Catalog Item Requirement

purdue
Kilo Sage

Hello,

I trying to populate the fields below when a business app is selected.  It is working but bringing back value instead of Display Value. AND I am trying to bring back user cost center and populate 

  Any assistance is appreciated.

 

Field: Data Classification<-Auto-populated by Business Application field (Data Classification')

Screenshot 2025-01-23 at 5.30.32 PM.png

Thanks,

Chad

1 ACCEPTED SOLUTION

Hello @purdue 

Here is the updated script include:

 

getdataclassfication: function() {
    var result = {};
    var appName2 = this.getParameter('sysparm_appName');
    var grAppRole2 = new GlideRecord('cmdb_ci_business_app');
    grAppRole2.addQuery('name', appName2);
    grAppRole2.setLimit(1);
    grAppRole2.query();
    if (grAppRole2.next()) {
        result.roleDetails = grAppRole2.getValue('data_classification');
    }
    return JSON.stringify(result);
},

 

Hope this helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"

 

Thank You
Juhi Poddar

 

View solution in original post

12 REPLIES 12

Bidduam
Tera Guru

You need to set the display value in the command:

Bidduam_0-1737678539711.png

You're only setting the field name and the value, not the display value

 

You could also go and directly get the display value and add it:

var MyDisplayValue = g_form.getDisplayValue('your_variable_name');

g_form.setValue('data_classification', MyDisplayValue);

Ankur Bawiskar
Tera Patron
Tera Patron

@purdue 

you can use Auto populate Utah feature and no scripting required

Based on reference variable you can set the other varaible

Auto-populate a variable based on a reference type variable (Utah) 

If it still doesn't work then you can use GlideAjax and bring the label of that choice field (data_classification)

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hello, 

The Auto Populate is not working it is bringing back the label on the item which is correct however once submitted the value is stored not the label so I will need to use GlideAjax.   Please provide example of pulling the value from Business_App.Data Classification and setting it in a reference field which points to sys_choice where the data classification values are held.   Thanks a bunch. Chad

The reason why I need the reference to point the sys_choice is some bus apps do not have data classification set so the user will need to select it but if it is populated set it from bus app.

Thanks a bunch,

Chad