Skip to main content
Nintex Community Menu Bar

Hi.

I'm creating a workflow in K2 to create a Purchase Request. the last step in the workflow will actually call a REST Web Api by posting one JSON parameter that contains all values, inlcuding the header and the list of details of the Purchase Request.

To simplify it:

the Json has three parameters: ID, Date, Items[].

and each Item has two parameters: Id, Quantity

 

I have a Form that contains:

  1. a Header View that includes the ID, the Date....
  2. a list view that includes the Items required, each item contains the ID, the quantity...
  3. a Create Button

The Create button is supposed to call the web service and post the serialized values of the header and the list of items as well. the only thing I need is how to serialize the whole list of items?

 

what I did is some rules on the button click:

  1. on the list: Serialize the list Item to Array by doing the requierd mapping
  2. on the list: Save the output mapping to a data label 1
  3. on the header: Serialize the header by doing the required mapping and mapping the data label 1 to Itemse]
  4. on the header: Save the output mapping to data label 2
  5. call the Smart object Method by supplying the data label 2

the problem here is the first step: Serialize Item to Array is serializing only the selected line in the list and not the whole list!!!

 

any suggestions?

You are on the right track, although I think you could do this without the extra data labels.  To get all of the items in the list, you will want to wait until they click save.  In the rule conditions you will find a for-each statement near the bottom.  So you could structure your logic to iterate over the list.  For each item that was added, seriarlize item to the array.

 

David


Reply