How to access and use TrackVia's API or Application Scripts?

Date Calculations in Apps Scripts

This is probably a very simple solution, but I've been banging my head on this for two days.

I need to populate a date field in a child table with a date stored in a parent record minus 14 at the time the child record is created via Apps Script. Not all child records link to the same parent table, and the child date field needs to be editable, so a calculated date field in the child table is not an option.

I have attempted a calculated datesub in the parent to subtract 14 from the source field, then use the calculated field in the script. The script saves with no errors, but the value of the calculated field is not populating on the child record. I have tested by referencing the source date field (not calculated) and it populates with no issues.

It looks like calculated fields cannot be used in Apps Scripts, so looking for an example that will handle the calculation directly within the script itself.

Parent Date = source (standard date field)
Due Date = source - 14 (I tried a datesub calc date, but not populating in the child)

Child Date = Parent Due Date value (standard date field populated with value from parent Due Date field)

Here is my script that is not working:

{
addChild ("Tasks", "PPR Task",

[
'Due Date': currentValues["Due Date calc"],
])
}

Thanks - I checked the KB but there is no reference to dates, and the Groovy site is too confusing.

1 vote
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    John McGarvey shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    2 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...

      Feedback and Knowledge Base