Problems with ^replace used twice in trigger


(Nigel) #1

Wondering if anyone can help with a little glitch we are trying to resolve.

We have a SugarCRM system connected to our Squiz Matrix instance via SugarBridge and there is contact/user info that resides in both.

We have triggers that keep the two systems in sync but there is one field in Matrix existing as Yes/No radio buttons that resides in Sugar as a 0 or 1 tickbox (1 = ticked box otherwise it’s 0).

So if I want to sync the field in question (let’s call it xyzfield), there is a trigger that pushes from Sugar to Matrix as follows: %globals_session_xyzfield^replace:1:Yes^replace:0:No%

But the above code is not quite working. It half works, ie if the Sugar contact is 1 then it pushes Yes to Matrix successfully, but if it’s 0 in Sugar, then when the trigger fires, it clears the field entirely in Matrix leaving it blank.

Assuming I have explained myself well enough, can anyone suggest how best to make this trigger work for both 1 and 0?


(Marcus Fong) #2

If the value is always either 1 or 0, could you just use the eq keyword instead? Something like:

%globals_session_xyzfield^eq:1:Yes:No%

(source: https://matrix.squiz.net/manuals/keyword-replacements/chapters/keyword-modifiers)


(Nigel) #3

Yes that seems to have fixed it Marcus. Thanks so much :slight_smile: