The Zurich release has arrived! Interested in new features and functionalities? Click here for more

How to get g_form.getUniqueValue() display value?

Keang
Tera Contributor

Hello,

This is primarily for educational purposes. 

Currently the following code populated the sys_id in the description. How do I it to display the ritm number instead of sys_id?   Thank you 

 

var recSysId = current.getUniqueValue();

var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('sys_id', recSysId);
ritm.query();
if (ritm.next()) {
    ritm.description = recSysId;
   
} else {
    return false;
}
1 ACCEPTED SOLUTION

@Keang ,Thanks for marking my answer as helpful. If it helped you in any way please accept the solution so that it will be beneficial to the future readers with the same query

 

Regards,

Swathi

View solution in original post

7 REPLIES 7

Tony Chatfield1
Kilo Patron

Hi, your post mentions client script but you are referencing the current object in your code and this is not available client side.

In a client script g_form.getUniqueValue() will return the sys_id of the current open form\record

GlideForm | ServiceNow Developers

 

Can you update this post to clarify your requirement?

and why you want to update the description to be the same as the records 'number'

 

Hello @Tony Chatfield1 

I apologize, Tony, for the lack of clarity in my question. I'm still in the process of learning JavaScript, so sometimes my inquiries might not come across clearly. However, I'm eager to absorb knowledge from you and the community's feedback.

 

Thank you for sharing the article link; it's incredibly helpful. I plan to dedicate time to reading it thoroughly to enhance my understanding.

 

Moving forward, my next question is for educational purposes. For instance, if the description field contains the sys_id of an old RITM, could I utilize a catalog client script to query information such as the number, created date, and creator? I understand that this information can be filtered from the list view, but I'm keen on learning how to achieve it through client scripting.

 

For example: 

 

Keang_0-1711061747699.png

 

Hi, normally if you want to look up data for a related record from client side best practice would be to use GlideAjax.

GlideAjax | ServiceNow Developers

It is possible to use GlideRecord from client side, just not recommended as it may cause performance issues.

GlideRecord | ServiceNow Developers

 

The core question is context and how\why the record sys_id is in the forms description field?

Also, normally a RITM record would be created at same time as the sc_request record, normally as part of the request creation process and so would share the creator\creation time and it's number would be visible to a fulfiller via related records list on sc_request form.

 

Hi @Tony Chatfield1 

The system has undergone numerous shifts in support analysts due to retirements, departures, and various other factors. This has contributed to the data being less than pristine.

 

As a newcomer to the company, I've been tasked with the responsibility of cleaning up this data. However, my understanding of the system is still limited. I heavily depend on the supportive ServiceNow community to guide me through challenges and enhance my knowledge.

 

While there may be instances where my questions are unclear or lack coherence, I am dedicated to learning from the valuable feedback provided by the community, much like the education you have graciously offered me.  Thank you