- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2017 04:55 AM
Hi all,
I have a requirement where the requested delivery date (due_date) should depend upon on a variable (end_dte)date value.
I have created a business rule on the catalog item and it is working, now I want the requested delivery date on the request to populate based on the same variable end_dte.
The business rule I have created is as follows:
(function executeRule(current, previous /*null when async*/) {
var gdt = current.variables.end_dte;
current.due_date.setValue(gdt);
var gr=new GlideRecord('sc_request');
gr.addQuery('sys_id',current.request);
gr.query();
if(gr.next())
{
gr.due_date=current.variables.end_dte;
gr.update();
}
})(current, previous);
Thanks.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2017 09:04 AM
Your code look fine to me. I have tested this on my end, it works for me. Make sure your business rule is a before insert one
(function executeRule(current, previous /*null when async*/) {
var gdt = current.variables.end_dte;
current.due_date.setValue(gdt);
var gr=new GlideRecord('sc_request');
gr.addQuery('sys_id',current.request);
gr.query();
if(gr.next())
{
gr.due_date=current.variables.end_dte;
gr.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2017 05:29 AM
Hi Roger,
What's your question?
Is your functionality working fine?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2017 05:55 AM
Hi Ankur,
The requirement is that the requested delivery date on 'requested item' and 'request' should be the same as the date selected on the form variable end_dte.
I have created a BR on requested item table, the RITM is populating the requested date value correctly but on the request it is not populating the value.
Thanks
Roger

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2017 09:04 AM
Your code look fine to me. I have tested this on my end, it works for me. Make sure your business rule is a before insert one
(function executeRule(current, previous /*null when async*/) {
var gdt = current.variables.end_dte;
current.due_date.setValue(gdt);
var gr=new GlideRecord('sc_request');
gr.addQuery('sys_id',current.request);
gr.query();
if(gr.next())
{
gr.due_date=current.variables.end_dte;
gr.update();
}
})(current, previous);