Set Follow Up date from a date variable plus 5 days on RITM

Bidduam
Tera Guru

I have a variable called u_return_date, what I want to do is when someone submits their catalog item, the follow up field on the RITM is populated by getting the u_return_date value and adding 5 days to it.

eg: u_return_date is 01/07/2024 then make follow_up - 06/07/2024

 

What I have currently is a business rule on the sc_req_item table and is a before insert with the following script:

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
	var ReturnDate = g_form.getValue('current.u_return_date');
    ReturnDate.addDays(5);
    current.follow_up = ReturnDate;

})(current, previous);

 

 

2 ACCEPTED SOLUTIONS

Hi @Bidduam ,

 

You have used g_form which is client side API. Business rule is server side so it won't work.

 

Use the below it will work, I have tested in PDI.

 

 

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
    var ReturnDate = new GlideDateTime(current.variables.u_return_date);
    ReturnDate.addDays(5);
    current.follow_up = ReturnDate;

})(current, previous);

 

 

Output:

SN_Learn_0-1719386488617.png

 

SN_Learn_1-1719386551101.png

 

 

 

 

Mark this as Helpful / Accept the Solution if this helps

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

View solution in original post

I have tested it again:

 

SN_Learn_0-1719388198825.png

 RITM OOB field:

SN_Learn_1-1719388239741.png

 

 

 

Business Rule:

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
    var ReturnDate = new GlideDateTime(current.variables.u_return_date);
    ReturnDate.addDays(5);
    current.follow_up = ReturnDate;

})(current, previous);

 

 

 

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

View solution in original post

8 REPLIES 8

Hi @Bidduam ,

The 'Date start' field is variable of catalog item and follow up date is custom field I have created on RITM which is of date type field.

 

Could you please share the screenshot of your fields?

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

I have tested it again:

 

SN_Learn_0-1719388198825.png

 RITM OOB field:

SN_Learn_1-1719388239741.png

 

 

 

Business Rule:

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
    var ReturnDate = new GlideDateTime(current.variables.u_return_date);
    ReturnDate.addDays(5);
    current.follow_up = ReturnDate;

})(current, previous);

 

 

 

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

@SN_Learn I don't know what happened the first time, but I went back and copied and pasted what you gave me again and this time it worked exactly as wanted.

 

I'm sorry to stuff you around and really appreciate the help - thank you very much

Glad that it helped.

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.