The CreatorCon Call for Content is officially open! Get started here.

Reference field value is coming but which is not visible

Mani60
Tera Contributor
Hi All, I have written one scripted rest API for creating a new Request, and i have tested via postman and new Request has been created and also RITM, but in Req and RITM form the reference field (ex: company, department) name are poputing but these are not visible Please find the attached scripted rest API code: (function process( /*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) { var error = ''; var catItem = ''; var cat = new GlideRecord('sc_cat_item'); if (cat.get('name', 'New Hire/Transfer')) { catItem = cat.sys_id; } var cart = new Cart(); var item = cart.addItem(catItem); cart.setVariable(item, 'company', request.body.data.company); cart.setVariable(item, 'existing_department', request.body.data.existing_department); var cartGR = cart.getCart(); cartGR.update(); var rc = cart.placeOrder(); response.setBody({ result: 'Catalog Item request' + rc.number + 'created.' }); })(request, response); Please help me how can I get these fields values visible. Thanks,
11 REPLIES 11

lunchtimeres
Kilo Contributor

From your provided scripted REST API code, it seems that you are successfully creating a new Request and RITM (Requested Item) in ServiceNow using the API. However, you are facing an issue with the reference field values (e.g., company, department) not being visible on the Req and RITM forms.

To make the reference field values visible on the Req and RITM forms, you need to ensure that the reference fields are correctly configured to display the values you are setting through the scripted REST API.

Here are some steps to check and verify:

  1. Field Visibility: Make sure that the reference fields (e.g., company, department) are visible on the forms for both the Request (REQ) and Requested Item (RITM) records. You can check this by going to the form layouts and ensuring that the fields are not marked as hidden or read-only.

  2. Field Permissions: Check the field-level permissions for the reference fields. Ensure that the user role you are using to create the Request and RITM through the API has the necessary read and write permissions for these fields.

  3. Form Conditions: Sometimes, form conditions or business rules might be in place that affect the visibility of certain fields based on specific conditions. Review any form conditions or business rules related to the reference fields and ensure they are not preventing the fields from being displayed.

  4. Catalog Item Configuration: Verify the catalog item configuration for the "New Hire/Transfer" item (based on the name you provided in the script). Ensure that the reference fields (company, department) are correctly mapped to the corresponding variables in the catalog item configuration.

  5. Scripted REST API Execution Context: Ensure that the user role executing the scripted REST API has the necessary permissions to interact with the referenced tables (e.g., 'sc_cat_item', 'company', 'department').

If you have checked and confirmed that the above aspects are correctly configured, the reference field values should be visible on the REQ and RITM forms when you create a new Request through the API.

If you are still facing issues, you might consider checking the system logs and debugging the script execution to identify any potential errors or issues.

Sagar Pagar
Tera Patron

Hi @Mani60,

 

Make sure that record is active and at least 1 column with display value as true in reference table.

 

Also, Take a look at these articles or old threads. might be helpful.

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0693859 

https://www.servicenow.com/community/developer-forum/reference-field-not-displaying-value-when-selec... 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0785309 


If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar

The world works with ServiceNow

Hi @Sagar Pagar Thanks for replying
I'm facing these issue When I create ticket through postman then the value of reference field is not visible.
please find the attached snapshot

Mani60_1-1691384041432.png

Please help me how can I get these fields values visible.

Thanks,

 

 

Hi @Mani60,

 

have you checked the display value for referenced tables? Company and Department?

 

Make sure that you do have the correct Department and Company sys_id's in

Department: request.body.data.company

Company: request.body.data.existing_department

 


If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar

The world works with ServiceNow

Hi  @Sagar Pagar 
When I take sys_id, at that time the Company and department's values are visible, but when I try to take the Name of the company and department at that time the value is not visible.

Here i don't need via sys_id here i  need via name