Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to remove commas from a integer value in flow designer

Kvb Kiran
Tera Contributor

In flow designer i am using an "if" condition and compare two values between catalog variables with values in a table.

I have fetched the values of both catalog as well as table using "get catalog variables" and "look up record" actions respectively.
In table, one of a field is having integer value with commas " , " in between the number. 

Catalog variable is a user selection field. It is having a reference details button ( i ) symbol to the left of it. I was comparing one of a field from the reference details section. This field value is integer without any commas.

In the table that i am comparing to, the same field is having commas " , ". This field value is also integer but with commas.

 

How can i compare this in flow's " if " condition?
If the value is different, then only the next action should be triggered, but here it is going to trigger always even though there is no difference practically. I just want to trim the integer.

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Kvb Kiran 

Do this

1) create a flow variable of type integer

2) then use "Set Flow Variables" flow action and store integer i.e. convert string to integer using parseInt

3) then use this Flow variable in your IF flow logic

OR

you can use Transform functions in flow

Transform functions 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Kvb Kiran 

Do this

1) create a flow variable of type integer

2) then use "Set Flow Variables" flow action and store integer i.e. convert string to integer using parseInt

3) then use this Flow variable in your IF flow logic

OR

you can use Transform functions in flow

Transform functions 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

@Kvb Kiran 

like this, also attached the gif to post

var numString = fd_data._1__get_catalog_variables.my_number;
var cleanedString = numString.replace(/,/g, '');
// Convert the cleaned string to a number
var result = Number(cleanedString);
return result;

flow variable convert string to number.gif

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thank you for your quick responses. 

Any idea on which transform function i can choose? I feel like transform function is easy to configure. I am trying different transform functions to look when it would remove the commas.

The transform function "Trim" worked like a charm.