I have a script task in my process which executes the following javascript task, that is linked as a seperate file:
var current_step = RMPApplication.getVariable('V_CurrentStep');
var work = RMPApplication.getVariable('V_ApprovalsRequired');
current_step = current_step + 1;
if (work < current_step) {
var approverArray = RMPApplication.getVariable('approvers_list');
//convert them to JSON
var jsonListApprover = JSON.parse(approverArray);
var approverName = jsonListApprover.approverName[current_step];
var approverEmail = jsonListApprover.approver[current_step];
RMPApplication.setVariable('V_ApproverName', approverName);
RMPApplication.setVariable('V_ApproverEmail', approverEmail);
RMPApplication.setVariable('V_CurrentStep', current_step);
} else {
//Approved
RMPApplication.setVariable('V_FinalApproval', 'true');
}
When the process is at task, an error is thrown: 2015-08-31T15:09:02+0000 - Task "Set next approver" (id: 5[0] - status: ACTIVE): Error while processing <@script env="javascript">
.....
setVariable('V_FinalApproval', 'true');
};</@script>
Unexpected error (1 attempt)
I don't know what I am doing wrong here and how to fix this.
I read something on this page: http://docs.runmyprocess.com/User_Guide/Development_Environment/Toolbox/Processes/Step/Task/Process_Task_Script_Tab
Your javascript file can only use process' variables defined or redefined (a=${a}) as input variable of your script task
But I don't know what this mean since there is no sample found anywhere. So I have no idea, if this is the case or not. I tried to rewrite this by using input variables, but I got the same error.
This was my new javascript code I used after I added three input variables:
current_step = ${V_CurrentStep}
work = ${V_ApprovalsRequired}
approverArray = ${approvers_list}
current_step = current_step + 1;
if (work < current_step) {
var jsonListApprover = JSON.parse(approverArray);
var approverName = jsonListApprover.approverName[current_step];
var approverEmail = jsonListApprover.approver[current_step];
setVariable('V_ApproverName', approverName);
setVariable('V_ApproverEmail', approverEmail);
setVariable('V_CurrentStep', current_step);
} else {
//Approved
setVariable('V_FinalApproval', 'true');
setVariable('V_FinalApproval', 'true');
}
Still same error, so what do I do wrong?
p.s. Someone suggested to remove the else statement, but then it would not make any sense anymore, since I am still needing the if statement.
--
Fujitsu - RunMyProcess
---
You received this message because you are subscribed to the Google Groups "Fujitsu RunMyProcess Developer Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to supportforum...@runmyprocess.com.
To post to this group, send email to suppor...@runmyprocess.com.
Visit this group at http://groups.google.com/a/runmyprocess.com/group/supportforum/.
To view this discussion on the web visit https://groups.google.com/a/runmyprocess.com/d/msgid/supportforum/cf496396-5fb8-4ba9-b06d-59392f0a01c2%40runmyprocess.com.
For more options, visit https://groups.google.com/a/runmyprocess.com/d/optout.
In your code sample I am missing the
"setVariable('V_FinalApproval', 'true');"
I am needing this variable to end this process, otherwise I run into an endless loop. Setting this variable is my stopping criteria.
How can I fix this? It now seems incorrect (I did not test this btw, just following the script logic).
I still receive the same error:
2015-09-03T08:43:41+0000 - Task "Set next approver" (id: 5[0] - status: ACTIVE): Error while processing <@script env="javascript">current_step = current_step + 1;
if (work < current_step) {
var jsonListApprover = JSON.parse(approverArray);
var approverName = jsonListApprover.approverName[current_step];
var approverEmail = jsonListApprover.approver[current_step];
setVariable('V_ApproverName', approverName);
setVariable('V_ApproverEmail', approverEmail);
setVariable('V_CurrentStep', current_step);
}
;</@script>
Unexpected error (1 attempt)
So I have no idea what is wrong here.
--
Fujitsu - RunMyProcess
---
You received this message because you are subscribed to the Google Groups "Fujitsu RunMyProcess Developer Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to supportforum...@runmyprocess.com.
To post to this group, send email to suppor...@runmyprocess.com.
Visit this group at http://groups.google.com/a/runmyprocess.com/group/supportforum/.
To view this discussion on the web visit https://groups.google.com/a/runmyprocess.com/d/msgid/supportforum/11b38144-adc7-458c-b3e8-d604b20d072b%40runmyprocess.com.
I tried the code that you suggested but its still throwing the following error:
2015-09-07T09:22:37+0000 - Task "Set next approver" (id: 5[0] - status: ACTIVE): Error while processing <@script env="javascript">current_step = Number(current_step) + 1;
if (work < current_step) {
var jsonListApprover = JSON.parse(approverArray);
var approverName = jsonListApprover.approverName[current_step];
var approverEmail = jsonListApprover.approver[current_step];
setVariable('V_ApproverName', approverName);
setVariable('V_ApproverEmail', approverEmail);
setVariable('V_CurrentStep', current_step);
}
;</@script>
Unexpected error (1 attempt)
Any suggestions where i might be going wrong?
Thanks
Menosshan
--
Fujitsu - RunMyProcess
---
You received this message because you are subscribed to the Google Groups "Fujitsu RunMyProcess Developer Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to supportforum...@runmyprocess.com.
To post to this group, send email to suppor...@runmyprocess.com.
Visit this group at http://groups.google.com/a/runmyprocess.com/group/supportforum/.
To view this discussion on the web visit https://groups.google.com/a/runmyprocess.com/d/msgid/supportforum/41c44511-77ec-4f7a-8f10-1002523e6166%40runmyprocess.com.
--
Fujitsu - RunMyProcess
---
You received this message because you are subscribed to the Google Groups "Fujitsu RunMyProcess Developer Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to supportforum...@runmyprocess.com.
To post to this group, send email to suppor...@runmyprocess.com.
Visit this group at http://groups.google.com/a/runmyprocess.com/group/supportforum/.
To view this discussion on the web visit https://groups.google.com/a/runmyprocess.com/d/msgid/supportforum/edf7730d-b999-4a47-bbb4-a9867b953925%40runmyprocess.com.