You need to sign in to do that
Don't have an account?

Call APEX from Visual Workflow
When trying to call an APEX class from any flow in my DE org I get an error message:
A fault occurred while executing your script:
Data Not Available: The data you were trying to access could not be found. It may be due to another user deleting the data or a system error. If you know the data is not deleted but cannot access it, please look at our support page.
I'm actually getting the error whenever a flow is trying to invoke APEX, even when I use an example that was posted on a salesforce.com blog. Does nybody have any ideas?
A fault occurred while executing your script:
Data Not Available: The data you were trying to access could not be found. It may be due to another user deleting the data or a system error. If you know the data is not deleted but cannot access it, please look at our support page.
I'm actually getting the error whenever a flow is trying to invoke APEX, even when I use an example that was posted on a salesforce.com blog. Does nybody have any ideas?
Posting your code may help with troubleshooting.
I am not sure what the issue could be, but I have done this in my org. Here is an example of my Class which is referenced from my flow. If you follow this you should get the flow and apex working..
global class flowExceedNameLength implements Process.Plugin{
// Main Code
global Process.PluginResult invoke(Process.PluginRequest request){
//This retrieves the input from your flow
String salu = (String) request.inputParameters.get('sal');
String fname = (String) request.inputParameters.get('firstname');
String lname = (String) request.inputParameters.get('lastname');
system.debug('####: ' + salu + ' '+fname+' '+lname);
//Your logic ie what you want the code to do
integer d = VisualProcessManager_Maintenance_v1.exceedNameLength(salu, fname, lname);
// return to flow
Map<string, object> rtnValue = new Map<string, object>();
rtnValue.put('exceedlen', d);
// Return result
return new Process.PluginResult(rtnValue);
}
//This is a must this defines all the inputs and output for apex plugin. You flow may not reference the class correctly if you do not define this.
global Process.PluginDescribeResult describe() {
Process.PluginDescribeResult result = new Process.PluginDescribeResult();
result.inputParameters = new List<Process.PluginDescribeResult.InputParameter>{
new Process.PluginDescribeResult.InputParameter('sal',
Process.PluginDescribeResult.ParameterType.STRING, true),
new Process.PluginDescribeResult.InputParameter('firstname',
Process.PluginDescribeResult.ParameterType.STRING, true),
new Process.PluginDescribeResult.InputParameter('lastname',
Process.PluginDescribeResult.ParameterType.STRING, true)
};
result.outputParameters = new List<Process.PluginDescribeResult.OutputParameter>{
new Process.PluginDescribeResult.OutputParameter('exceedlen',
Process.PluginDescribeResult.ParameterType.INTEGER)
};
return result;
}
}Hope this helps
Thank you for your response and I agree, your code should work and it looks very similar to my code. And here's what I've just done:
-
copy and paste your code into a new Apex class (I had to modify one line since I don't have access to the exceedNameLength method; but I just replaced it with a hard coded number)
-
create a new VWF that consists of 3 elements:
-
A screen taking in the data for the Apex class (Salutation, First Name and Last Name
-
the call to your Apex class
-
A screen displaying the output of your Apex class (I would've expected to see my number)
Unfortunately, I do get the exact same error message. Seems like something isn't setup right in my org or maybe I've discovered a bug?!?Thanks again,
Heiko.
On the brightside, it does work :-D