How can we trigger sync (after initial sync) only if a certain condition is met?

Originally asked by Samip K Banker on 07 September 2019 (original question)


We have a “trigger” rules to start the sync that is working but once the initial sync is established… subsequent syncs will happen regardless of the condition… we only want sync (after initial sync) only to happen if certain condition is met… how can we do that?


Answer by André Leroy-Beaulieu Castro on 09 September 2019

Hi Samip,

In the incoming script of your destination side, you can have some logic right after the “if (firstSync)” block, so that it “returns” aka does nothing if a condition isn’t met, for example, if your condition was that the priority must be “1-High” you can have something like:

if (replica.priority != "1-High") {
	return;
}

And after this, you can have all your normal sync rules, so if the condition is met, it goes through your normal sync rules, but if it isn’t, it does nothing.

Let me know if this is a solution for you.

Thanks,

André


Comments:

Samip K Banker commented on 09 September 2019

André Leroy-Beaulieu Castro :

I have exact same thing but it is still not working…let me try agian…

if (replica.customKeys."Status" != "Approved")
{
	return
}
else
{
	// code to perform the sync
}



~Samip

Francis Martens (Exalate) commented on 09 September 2019
  • Make sure that the issue is empty, such that Exalate knows that nothing needs to be applied.