Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Need populate quotation in catalog variable

poco
Tera Contributor
  • If the field is empty, then the value must be nothing.
    Preferred First Name = ""

  • If the field is not empty, then the value must include the quotation marks ("").
    Preferred First Name= '"Preferred First Name"'

please help me on this 

1 ACCEPTED SOLUTION

Its_Azar
Tera Guru
Tera Guru

Hi there @poco 

Good question and I think you can do this with a client script in the catalog item to populate the value of the catalog variable accordingly

function onLoad() {
    var preferredFirstName = g_form.getValue('preferred_first_name'); variable name

    if (preferredFirstName) {
        g_form.setValue('preferred_first_name', '"' + preferredFirstName + '"');
    } else {
        g_form.setValue('preferred_first_name', '');
    }
}

If this helps kindly accept the response thanks much.

ā˜‘ļø If this helped, please mark it as Helpful or Accept Solution so others can find the answer too.

Kind Regards,

Mohamed Azarudeen Z

Developer @ KPMG

View solution in original post

5 REPLIES 5

Sohail Khilji
Kilo Patron

where and why ?


ā˜‘ļø Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Hi Sohail 

I need to populate like this in "Preferred First Name"' value in service catalog variable  

use like this in client script , + ''+ prefered first name +''+

 

Can you explain your requirement clearly ? were when how etc...


ā˜‘ļø Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

suppose user submit the catalog form request  "prefered first name " is choice question and optional  suppose user fill the that field the value between quotation mark other wise blank