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
AmphitriteAmphitrite 

conditional onclick javascript button -syntax help

This button populates a few fields on a list of cases. I need the field InEditUserId to only update if the UserControl__c=="Read-Write". But I'm having trouble figuring out the syntax. 

 

Here is my code so far - works w/o the conditional statement.

 

 

{!REQUIRESCRIPT("/soap/ajax/8.0/connection.js")} 
pagRef = window.location.href; 
var records = {!GETRECORDIDS($ObjectType.Case)}; 
var newRecords = []; 
if (records[0] == null) 

alert("Please select at least one row") 

else 

for (var n in records) { 
var c = new sforce.SObject("Case"); 
c.id = records[n]; 
c.XLS06__c =1; 
c.ReturntoViewURL__c=pagRef;

 

IF(c.UserControl__c=="Read-Write"){
c.InEditUserId__c="{!$User.Id}";}

 
newRecords.push(c); 

result = sforce.connection.update(newRecords); 
window.location = pagRef; 
}

AmphitriteAmphitrite

Fairly certain this will need to be determined in a query - posted new topic here  -http://boards.developerforce.com/t5/General-Development/conditional-onclick-javascript-button-query-syntax-help/td-p/701151.