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

RaghavSh
Kilo Patron

Try : 

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


Raghav
MVP 2023

View solution in original post

2 REPLIES 2

RaghavSh
Kilo Patron

Try : 

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


Raghav
MVP 2023

Ramel
Mega Guru

Thanks Raghav.