You need to sign in to do that
Don't have an account?
das61
Setting and clearing a flag
Hello.
I'm new to the forums. I have a question regarding setting a flag (checkbox) to cause certain trigger and workflow actions. I have a button with the javascript shown below. There is a flag called Submit to Legal. When this is set to true, it triggers an email alert to be sent as an action in a workflow. I orginally thought I could then clear the flag (set to false) in an apex trigger that already exists. It appears the flag is being cleared before the workflow is executed and therefore the email is not being sent. When I comment out the code to clear the flag, the email is sent but the flag is not cleared. What would be the best practice to accomplish this.
Thanks in advance.
var agreement= new sforce.SObject("Agreement__c");
agreement.Id= "{!Agreement__c.Id}";
var Agreement_Status = "{!Agreement__c.Agreement_Status__c}";
//var CMO_Request_Status = "{!Agreement__c.CMO_Request_Status__c}";
if (Agreement_Status != 'Legal Submitted' && Agreement_Status != 'Legal Assigned' && Agreement_Status != 'Legal Drafting' && Agreement_Status != 'Legal in Review' && Agreement_Status != 'Closed'){
agreement.Submit_To_Legal__c = true;
var result = sforce.connection.update([agreement]);
if (result[0].getBoolean("success"))
{
// Refresh window
window.location = window.location.href+'?eraseCache=true';
window.location.reload(true);
}
else
{
alert("Error saving Agreement"+result[0]);
}
}else{
alert('Agreement is already in Legal or Closed status.');
}
I'm new to the forums. I have a question regarding setting a flag (checkbox) to cause certain trigger and workflow actions. I have a button with the javascript shown below. There is a flag called Submit to Legal. When this is set to true, it triggers an email alert to be sent as an action in a workflow. I orginally thought I could then clear the flag (set to false) in an apex trigger that already exists. It appears the flag is being cleared before the workflow is executed and therefore the email is not being sent. When I comment out the code to clear the flag, the email is sent but the flag is not cleared. What would be the best practice to accomplish this.
Thanks in advance.
var agreement= new sforce.SObject("Agreement__c");
agreement.Id= "{!Agreement__c.Id}";
var Agreement_Status = "{!Agreement__c.Agreement_Status__c}";
//var CMO_Request_Status = "{!Agreement__c.CMO_Request_Status__c}";
if (Agreement_Status != 'Legal Submitted' && Agreement_Status != 'Legal Assigned' && Agreement_Status != 'Legal Drafting' && Agreement_Status != 'Legal in Review' && Agreement_Status != 'Closed'){
agreement.Submit_To_Legal__c = true;
var result = sforce.connection.update([agreement]);
if (result[0].getBoolean("success"))
{
// Refresh window
window.location = window.location.href+'?eraseCache=true';
window.location.reload(true);
}
else
{
alert("Error saving Agreement"+result[0]);
}
}else{
alert('Agreement is already in Legal or Closed status.');
}
All Answers