Split returned variable from choice/select into 2 variables

Ron28
Kilo Sage

Hello, 

In a Standard Catalog item I have added a choice question from a cmdb table. This choice returns the value from 2 columns in the cmdb table, separated by a vertical bar. But they are one single variable, I need to split these 2 values. Where can I do this? In Flow designer?

Thanks

Ron

 

6 REPLIES 6

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi Ron,

Values in a field can be split in Client Script.

For example, to split value from field named 'u_field1', create a onChange() or onSubmit() client script and use JavaScript's split() function.

e.g.

var valArray = g_form.getValue('u_field1").split('|'); // values will be in an array named valArray. First value will be in valArray[0] and second value will be in valArray[1].

Community Alums
Not applicable

Hi Ron,

Refer to thread: https://community.servicenow.com/community?id=community_question&sys_id=a16e4f80dbaa501011762183ca96...

 

Mark my answer correct & Helpful, if Applicable.

Thanks,

Sandeep

Hitoshi Ozawa
Giga Sage
Giga Sage

Values may also be split in business rule before the data is entered into a database table.

Business rule also uses JavaScript so it'll still use the .split('\') function.

Where the script should be written will depend on how the split values will be used. If they are to be displayed on the form, create a client script. If they are to be saved to a database table fields, use business rule.