The following piece of code snippet will help you invoke a visual flow from Custom Button/ Custom Links.
Limitation : We cannot create a Custom Button on User Std Object in salesforce.
Prerequisites : The flow which you are about to invoke should be active.
This below sample snippet is a Custom Link created on USER object.
Limitation : We cannot create a Custom Button on User Std Object in salesforce.
Display Type : Detail Page Link
Behavior : Execute JaveScript
Content Source : OnClick JavaScript
{!REQUIRESCRIPT("/soap/ajax/28.0/connection.js")}
{!REQUIRESCRIPT("/support/console/28.0/integration.js")}
{!
IF( User.isActive , "allowInvokeFlowFunction() ;" ,"alert('The user seems to be Inactive');")}
function allowInvokeFlowFunction(){
var url = '/flow/You_Flow_API_Name?inputUserID={!User.Id}';
if (sforce.console.isInConsole()) {
sforce.console.openPrimaryTab(null, url, true);
} else {
window.open(url,'_blank');
}
}
In the above snippet allowInvokeFlowFunction ( ) is being called within IF condition is just to have a validation so that only Active Users can invoke the flow.
This step can be vomited and one can just invoke the Flow.
Note: If your flow is expecting any input then you can pass the required values as shown above. In the above example we are passing UserId to flow. If nothing is required, then this can be vomited.
inputUserID : This is a flow variable which is set to as "Input Only ".
Flow Variable :
inputUserID : This is a flow variable which is set to as "Input Only ".
Flow Variable :
Comments
Post a Comment