Need to populate the free text value to the one of the reference field in the Incident table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2024 03:35 AM - edited 04-19-2024 03:36 AM
Hi All,
I am working on the Record producer form, My requirement is on the form level I have one field called "Please provide the ADO/Change number associated with the previous change." it is a single line text field and I wanted to updated this field value to the "Caused by Change" OOB field in the incident table and it is a reference field and referring to change_request table.
Note :
Please provide the ADO/Change number associated with the previous change backend value is ado_change
Caused by Change backend value is caused_by
I tried like this in the Record Producer script,
In the background script I tried like below,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2024 03:46 AM
Hi @vinuth v ,
As I checked your problem in my PDI I got solution please refer below script
var gr=new GlideRecord("incident");
gr.addQuery('number', 'INC0010003');
gr.query();
if(gr.next())
{
gr.caused_by='c83c5e5347c12200e0ef563dbb9a7190'; // Sys_id of change record
gr.update();
}
As caused_by is reference field so you need to give the sys_id in that case than it will work
Please mark my answer correct and helpful if this works for you
Thanks and Redards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2024 04:05 AM
Hi @Community Alums
This is working in background script, how to implement in the Record producer Script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2024 04:16 AM
Hi @vinuth v ,
Please try the below script in record producer :
var chgRec = new GlideRecord("change_request");
chgRec.addQuery('number', producer.ado_change); //Change number(also implement some validation for this field)
chgRec.query();
if(chgRec.next())
{
current.caused_by = chgRec.sys_id; //It returns the sys_id of Change record
}
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2024 04:43 AM - edited 04-19-2024 04:46 AM
Hi @vinuth v ,
Please check below script
var gr=new GlideRecord("change_request");
gr.addQuery('number', producer.ado_change);
gr.query();
if(gr.next())
{
current.caused_by=gr.sys_id; // sys_id of change record
gr.update();
}
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
Please mark my answer correct and helpful if this works fine