Updating a date field in Flow Designer

matthew_hughes
Kilo Sage

I'm trying to update the 'Next AMA Due Date' field in my flow designer based on the following requirements:

  • If Enhanced = Date Scoping Completed + 1 Year
  • If Moderate = Date Scoping Completed + 2 Year
  • If Basic = Date Scoping Completed + 3 Year

 

I'm trying to implement the requirements with the following code:

 

matthew_hughes_0-1710405804364.png

 

However, what I'm finding is that it doesn't update the 'Next AMA Due Date' field with the required date. I ran some logs for the 'scopingCompleteDate' and 'amaRating', but nothing is returning to the logs. I was just wondering if somebody has come across this before and what I can do to resolve it.

1 ACCEPTED SOLUTION

Hi @matthew_hughes ,

 

If 2nd step is where you are getting the value and it is a look up record, then you should use 

fd_data._2__look_up_record_current.<field name>
 
Regards,
Deborah Brown
 
Mark the article as helpful and bookmark if you found it useful.

View solution in original post

25 REPLIES 25

Hi @Arun_Manoj  Would I still need to use getValue or get DisplayValue?

Hi @matthew_hughes , please use getDisplayValue() 

 

Hi @Arun_Manoj  I've tried the following and it doesn't work:

 

var scopingCompleteDate = current.getDisplayValue('u_last_scoping_ama_completed_date');
gs.log('MH: The value of the scopingCompleteDate is: ' + scopingCompleteDate);
 
var startDate = new GlideDateTime(scopingCompleteDate);
 
var amaRating = current.getDisplayValue('u_access_management_controls');
gs.log('MH: The value of the amaRating is: ' + amaRating);
 
 
if (amaRating == 'basic') {
return startDate.addYearsLocalTime(3);
}
else if (amaRating == 'moderate') {
return startDate.addYearsLocalTime(2); 
}
 
else {
return startDate.addYearsLocalTime(1);
}

Arun_Manoj
Mega Sage

Hi @matthew_hughes ,

 

var scopingCompleteDate = current.getDisplayValue('u_last_scoping_ama_completed_date');
gs.log('MH: The value of the scopingCompleteDate is: ' + scopingCompleteDate);
 
var startDate = new GlideDateTime(ScopingCompleteDate);
 
var amaRating = current.getDisplayValue('u_access_management_controls');
gs.log('MH: The value of the amaRating is: ' + amaRating);
 
 
if (amaRating == 'basic') {
return startDate.addYearsLocalTime(3).getDisplayValue();
}
else if (amaRating == 'moderate') {
return startDate.addYearsLocalTime(2).getDisplayValue() ; 
}
 
else {
return startDate.addYearsLocalTime(1).getDisplayValue();
}
 

Harish KM
Kilo Patron
Kilo Patron

Hi @matthew_hughes your no where calling the new GlideDateTime() method hence the addDaysLocalTime is invalid.

you need to call glidedatetime API to invoke date methods

after line 9 add the below code

var gdt = new GlideDateTime(scopingCompleteDate);

and in line 17,20,24

add this

gdt.addDaysLocalTime(365);

gdt.addDaysLocalTime(730);

gdt.addDaysLocalTime(1095);

Regards
Harish