Catalog client script to add text to the single line text variable rather than over written.

syedasimali
Kilo Expert

i would like to add text to single line text based on the select box options i select.

ie

var cat = g_form.getValue('domain');

if(cat == 'eee')

  {

  g_form.setValue('serverName', "DC");

  }

Another Catalog Client Script

  var cat = g_form.getValue('serv_env');

if(cat == 'dev')

  {

  g_form.setValue('serverName', "T");

  }

  }

I want variable to have text "DCT" however with these scripts it over writes the old text. i would like it to be added to the existing text.

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Replace another catalog CS as below




var cat = g_form.getValue('serv_env');


var serName = g_form.getValue('serverName');


if(cat == 'dev')


  {


var cat = g_form.getValue('domain');


var ser = serName +'t';


  g_form.setValue('serverName', ser);


  }


  }


View solution in original post

7 REPLIES 7

Let me know if that answered your question. If so, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list. Thank you


How To Mark Answers Correct From Community Inbox


syedasimali
Kilo Expert

i appreciate that.



then is there a way i merge two variable text into 1 variable. so it looks something like this.



serverName = DEVT


userInput = WEBMAIL


output = DEVTWEBMAIL


Script will be something like



var serName = g_form.getValue('PASS SERVER NAME COLUMN NAME');


var usrinput =   g_form.getValue('PASS USER NAME COLUMN NAME');


g_form.setValue('Third field column name', serName + usrinput);