How to concatenate two catalog variables value to new variable which is hidden in the catalog form, and display that hidden catalog variable in RITM form

Arkesh Kumar
Giga Guru

How to concatenate two catalog variables value to new variable which is hidden in the catalog form, and display that hidden catalog variable in RITM form

find_real_file.png

 

I need to concatenate "International dailling code" and "Landline Number" into "Landline" Variable

"International dailling code" and "Landline Number" Variables are visible to user in catalog form but "Landline" variable only visible in RITM

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Arkesh,

You can create a Before insert or update business rule against sc_req_item and filter condition to only trigger against respective catalog item i.e item | is | XYZ with script as

if(current.variables.PASS International dailling code VARIABLE NAME && current.variables. PASS VARIABLELandline Number" NAME HERE)

{

current.variables.Landline = current.variables.PASS International dailling code VARIABLE NAME + current.variables.PASS VARIABLELandline Number" NAME HERE;

}

View solution in original post

9 REPLIES 9

Jaspal Singh
Mega Patron
Mega Patron

Hi Arkesh,

 

So, do you have any client script written for the same as I see you get NAN? 

If not you can try below business rule that runs before insert/update on the RITM table with Condition as your specific Catalog Item

Item | is | Your item name

Script"

(function executeRule(current, previous /*null when async*/) {

current.variable.landline=current.variables.internationaldialling+current.variables.landline;
//Replace above with correct variables names
})(current, previous);

REPEAT 😉

Ankur Bawiskar
Tera Patron
Tera Patron

@Arkesh 

Few assumptions:

1) I assume your landline variable is only hidden on Catalog Form and it is shown on RITM view.

2) You must be using either onLoad catalog client script or UI policy which applies to Catalog item view for this.

If yes then you would require onSubmit catalog client script to populate that variable.

UI Type - ALL

Applied on Catalog Item View-  True

Even though this variable is hidden on Catalog Item form you can set the value using g_form.setValue()

Sample script below:

Ensure you use correct variable name there

function onSubmit(){

var dialing = g_form.getValue('dialing-code-variable');

var landline = g_form.getValue('landline-number-variable');

var combined = dialing + '-' + landline;

g_form.setValue('landline-variable',combined);

}

Regards
Ankur

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

Arkesh Kumar
Giga Guru

Hello @Pradeep Sharma @Jaspal Singh @Ankur Bawiskar Thank you all. All the given answers are correct and working for me. Pradeep answered first so i am marking that answer as Correct Answer, and other answers as useful.

Thank you all for helping me,

Arkesh

You are very welcome Arkesh.