ChrisLoe Posted December 7, 2017 Share Posted December 7, 2017 Hi, I´m looking for a solution, that a source can create different entities (Part A, B and C) in a certain order (and then repeat it, not based on random). For Example: 1st Arrival Part A, 2nd Arrival Part B, 3rd Arrival Part C, 4th Arrival Part A (and so on). Is there an opportunity to realise this? I tried to use a data table, but probably I missed a necessary step. Thank you for helping. Chris Link to comment Share on other sites More sharing options...
CWatson Posted December 7, 2017 Share Posted December 7, 2017 First, in a table, list the part types, in order, that you would like, i.e., PartA, PartB, PartC, then PartD in a column. In the Definitions window, add a new integer state (named 'Index' for example) with default value of 1. This can be used to loop through the table rows (and reset to 1 once you create the last one). Then, within the Source, use the TableName.ColumnName' as the Entity Type. Within the Table Row Referencing / Before Creating Entities, set the Table Name and then use the 'Index' integer state as the Row Number. In the state assignments before exiting, simply increase the integer state value - you can use simply a Math.If(Index == 4, 1, Index+1) - or you can use the max rows in the table if you aren't sure how many items in table. Link to comment Share on other sites More sharing options...
ChrisLoe Posted December 8, 2017 Author Share Posted December 8, 2017 Hi Christine, thank you for your quick reply. The 4th step (state assignments before existing) didn’t work. Maybe I did something wrong. Instead, I used an additional process (in source – add-on process triggers / creating entities). For completeness, in attachment: my model with process trigger. Model with process trigger.spfx Link to comment Share on other sites More sharing options...
jzhou Posted December 9, 2017 Share Posted December 9, 2017 yeah , it is not so good to increment that Before Exit State Assignment, becuase each entity you created would trigger that. If you increment that by Math.If(Index == PartDefinition.AvailableRowCount, 1, Index + 1), then the quantitis you defined will trigger many times of calculation. so say if the first entity is red entity, the quantities are 3, then after the 3rd one coming out of source, the index turns 3. Link to comment Share on other sites More sharing options...
Recommended Posts