Saving a one a many record

Hi,

I am looking to set up this configuration in Appian and I'm not sure how to approach this. I am designing a task manager application where a single task can be assigned to multiple people. So in the interface form, it will list generic task details such as task name, description, due date, and who the task needs to be assigned to. If I assign it to Alice, Bob, and Charlie, then I want to create three tasks with each one assigned to each individual. 

<Interface form>

Create a single task to "Do Laundry" and assign to Alice, Bob, Charlie.

<Data store>

1 - Do Laundry - Alice

2 - Do Laundry - Bob

3 - Do Laundry - Charlie

This way I can see if each person has done their task. I assume I need to use a for each loop somewhere in the process model? How do I code this in the process model to create X number of tasks and write X number of records?

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    Use Multiple Node Instances (MNI) on the User Input Task, with a process variable pv!assignees (multiple users). Configure the task to run one instance for each assignee so Alice, Bob, and Charlie each get their own task, then use a Write_To_Data_Store/Write_Record (with forEach over pv!assignees) to insert one record per assignee.

  • Thanks for the explanation. I have a question on the execution. Currently, I have a RI variable from the interface which contains all the fields and another RI variable to collect the Task Assignees (multiple).

    In the <Parent> Process Model, I created two variables, pv!TASK_RI (RecordType) and pv!TaskAssignees (User or Group)(multiple). I set up the Subprocess node to pass these variables to the <Child> Process Model. The Subprocess node has (MNI) selected and will run one instance for each item in pv!TaskAssignees.

    In the <Child> Process Model, In the Write Records node, how do I combine both variables into one variable to be added to the RecordType? Under Configure Write Records, in the Setup tab, I selected the TASK_RI. But the Task assignee is not in the RI group. It's in pv!TaskAsignee. 

    Do I need to write an expression to combine the RI and pv variable together before it gets inserted into the recordtype? I hope my explanation is clear..

  • Can anyone help? How do I add data to the <Record Type> variable? It currently pulls in all the data collected on the form, except the User field. I want to add the user data to the RecordType before I pass it to the subProcess.

  • 0
    Certified Lead Developer
    in reply to jimc

    before the write record node add a script task. In the output tab of script task add a new output expression. Value can be the taskAssignee , save into should be record type variable field that can store task assignee (the user field). Basically you set the user field in this script task with the value you expect and then publish your model.

  • 0
    Certified Lead Developer
    in reply to jimc

    I suggest to only pass the record id to that sub process, and let the sub process fetch whatever data it needs. This way, you decouple their individual dependencies.

Reply Children
No Data