Create Object of association using microflow

0
Hi, I was wondering how I can create an object of association. Let say I have Entity1 and Entity2 having a 1-* association , there is one attribute in Entity1 which user selects as multi check and it has a value like attribute1_of_Entity1 = stage1,stage2,stage3,stage4 Now I have an attribute as stageName in Entity2 which should create all the objects coming from attribute1_of_Entity1. I have created a microflow which gets called at a click of button with input parameter as Entity1and I am splitting string attribute1_of_Entity1 in list and then looping though the list I am creating the object of Entity2 and setting it to current item of list. My problem is it is not creating the objects in association with my Entity1. Can anyone help me?
asked
1 answers
1

hi, himanshi!

 

two main questions:

1) is your object of Entity1 being committed?

2) are you setting the association on the Entity2 objects to Entity1?

 

then (i don't have the full context, but maybe this is helpful), here is an add-on to look into the longevity of your code, maybe consider an entity to store your multi-select options:

 

1) if this entity is called MultiSelectOption, you can store an attribute with OptionName

2) create and commit the options (in your case, 'stage 1', 'stage 2', etc.) as MultiSelectOption objects ('stage 1' being stored under OptionName)

3) create a one-to-many association from Entity1 to MultiSelectOption

4) present it to the user using the nifty Simple Checkbox Set Selector

5) loop through the associated objects and map it to your Entity2. depending on your requirements, you might not need Entity2 at all, and you can just commit the associations between Entity1 and MultiSelectOption, then retrieve the selection through filtering by Entity1 as the associated object

 

this way, you can reuse options, avoid the concatenated string being out of date, and you have more flexibility to add, change or remove options!

 

hope this helps

answered