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
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.
mkhaiserullaPersonal said: will have the last value of "local!reasonOfLeave" and the same with "informedmManager"
What do you mean by this? These two local vars will have only single value, as you mentioned user fills the information only once, and we are using the same value to populate in CDT, just changing dates using fv!item.
It will write all of the entries if you configure it properly which includes setting the node input to take multiple CDT type values.
O yes sorry, then "date" will have the final fv!item
Okay, I did it using the process model itself, just another way of doing I think. Thank you for your response:
yea another but complex