[Vtigercrm-developers] Lookup table in Workflow?

Martin Allen martin.allen at exe-squared.co.uk
Mon Aug 8 07:31:14 GMT 2022


I’d do as either a custom workflow function (if there are variable conditions to trigger it, that may need to change at a later date ) or an vtiger.entity.aftersave event handler – then would have an array mapping the country values e.g.

$mapping = array(
   'US'=>'United States',
   'UK'=>'United Kingdom'
);

function getCountryMapping($country){
   return $mapping[$country] ?? $country;
}

Then simply populate the array with your expected country mappings. To add a new one later, all you do is add a new entry in your array. We’ve done something similar before were we weren’t able to be given an exact list of possible values that an external API would send us, so in this case we extended the getCountryMapping function to record and notify Admins whenever a new value was seen, so they could work out the correct mapping and update the array and add the correct mapping.


From: vtigercrm-developers-bounces at lists.vtigercrm.com <vtigercrm-developers-bounces at lists.vtigercrm.com> On Behalf Of socialboostdk
Sent: 04 August 2022 21:57
To: vtigercrm-developers at lists.vtigercrm.com
Subject: [Vtigercrm-developers] Lookup table in Workflow?

Hi everyone,

Hope you're enjoying some summer days ;)

I have a lot (approx 300) of variables that need to be changed (like "US" to "United States", and many others) in a text field across many records as they get added from an external source.

Any ideas on how to do this in a smart way?

I can't change it in the source unfortunately.

The only idea I've come up with so far is to make a.. massive.. if-else structure in a workflow, which of course sounds terrible :-)

Thank you in advance for any pointers :)

Cheers,
Chris

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20220808/a08b34a1/attachment.html>


More information about the vtigercrm-developers mailing list