Populate Related case number on work order form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 12:43 AM
We have requirement where Related case details should be populated on the work form.
The current setup is work order is created from an incident and incident is created from case. So the parent of work order is incident and the parent for incident is case.
we have a custom Related case field on work order form where the case number should be populated.
Any Suggestions on how to implement this ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 01:18 AM - edited 12-27-2023 02:28 AM
Hi @Ramya95 ,
You can write an BR after insert on work order table where u can try the below code. Please use proper backend values in the code.
var gr = new GlideRecord('incident');//Please enter proper table name here
gr.addQuery('sys_id',current.parent);
gr.query();
if(gr.next()){
current.u_case = gr.parent;
current.setWorkflow(false);
current.update();
current.setWorkflow(true);
}
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 02:27 AM
Hello @Ramya95
You need to create after incident Business rule for work order table and add below code.
var workOrder = new GlideRecord('work_order') // Add work order table backend name
workOrder.addQuery('sys_id',current.getUniqueValue());
workOrder.query();
if(workOrder.next()){
var incident = new GlideRecord('incident')// Add proper table name
incident.addQuery('sys_id',current.parent);
incident.query();
if(incident.next()){
workOrder.u_case = incident.parent;
workOrder.setWorkflow(false);
workOrder.update();
}
}
Please Mark my Solution as Accept ✅ and Give me a thumbs up 👍, if you find it Helpful.
Regards,
Vaishnavi Shinde