Tip #1104: If without if

(The chart fortnight by Ulrik “CRM Chart Guy” Carlsson is over but I’m sure he’ll be back! – t.j.)

Sometimes we need to set the value for a field but only if it does not exist, e.g. user did not bother entering it. Like topic for a lead. I’ve seen the implementations where business asked to make it optional and set default to the lead name.

The first instinct is to do something conditional like:

if lead topic does not have value then
   update lead with a made up topic

Update lead conditional
Stacked approach works quite well in this scenario as “if without if”, i.e. update topic to itself otherwise use made up default:
Update lead implicit
The update is now can be bundled with some other manipulations, saving an extra update call but one thing to be aware of that it is unconditional and will trigger both workflows and plugins if any are registered on update of the field (topic in our sample).

Leave a Reply

Your email address will not be published. Required fields are marked *