Logic branches are difficult
This might be a case of missing documentation, or it might be a discussion of an improvement, or it might be a support request - if there's a way to do this and I've just not understood!
I have a FP that asks people for their University. It's an optional field, if provided it is the contact ID of a uni. What I want to do is fairly simple:
- if a uni is given:
- look up an existing relationship to that uni.
- if the relationship does not exist, add one.
Currently this is implemented as:
-
Input: Add a non-required input called
zero
with a default value of0
-
Action:
find_existing_link_to_given_uni
, condition: uni contact id is not empty. Looks up the relationship. -
Action: set
uni_given
with a value of 1, condition: uni contact id is not empty. Map output to input.zero. i.e.uni_given
will be0
unless a uni was provided in which case it will be1
-
Action : set
need_to_add_uni
touni_given
condition:find_existing_link_to_given_uni
is empty. Map output toinput.zero
. This will be1
if a uni was given AND if there's no existing relationship; for all other cases it will be0
-
Action: Create Relationship, condition:
need_to_add_uni
is not empty.
This works, but it was hard to reason about in creation and is hard to review. It took a lot of time to test, too.
Can this be done in a simpler way? If so, perhaps we need more examples (like a "cookbook") in the documentation.
Otherwise, any thoughts on what might be needed to make this sort of logic easier/clearer? e.g. perhaps a "go to" action that could jump processing to a different part of the list?
Thanks.