I have the following code on a button


if (({!Service_Call__c.Incomplete_Parts_Count__c} > 0))
alert( "Error: One or more parts on this call have not been completely filled out. Update parts before releasing." ); 
else {
var newRecords = []; 
var c = new sforce.SObject("Service_Call__c");
c.id ="{!Service_Call__c.Id}"; 
c.Release__c = true;
result = sforce.connection.update(newRecords); 

It works as long as there is some type of number in that field, but sometimes it is just null and it causes this error. I've tried to manipulate my if statement to include the null, but I don't really know how. Any help would be appreciated. Thanks!

  • Does it work if you change Service_Call__c.Incomplete_Parts_Count__c to BLANKVALUE(Service_Call__c.Incomplete_Parts_Count__c, 0)?
    – Adrian Larson
    May 24, 2018 at 17:17
  • It worked now if the field was null, but gave an error that says "BLANKVALUE not defined" when there was a number in the field
    – ad_rey
    May 24, 2018 at 17:31

1 Answer 1


When possible, don't jump in and out of JavaScript; you can use normal formulas just like you would in Visualforce, which can reduce the likelihood of errors:

if( {!BLANKVALUE(Service_Call__c.Incomplete_Parts_Count__c,0) > 0} )

Upon evaluation, the JavaScript will be converted to a simple:

if( true )


if( false )

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .