You need to sign in to do that
Don't have an account?
Error using an Apex Plugin with Cloud Flow
Hi,
I've created a Flow that utilises an Apex Plugin that takes the nominated Date from the Flow (CurrentDate), adds 1 month and returns the new date into 'NextDate'. Both fields exist as Date fields on the Flow, however when running the flow it returns the following error:
An unhandled fault has occurred in this flow
An unhandled fault has occurred while processing the flow.
The Apex Code I'm using is pasted below. Any help on why it's not working would be appreciated?
global class MicrosoftLAR implements Process.Plugin {
global Process.PluginResult invoke(Process.PluginRequest request) {
Date CurrentDate = (Date)request.inputParameters.get('CurrentDate');
Date TempDate = Date.newInstance(CurrentDate.year(),CurrentDate.month(),CurrentDate.day());
Date NextDate = TempDate.addMonths(1);
Map<String, Object> result = new Map<String, Object>();
result.put('NextDate', NextDate);
return new Process.PluginResult(result);
}
global Process.PluginDescribeResult describe() {
Process.PluginDescribeResult result = new Process.PluginDescribeResult();
result.description='This plug-in adds 1 month to a given date and returns the result.';
result.tag='Next Schedule Date';
result.inputParameters = new List<Process.PluginDescribeResult.InputParameter> {
new Process.PluginDescribeResult.InputParameter('CurrentDate',
Process.PluginDescribeResult.ParameterType.DATE, true)
};
result.outputParameters = new List<Process.PluginDescribeResult.OutputParameter> {
new Process.PluginDescribeResult.OutputParameter('NextDate',
Process.PluginDescribeResult.ParameterType.Date)
};
return result;
}
}
For those who may come across this post... I found the problem.
The date coming from flow is actually a DateTime field, therefor my 4th line should have been:
DateTime CurrentDate = (DateTime)request.inputParameters.get('CurrentDate');