Many-to-Many relationships in Workflows

  • 9 March 2016
  • 1 reply
  • 3 views

Badge +2

Hi,

 

I have been trying to create a workflow for a form which contains an item view for the body of a form and an editable list for users to be added to it. The intention is for the item view to be filled out for the form request, then users to be included in that request can be added in the editable list below. Once the create button on form level is clicked both the form item and the users attached to it should be passed along as an instance of the workflow

 

I want the form to be viewed in the manager state exactly as it was submitted, however the form SmartObject and the user SmartObject can not be both used as item references, so only the values from one view are passed through properly. I've played with the rules a bit and have been able to display all instances of the user smartobject, however I have not been able to filter the results to the users which apply to that form.

 

I have created a many-to-many relationship between the two SmartObjects linking the two ID fields

 

Any suggestions on how to move forward?


1 reply

Badge +10

I did a similar form, but the requirements change a little.

 

For each Item in the List, there will be different approvers or no approvers depending on the Resource that is added to the List.

 

For that reason needed to call a Loop.

http://community.k2.com/t5/K2-blackpearl/Is-it-possible-to-compare-two-SMOs-Loop-trough-all-items-and/m-p/87694#M27254

 

So here is what I suggest:

 

Table A

ID

Field1

Field2...

FieldN

 

Table B

ID

TableAID

Field1

Field2..

FieldN

 

Now that we have Two tables:

Table A will have the main Information or header of the Data

Table B will have the elements of the List individually linked back to Table A via TableAID

 

When you click submit the following things happen:

A) Execute Create Method for the TableA Item View.

B) Execute a For/Each loop on table B. then each time pass trough the Item execute the Create Method of that particular record.

 

Once Both Rules Have completed you should have the Table A populated with data and many items in TableB with the contents of the list.

 

From here you can execute the Start a workflow on Table A.

[Add some parameters to TableB List View for ParamTableAID (int) make it default 0. then on initialize filter the List on TableID=ParamTableID]

 

Pass as a parameter to your workflow the paramTableAID to be used when opening the form.

 

With all this in place the next time the form is open for approval will render the TableA data, the initialization of TableB will detect the tableAID and will render correctly.

 

Hope this helps.

 

Dino.

 

 

Reply