Skip to main content
Hi, I am trying to find the error in my code, thank you for your help:

 

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

 

if("{!$Profile.Name}" =="System Administrator"){

 

    if("{!Opportunity.SOA_Sent__c}" == False){

 

        if("{!Opportunity.Notification_POC_Email__c}" !== ""){

 

                var OpportunityToUpdate = new sforce.SObject("Opportunity");

 

                OpportunityToUpdate.Id = "{!Opportunity.Id}";

 

                OpportunityToUpdate.SOA_Sent__c = true;

 

                var result = sforce.connection.update([OpportunityToUpdate]);

 

             if (result[0].success === "false"){

 

                    alert(result[0].errors.message);

 

                }

 

                else{

 

                    location.reload(true);

 

                }

 

            }

 

        else{

 

                alert("The Notification POC Email field cannot be blank!");

 

        }

 

    else{

 

        alert("A SOA has already been sent for this Opportunity!");

 

    }

 

else{

 

    alert("You do not have permission to send SOA's!");

 

}
2 件の回答
  1. 2018年5月3日 19:53

    Give this a shot = 

    if("{!$Profile.Name}" =="System Administrator"){

    if("{!Opportunity.SOA_Sent__c}" == false){

    if("{!Opportunity.Notification_POC_Email__c}" !== ""){

    var OpportunityToUpdate = new sforce.SObject("Opportunity");

    OpportunityToUpdate.Id = "{!Opportunity.Id}";

    OpportunityToUpdate.SOA_Sent__c = true;

    var result = sforce.connection.update([OpportunityToUpdate]);

    if (result[0].success === "false"){

    alert(result[0].errors.message);

    }

    else{

    location.reload(true);

    }

    }

    else{

    alert("The Notification POC Email field cannot be blank!");

    }

    }

    else{

    alert("A SOA has already been sent for this Opportunity!");

    }

    }

    else{

    alert("You do not have permission to send SOA's!");

    }

0/9000