How can I populate the database with a single form on multiple dates field?

How can I populate the database with a single form on multiple dates field?
Let's say I am creating a Vacation form and when an employee wants to apply for leave from 1st Jan till 5th Jan, they open the form select FROM and TO date, fill other form fields such as reason of leave, informed manager etc. Now when the employee hit submit I should see 5 entries on Database with 5 dates but the rest form details should be same.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    You can form a loop on all the dates between From and To and create a casting rule to cast the data into array of CDT and then use it in WDSE service

    For eg: 

    a!localVariables(
      local!dates: a!foreach(
        items: enumerate(1 + tointeger(local!toDate - local!fromDate)),
        expression: local!fromDate + fv!item
      ),
      local!reasonOfLeave,
      local!informedmManager,
      a!forEach(
        local!dates,
        type!CDTNAME(
          date: fv!item,
          reasonOfLeave: local!reasonOfLeave,
          informedmManager: local!informedmManager
        )
      )
    )
    

  • Are you sure this will populate the DB? even I thought the same initially but I might be wrong because what I thought is after running the for each loop "reasonOfLeave" will have the last value of "local!reasonOfLeave" and the same with "informedmManager" but when it will move towards process model to write on data store entity it will only write the last value.

Reply Children