function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mick MuMick Mu 

Javascript problem

Hi all does anyone have any idea why when i put "c.Support_Term__c+=1;" into this script it stops working? the editor tells me that the syntax is correct? and when i take this line out the PO_Status__c gets updated as expected. All Suport_Term__c is is a number(3,0) with a default value of 0.

 

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}

var newRecords = [];

var c = new sforce.SObject("Purchase_Form__c");
c.id ="{!Purchase_Form__c.Id}";
c.Support_Term__c+=1;
c.PO_Status__c = "Submitted";
newRecords.push(c);

 

Thanks

result = sforce.connection.update(newRecords);

window.location.reload();

 

Best Answer chosen by Admin (Salesforce Developers) 
MagulanDuraipandianMagulanDuraipandian

Try like this

c.Support_Term__c = {!Purchase_Form__c.Support_Term__c} + 1;

 

Regards,

Magulan D

Salesforce.com certified Force.com Developer.

SFDC Blog

SFDC Site

If this post is your solution, kindly mark this as the solution.

All Answers

MagulanDuraipandianMagulanDuraipandian

Try like this

c.Support_Term__c = {!Purchase_Form__c.Support_Term__c} + 1;

 

Regards,

Magulan D

Salesforce.com certified Force.com Developer.

SFDC Blog

SFDC Site

If this post is your solution, kindly mark this as the solution.

This was selected as the best answer
Mick MuMick Mu

Ah! thats got it! thanks for your help!