Changes

Jump to: navigation, search

Trigger a Workflow from a Custom Browser Script

686 bytes added, 14:49, 13 May 2010
no edit summary
[[Workflow|Workflows]] can be triggered based on a value in a [[Custom Fields|custom field]] on the object using a [[Browser|browser]] script. The [[Workflow|workflow]] id is passed to the system from the script.
 
This procedure is for use within the [[UTA]] only.
==Syntax==
'''NOTE''': For [[Workflow|workflows]] triggered by a [[Browser Script]] within a [[UTA]] you should set '''Trigger When''' to '''--Deactivate--''' rather than selecting a [[Status]].
 ==ExampleExamples==1) To create a button that triggers a workflow at Level 2:
Create a [[Custom Field Type: Read Only – System Variables|Read Only – System Variables]] Custom Field. In the '''Text/Link:''' section include the following:
<input type="button" class=Button value="Button Label" onClick="_triggerwf('@eventid@',''workflowid'',26);"/>
 
2) To trigger a workflow based on the value in a [[Custom Field]] at Level 1:
 
In order to trigger workflow #32123 when the Custom Field named ''My Field'' (Custom Field ID 123456) has the value ''This Value'':
 
Create a [[Browser Script]] Custom Field:
 
<pre>
function savefunc(frm){
if("@My Field@"!="This value" && frm.123456.value=="This value")
{
alert("The workflow will now be triggered");
_triggerwf('@opportunityid@',32123);
}
return true;
}
</pre>
 
Notes:
* The function [[savefunc]] is run whenever a record is saved.
* The if statement will ensure that the workflow is only triggered when the ''My Field'' value is '''changed''' to ''This Value'', not every time the page is saved with with ''This Value''.
0
edits

Navigation menu