The CreatorCon Call for Content is officially open! Get started here.

Business Rule to change Due Date

Gemma Jacobs
Mega Guru

Hello Everyone,

We have a current requirement for Due Date on Tasks be set to match a field called Target Date on the Request Item. I've tried different options for Business Rules but none have worked for me so far. Is there anyone who has a proper script for this or knows the best way to achieve this?

Thanks in advance

Gemma

18 REPLIES 18

I tried several variations from the following community help, but didn't get very far and just overwhelmed. ðŸ˜”

https://www.servicenow.com/community/developer-forum/due-date-on-request-item-and-task/m-p/1618259/p...

Any ideas would be appreciated, I'm not very good at scripting 

ronprice
Giga Guru

You potentially need 2 business rules for this.  One on the sc_task table to run on create and pull down the date from the RITM.  Something like this:

Screenshot 2023-04-05 174322.jpg

 

And then one on the RITM to run on Update to propagate changes to the Target Date to all associated tasks, like this:

Screenshot 2023-04-05 174419.jpg

 

Please mark as correct/helpful if this helps solve your problem.

Gemma Jacobs
Mega Guru

Thanks so much for all the feedback! I added the 2 business rules. Attached are the conditions and scripts. Unfortunately, the task due date is still not matching task target date. any other ideas to try?

I will be ooo tomorrow but will follow up on Friday. 

br propogate 4.pngbr 3 ritm script.pngbr 2 condition.pngTask1.png

ronprice
Giga Guru

On the first business rule, for RITM, it needs to look for a change in Target Date, not Due Date.  Sorry if my screenshot was a little confusing - I didn't add Target Date to my record and instead used an existing field - Expected Start.  I then edited the script before posting to put in Target Date to match your example, but missed changing the first line that checks for a change.  That said, the comparison obviously doesn't need to be done in script.  It can be done via the Condition as you attempted - again, you were just looking at the wrong field.

 

With regards to the business rule on the catalog task table, it doesn't need to look for a field change at all.  It should just set the value on Insert.  That takes care of the initial value and the BR on the RITM handles any changes that might happen.

Gemma4
Mega Sage

Thank you all so much for the help! I used the br you suggested and attached is a screenshot of how I configured when to run, actions and the script. I also had to create a new field Due date.  So far the due date is matching target date...Good news!

However now I noticed the request item list is not populating due date..

Do you think I just need another business rule for it? Something like :

current.u_due_date = current.sc_req_item.u_target_date;

current.update();DevReqItemViewMissingDueDate.png