Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Convert string to number

Ramel
Mega Guru

Hi Community,

 

Good day! I am working on a notification and I just want to convert string value to number. This is for a custom notification that has configuration settings. Below is my script:

y - is the fieldname in the notifications config

var x = 'y';
var z = new customTable.ScriptInclude().getOptions('system_properties', x);
workflow.scratchpad.b = 2; //default value
if (z[x]){
    workflow.scratchpad.b = (z[x]).value; // (z[x]).value this is the value being pulled from the configuration settings in the notification, value there is every 2 days --> this is the one that is returning as string and not a number

When I run in background script it is, I can see the value which is 2 but the typeof is returning as string. Can somebody advise how can I rewrite the script that will convert 2 from being a string to make it a number.

Thank you.

 

1 ACCEPTED SOLUTION

Raghav Sharma24
Giga Patron

Try : 

workflow.scratchpad.b = parseInt((z[x]));

View solution in original post

2 REPLIES 2

Raghav Sharma24
Giga Patron

Try : 

workflow.scratchpad.b = parseInt((z[x]));

Ramel
Mega Guru

Thanks Raghav.