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
Sonia GenesseSonia Genesse 

onClick Exectue Java script for SF button, need to add addtional IF

Hello,

I have created an onClick Exectue Java script button, which works well except that I need to add an addtional IF for the same picklist value:
if SVMXC__Service_Order__c.SVMXC__Order_Status__c, picklsit value = "Closed" or "Unresolved", how do I add this to my existing  script below?

if({!NOT(ISPICKVAL(SVMXC__Service_Order__c.SVMXC__Order_Status__c, "Closed"))}){
     alert("Close Work Order button has not been completed, the Work Order Order Status has not been set to Closed or Unresolved");
}
else{
    window.top.location.href =
        "/apex/loop__looplus?sessionId={!$Api.Session_ID}&eid={!SVMXC__Service_Order__c.Id}&filter={!SVMXC__Service_Order__c.Email_Integrator__c}Service&servcont_Name={!SVMXC__Service_Order__c.SVMXC__Contact__c}&servcont_email={!SVMXC__Service_Order__c.Contact_Email__c}";

}


Thanks!
Sonia
 
Deepak Pandey 13Deepak Pandey 13
if({!NOT(ISPICKVAL(SVMXC__Service_Order__c.SVMXC__Order_Status__c, "Closed"))} 
                      || {!NOT(ISPICKVAL(SVMXC__Service_Order__c.SVMXC__Order_Status__c, "Unresolved"))}){
     alert("Close Work Order button has not been completed, the Work Order Order Status has not been set to Closed or Unresolved");
}

 
Dushyant SonwarDushyant Sonwar
if('{!SVMXC__Service_Order__c.SVMXC__Order_Status__c}' !='Closed' || '{!SVMXC__Service_Order__c.SVMXC__Order_Status__c}' !='Unresolved'){
     alert('Close Work Order button has not been completed, the Work Order Order Status has not been set to Closed or Unresolved');
}
else{
    window.top.location.href = '/apex/loop__looplus?sessionId={!$Api.Session_ID}&eid={!SVMXC__Service_Order__c.Id}&filter={!SVMXC__Service_Order__c.Email_Integrator__c}Service&servcont_Name={!SVMXC__Service_Order__c.SVMXC__Contact__c}&servcont_email={!SVMXC__Service_Order__c.Contact_Email__c}';

}

Sonia , Above code will work fine . Hope this helps !!!
Sonia GenesseSonia Genesse
Hello and thank you both!

I've tried both of these solutions and both are throwing the Alert message no matter what the the value of this field is: {!SVMXC__Service_Order__c.SVMXC__Order_Status__c}. 

This Javascript works fine on it's own as shown below, but when I try to include the not equal to "Unresolved" status, I'm receiving an error even for "Closed" and "Unresolved"..... any thoughts as to why?

if({!NOT(ISPICKVAL(SVMXC__Service_Order__c.SVMXC__Order_Status__c, "Closed"))} || {!NOT(ISPICKVAL(SVMXC__Service_Order__c.SVMXC__Order_Status__c, "Unresolved"))}){
     alert("Close Work Order button has not been completed, the Work Order Order Status has not been set to Closed or Unresolved");
}
}
else{
     "window.top.location.href = '/apex/loop__looplus?sessionId={!$Api.Session_ID}&eid={!SVMXC__Service_Order__c.Id}&filter={!SVMXC__Service_Order__c.Email_Integrator__c}Service&servcont_Name={!SVMXC__Service_Order__c.SVMXC__Contact__c}&servcont_email={!SVMXC__Service_Order__c.Contact_Email__c}";

}


Thanks again!
Sonia