Number of Days to Calculate Read Only Due Date Field

Forums Classic DFFS Number of Days to Calculate Read Only Due Date Field

Viewing 1 reply thread
  • Author
    Posts
    • #35091
      Jeverly
      Participant

      Hello,

      I have three fields that I need to link together.

      – Session Start Date (Date Picker)
      – Number of Days
      – Task Due Date

      The user fills out the Session Start Date field (Parent List) and will click the Add Task button which opens the Task form (Child List). The user then chooses a task from the Task Name dropdown field (The Lookup list). Once they choose their task they need to add a number to the number of days field. -1 would be the day before the session start date, 0 would be the day of the Session Start Date and 5 would be 5 days after the Session Start Date. I need for the day entered to populate the read only Task Due Date field as it relates to the Session Start Date field. The Task Due Date field would be calculated using calendar days.

      Example 1.

      Session Start Date – 4/10/2021
      Number of Days – -10
      Task Due Date – 5/31/2021

      Example 2.

      Session Start Date – 8/17/2021
      Number of Days – 16
      Task Due Date – 9/2/2021

      Can this be done using DFFS? Any help you can provide would be greatly appreachiated :).

    • #35104
      SteveE
      Participant

      First populate the Session Start Date field in the child from the parent using vLookup settings.

      In the child Custom JS section add this code (changing the field names to match yours):

      
      
      function SetDate(){
          var StartDate = spjs.utility.getDateFieldAsDateObject("SessionStartDateFIN");
          var DayNumber =  Number(jQuery("#dffs_NumberofDaysFIN input").val());
          spjs.utility.setDateFieldFromDateObject("TaskDueDateFIN",StartDate,DayNumber);
      }

      Then in the child create a rule that triggers when the Number of Days field is changed and add SetDate in the Run these functions section.

      Your math in your examples doesn’t add up so that part was confusing, but this works for the request in your explanation.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.