- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2018 03:04 PM
Hello I have a an IF statement in a workflow that checks for location of three different variables in a catalog item. However I am getting the following error (attached): Fault Description: org.mozilla.javascript.WrappedException:Wrapped conversionError.......
My script is:
answer = ifScript();
function ifScript() {
var revbranch = current.variables.rev_branch.getDisplayValue();
var sellbranch = current.variables.sell_branch.getDisplayValue();
var advbranch = current.variables.adv_branch.getDisplayValue();
if ((revbranch.startsWith('Cal')) && (!revbranch.includes('bridge')) || (revbranch.startsWith('Edt')) || (revbranch.startsWith('Leth')) || (revbranch.startsWith('Med'))) {
return 'yes';
}
else if ((sellbranch.startsWith('Cal')) && (!sellbranch.includes('bridge')) || (sellbranch.startsWith('Edt')) || (sellbranch.startsWith('Leth')) || (sellbranch.startsWith('Med'))) {
return 'yes';
}
else if ((advbranch.startsWith('Cal')) && (!advbranch.includes('bridge')) || (advbranch.startsWith('Edt')) || (advbranch.startsWith('Leth')) || (advbranch.startsWith('Med'))) {
return 'yes';
}
else{
return 'no';
}
}
Can anyone provide insight as to what is causing this error? Thank you.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2018 10:19 AM
For debugging, lets add few debug statements. Let me know, what you see in the log
answer = ifScript();
function ifScript() {
gs.log('+++++++++inside the function+++++++');
var revbranch = current.variables.rev_branch.getDisplayValue();
var sellbranch = current.variables.sell_branch.getDisplayValue();
var advbranch = current.variables.adv_branch.getDisplayValue();
gs.log('++++++++revbranch+++++++++++++'+revbranch );
gs.log('++++++++sellbranch +++++++++++++'+sellbranch );
gs.log('++++++++advbranch +++++++++++++'+advbranch );
if ((revbranch.startsWith('Cal')) && (!revbranch.includes('bridge')) || (revbranch.startsWith('Edt')) || (revbranch.startsWith('Leth')) || (revbranch.startsWith('Med'))) {
gs.log('+++++++++if 1+++++++');
return 'yes';
}
else if ((sellbranch.startsWith('Cal')) && (!sellbranch.includes('bridge')) || (sellbranch.startsWith('Edt')) || (sellbranch.startsWith('Leth')) || (sellbranch.startsWith('Med'))) {
gs.log('+++++++++if 2+++++++');
return 'yes';
}
else if ((advbranch.startsWith('Cal')) && (!advbranch.includes('bridge')) || (advbranch.startsWith('Edt')) || (advbranch.startsWith('Leth')) || (advbranch.startsWith('Med'))) {
gs.log('+++++++++if 3+++++++');
return 'yes';
}
else{
gs.log('+++++++++if 4+++++++');
return 'no';
}
}
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2018 04:13 PM
I think instead of StartsWith and include, you should use indexOf. is startsWith and include a valid function?
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2018 09:32 PM
Hi sanjivmeher thanks fore replying. Yes both startsWith and Include are valid methods. This script actually worked fine and was tested numerous times with failing. Then it stopped working??? I checked back to my documentation and the script has not change at all.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2018 10:19 AM
For debugging, lets add few debug statements. Let me know, what you see in the log
answer = ifScript();
function ifScript() {
gs.log('+++++++++inside the function+++++++');
var revbranch = current.variables.rev_branch.getDisplayValue();
var sellbranch = current.variables.sell_branch.getDisplayValue();
var advbranch = current.variables.adv_branch.getDisplayValue();
gs.log('++++++++revbranch+++++++++++++'+revbranch );
gs.log('++++++++sellbranch +++++++++++++'+sellbranch );
gs.log('++++++++advbranch +++++++++++++'+advbranch );
if ((revbranch.startsWith('Cal')) && (!revbranch.includes('bridge')) || (revbranch.startsWith('Edt')) || (revbranch.startsWith('Leth')) || (revbranch.startsWith('Med'))) {
gs.log('+++++++++if 1+++++++');
return 'yes';
}
else if ((sellbranch.startsWith('Cal')) && (!sellbranch.includes('bridge')) || (sellbranch.startsWith('Edt')) || (sellbranch.startsWith('Leth')) || (sellbranch.startsWith('Med'))) {
gs.log('+++++++++if 2+++++++');
return 'yes';
}
else if ((advbranch.startsWith('Cal')) && (!advbranch.includes('bridge')) || (advbranch.startsWith('Edt')) || (advbranch.startsWith('Leth')) || (advbranch.startsWith('Med'))) {
gs.log('+++++++++if 3+++++++');
return 'yes';
}
else{
gs.log('+++++++++if 4+++++++');
return 'no';
}
}
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2018 08:10 AM
Thank you very much sanjivmeher. I got this resolved based on the logs. The undefined value in the error message is the result of the rev_branch variable being inactivated and overlooked in the script.
Appreciate the guidance,
Ed