Highlighted
Super Contributor.. Super Contributor..
Super Contributor..
600 views

SM 9.4 - RAD - how to set a date based upon current date and a second field?

Jump to solution

I am trying to set a date field to a date in the future based upon the current date and the number in a field. 

field: audit.days (this field would be either 30, 60, 90 or 120)

field: next.date  (I want this field to be the current data plus how many days is specified in the audit.days field)

I know how to set the date in RAD using a static value such as tod()+60*24*30 (this works for 30 days), but I want to be able to switch out the 30 with the audit.days field, like tod()+60*24*audit.days and I cant get it to work - is there a way to do this in RAD or is there a way to do this in Javascript? I am using a button for this action.

0 Likes
1 Solution

Accepted Solutions
Highlighted
Honored Contributor.. Honored Contributor..
Honored Contributor..

Re: SM 9.4 - RAD - how to set a date based upon current date and a second field?

Jump to solution

try this one

next.date in $L.file=tod()+(60*24*audit.days in in $L.file)

View solution in original post

6 Replies
Highlighted
Outstanding Contributor.. Outstanding Contributor..
Outstanding Contributor..

Re: SM 9.4 - RAD - how to set a date based upon current date and a second field?

Jump to solution

Try something like this to calculate the new date

var currentDate = new Date().getTime();
var auditDays = 30;

var newDate = new Date(currentDate + (auditDays * 24 * 60 *60 * 1000) );

 

Highlighted
Honored Contributor.. Honored Contributor..
Honored Contributor..

Re: SM 9.4 - RAD - how to set a date based upon current date and a second field?

Jump to solution

try this one

next.date in $L.file=tod()+(60*24*audit.days in in $L.file)

View solution in original post

Highlighted
Outstanding Contributor.. Outstanding Contributor..
Outstanding Contributor..

Re: SM 9.4 - RAD - how to set a date based upon current date and a second field?

Jump to solution

You have an "in" too much

 

next.date in $L.file=tod()+(60*24*audit.days in $L.file)
Highlighted
Super Contributor.. Super Contributor..
Super Contributor..

Re: SM 9.4 - RAD - how to set a date based upon current date and a second field?

Jump to solution

I tried the following code in the PRE RAD tab and get "field contains an invalid expression (display,show.rio)

next.date in $L.file=tod()+(60*24*audit.days in $L.file)

 

 

I tried this as well and it doesnt error out but I cant figure out how to set my field to the newDate value ( i 

var currentDate = new Date().getTime();
var auditDays = 30;
var newDate = new Date(currentDate + (auditDays * 24 * 60 *60 * 1000) );

 I tried next.date = NewDate; in RAD and Javascript and it gives me an invalid expression error

0 Likes
Highlighted
Super Contributor.. Super Contributor..
Super Contributor..

Re: SM 9.4 - RAD - how to set a date based upon current date and a second field?

Jump to solution

ok, i got it to work, i had to make the audit.days field a val (using Pre Rad Expression tab)

$auditvalue=val(audit.days in $L.file)
next.date in $L.file=tod()+60*24*$auditvalue

 

0 Likes
Highlighted
Outstanding Contributor.. Outstanding Contributor..
Outstanding Contributor..

Re: SM 9.4 - RAD - how to set a date based upon current date and a second field?

Jump to solution

To set a field from javascript: you pass the file handle as parameter to the function, for example as table

 

function setDate(table)

{

     table["next.date] = newDate

}

if you put this directly in the javascript field of the display option then set the field like this

 

vars["$L.filed"]["next.date] = newDate

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.