How to fetch latest approved case record into reference field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2024 01:33 AM - edited ‎03-13-2024 09:46 AM
Hi All,
Actually we have two case tables (plan and build), on the plan case form , we have reference field called "trigger case" which is refers to Build case table, so now in that reference field I need to set the latest approved build case record , on the build case we have field case status in that we have choices, in that we have "Approved", based on this field , i need to get that lates approved record?
I have written a after BR like below
Table Plan
After insert/Update
Please help me to achieve this
Thanks
Deepika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2024 09:47 AM
Hi All,
Please help me to resolve this
Thanks
Deepika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2024 08:03 AM
Hello @Deepika61 ,
Try this
var es = new GlideRecord('sn_customerservice_build_case'); es.addQuery('state', 6); // replace 6 with actual integer value for 'Approved' es.orderByDesc('sys_updated_on'); es.setLimit(1); es.query(); if (es.next()) { current.u_trigger_case_no = es.sys_id; // assuming u_trigger_case_no is a reference field, you need to set it to sys_id current.update(); }
I think you need to map the sys_id.
Thanks
Amarjeet Pal