Javascript.wrappedexception: wrapped ConversionError

eleung1
Kilo Expert

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.

 

1 ACCEPTED SOLUTION

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.

View solution in original post

4 REPLIES 4

SanjivMeher
Kilo Patron
Kilo Patron

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.

eleung1
Kilo Expert

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.

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.

eleung1
Kilo Expert

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