I'm trying to write a flow that automatically updates a multi-select picklist field on Contacts in response to the Opportunity's Stage being changed. I'm running into issues with the multi-select picklists. The field will have several options (let's say, "A", "B", "C", and "D") and in response to the Opportunity stage change, I need to sometimes insert one of those or sometimes remove one of those. Flow doesn't do this natively and using nested functions is a huge pain so I'm writing an Invocable Apex method. This is my first time writing Invocable methods and I'm running into issues passing variables into the method.
The Invocable method is called for every Contact associated with the Opportunity's Account. I want to use Apex to examine the picklist and modify accordingly. Questions:
- Invocable methods only accept one variable. I can use Invocable variables to split them up, but then I would have to package a) the text version of the MSP and b) the tag I would like to add as a Flow Collection, and that just feels messy. Is this the best option?
- OR is it possible to use the Interview class to access the current Contact in the loop from the Invocable method? Then I could pass just the wanted tag to the Invocable method, access the Contact via the Interview class, and modify as needed.
- I'm open to ANY other options as I really need to get this finished.