Writo to data store entity - Store data output in all indeces of an array

Certified Associate Developer

Hello,

I'm using 2 CDTs. One to saves Contractor information and the other one to save a list of employees of the contractor.

In my form i am using a grid layout component which lets me add a list of employees that will work overtime in a week. Once i submit the form a list of employees is stored in an array of values that will need to be recorded in my Employees table.

My question is, how can i store the output of my employees array to then write into my data store entity?

Thanks!

  Discussion posts and replies are publicly visible

Parents
  • Did you take a look at the documentation for Write to Data Store Entity? Basically you will want to add a node input in your process of type Employees. Then, add a reference to your data store entity (I typically use a constant to point to the appropriate data store entity). Then, it should insert the data correctly in the database. This node allows you to insert an array of employees as long as the node input is defined as an array. It should look something like this:

  • 0
    Certified Associate Developer
    in reply to Peter Lewis

    Hi Peter, 

    Thank you so much for your response! I got this working succesfully, the node  is indeed inserting the array of employees accordingly.

    Now i'm facing another issue which is: My employees table needs an id that comes from the contractor table. I passed this id through the output section of my first Write to data store entity to use it for my array of enmployees in the next write to data store entity assigned to my employees CDT but, the id it's being captured for only one of the employees instaces in the array.

    Do you how can i solve this? Thanks in advance for the help and support

  • +1
    Appian Employee
    in reply to Fer1986

    Nice! You will need to ensure that the ID is passed into all of the Employees and not just the first one. I usually do this by adding a script task between the Write to Data Store Entity for Contractors and Employees. You need to generate a list of Contractor IDs that matches the length of the Employee ID. In you script task, I'd create a custom output with the following expression. Then, save this into Employee.ContractorID.

    repeat(
      length(
        pv!employee
      ),
      pv!contractor.id
    )

  • 0
    Certified Associate Developer
    in reply to Peter Lewis

    Thanks again for your quick reply Peter,

    This was exactly what i needed, now i got the contractor id flowing into into all of the employees array instances.

Reply Children
No Data