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

**URL:** <https://community.exalate.com/t/how-can-we-trigger-sync-after-initial-sync-only-if-a-certain-condition-is-met/4062>\
**Category:** General Questions\
**Tags:** onpremise-jira, migrated\_question\
**Created:** [November 4, 2024, 6:25am UTC](https://community.exalate.com/t/how-can-we-trigger-sync-after-initial-sync-only-if-a-certain-condition-is-met/4062 "2024-11-04T06:25:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![xl8bot](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/xl8bot/32/324_2.png) [@xl8bot](https://community.exalate.com/u/xl8bot)\
**Post date:** [November 4, 2024, 6:25am UTC](https://community.exalate.com/t/how-can-we-trigger-sync-after-initial-sync-only-if-a-certain-condition-is-met/4062/1 "2024-11-04T06:25:55Z")

</div>

_Originally asked by Samip K Banker on 07 September 2019 [(original question)](https://oldcommunity.exalate.com/questions/3702799)_

* * *

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?

* * *

---

<div class="post-metadata">

**Author:** ![xl8bot](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/xl8bot/32/324_2.png) [@xl8bot](https://community.exalate.com/u/xl8bot)\
**Post date:** [November 4, 2024, 6:25am UTC](https://community.exalate.com/t/how-can-we-trigger-sync-after-initial-sync-only-if-a-certain-condition-is-met/4062/2 "2024-11-04T06:25:56Z")

</div>

_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:

```auto
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…
> 
> ```auto
> 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.
> 
> - If in doubt what the value is, check the ‘remote issues tab’ on the issue under sync
> - If still in doubt, add a throw statement in the else section of the code  
> Check following snippet for the throw details  
> [https://stash.idalko.com/snippets/21ad469b5a2e4ff0a42d628c79245758](https://stash.idalko.com/snippets/21ad469b5a2e4ff0a42d628c79245758)
