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

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.

Parents Reply Children
  • 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

  • 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

     

  • 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