How to compare String variable in catalog item with integer field on user record (requested for user record) in if activity in workflow?

HARI KISHAN GVS
Mega Sage

Hi Team, 

my requirement is

i have a string variable(requested_amount) in my catalog item

and i have a integer field(available_amount) on user table (sys_user)

and i have requested_ for variable in my catalog item.

Now in my workflow if activity or Approval group activity i need to compare requested amount and available amount(requested for.available_amount). and if requested amount is greater than available amonut approval will go to ABC Group. if requested amount is less than available amount approval will go to DEF group.

i am stuck at how to convert my string variable value to integer to compare the two values? and how can i compare the two? like which operators i need to use?

 

can anyone Please provide the solution/ sample script for comparision?

Thanks in advance,

Hari Kishan.

2 REPLIES 2

Shruti
Mega Sage
Mega Sage

Hi,

You can use parseInt() to convert string to number

Click Advanced checkbox in the workflow IF activity and use below function to compare the values

parseInt(current.variables.requested_amount)

Ravindra Lodhi
Kilo Expert

Hello @HARI KISHAN GVS

You can direct check the condition as below syntax

if(parseInt(current.variables.requested_amount)==ParseInt(current.variables.requested_for.available_amount))

{

return "Yes";

}

else

{

return "No";

}

Thanks