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

Hello,

It is not working.

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.hasNext()){
result.roleDetails = grAppRole.getValue('data_classification').toString();
}
 
return JSON.stringify(result);
},
Client script
Screenshot 2025-01-25 at 10.07.49 PM.png

Ayushi12
Mega Sage

Hi @purdue 
Use getDisplayValue() method to reterieve the display value of Business Application field.
In case Business Application field is a reference field and you are trying to populate the field like data classification, cost center from Business Application record try using script include method.
Refer: https://www.servicenow.com/community/developer-forum/populate-logged-in-user-details-in-catalog-item...

If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful."

Thanks!

 

Hello,

Are you saying to use the getDisplayValue in the first line of the client script?

Thanks a bunch.

Chad

Hello,

It is not working.

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.hasNext()){
result.roleDetails = grAppRole.getValue('data_classification').toString();
}
 
return JSON.stringify(result);
},
Client script
Screenshot 2025-01-25 at 10.07.49 PM.png

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