How to update form field value based on the related list record field value by using Business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2022 01:38 AM
Hi Community,
I have a requirement to update skill field on the case form when ever the Task skills related list is updated with a skill
I have written before insert Business rule but it's not working
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord("sn_customerservice_case");
gr.addQuery('sys_id',current.skill);
gr.query();
while(gr.next())
{
gr.skills = current.skill;
gr.update();
}
})(current, previous);
Can any one have any better idea ?
Thanks,
Harikrishna
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2022 11:37 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2022 11:56 PM
Okay. Just need to update Line number 7 of your code as below:
gr.skills = gr.skills + ',' + current.skill;
Rest all looks okay . Please try this and let me know for further issues.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2022 12:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2022 12:43 AM
Hi,
Are you referring to the correct field when you are trying to do an addQuerym in your script above.
Please make sure you refer the correct field (i.e. field present on child Table which is referring to parent Table)in line below
I see you have used Skills in your addQuery and then again in line number 7. Are both the fields same in your case?
This is my script which is working when I am updating watch list from Incident task to Incident:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('incident'); // Replace your Parent table Name here
gr.addQuery('sys_id',current.incident); // Replace Incident with the Field which is connecting both tables
gr.query();
if(gr.next()){
gr.watch_list = gr.watch_list + ',' + current.watch_list;
gr.update();
}
})(current, previous);
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2022 12:44 AM
Say For example, Below is my Incident task form screenshot where I have Incident field which is parent in my case so I have used Incident in Add Query so you need to check for your corresponding field in addQuery. Rest all code looks good to me:
Regards,
Shloke
Regards,
Shloke