trigger a record in the related list when the form record is created
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 10:58 AM
HI community,
I got struck at a small issue, The ask is as shown in the below screen shot when the below form is created (wm_order)
Once the record is created as shown in below, It has to trigger a record on the work task table populating some data. But I am not able to achieve that. I wrote after business rule mapping the location field but the record is not getting created but when we are creating the work task record manually the location field is population with the data which is given in the parent form.
After BR script:
/*var gr = new GlideRecord('wm_task');
gr.initialize();
gr.location=current.location;
gr.short_description='Duplicate of work order';
gr.insert();
Kindly help me in achieving this.
TIA
#FSM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 11:13 AM
Hi @Madhan27 ,
The script looks good . not sure why it is not updating . can you try using flow designer it is much more easier and just need to do drag and drop .
If my reply helped with your issue please mark helpful 👍 and correct ✔️ if your issue is resolved.
By doing so you help other community members find resolved questions which may relate to an issue they're having
Thanks,
Astik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 11:15 AM
Hi Madhan,
Assuming that the /* in your first line of code isn't in the script I think you need to look at ACLs, data policies and any BRs on wm_task. The code that you show looks to be fine.
One thing that ServiceNow is pushing is to do the assignments via setValue() and not by direct assignment
gr.setValue("location", current.location);
:{)
Helpful and Correct tags are appreciated and help others to find information faster
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 01:10 PM
Besides what johnfeist found (remove the '/*' as the code is commented out). Add 'gr.parent = current.sys_id;' before the insert() so the wm_task is "linked" to the wm_order record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2024 11:27 AM
Hi Madhan Good day!!
Add parent reference in your script and try, it will work.
Ex: current.parent = gr.sys_id;
Best Regards
Shanmuk
Please mark my response helpful, if this resolves your issue!!