# Multiple preconditions help

**URL:** <https://forum.genieacs.com/t/multiple-preconditions-help/2957>\
**Category:** Uncategorized\
**Created:** [September 16, 2022, 8:14pm UTC](https://forum.genieacs.com/t/multiple-preconditions-help/2957 "2022-09-16T20:14:57Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![dustin](https://avatars.discourse-cdn.com/v4/letter/d/5daacb/32.png) [@dustin](https://forum.genieacs.com/u/dustin)\
**Post date:** [September 16, 2022, 8:14pm UTC](https://forum.genieacs.com/t/multiple-preconditions-help/2957/1 "2022-09-16T20:14:57Z")

</div>

Hi Guys,

I am using 1.2.9 and would like to create a preset with more than one precondition.  
For example:  
DeviceID.OUI \<\> “first OUI”, “second OUI”, 'third OUI"

I have already tried:  
DeviceID.OUI \<\> (“first OUI”, “second OUI”, “third OUI”)  
DeviceID.OUI \<\> “first OUI” OR “second OUI” OR “third OUI”  
DeviceID.OUI \<\>“first OUI” OR DeviceID.OUI \<\> “second OUI” OR DeviceID.OUI \<\> “third OUI”

So far I have not been able to make it work.Any suggestions?

DR

---

<div class="post-metadata">

**Author:** ![UNKpl](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/unkpl/32/977_2.png) [@UNKpl](https://forum.genieacs.com/u/UNKpl)\
**Post date:** [September 19, 2022, 6:41am UTC](https://forum.genieacs.com/t/multiple-preconditions-help/2957/2 "2022-09-19T06:41:43Z")

</div>

Hi,  
condition in this field are set like SQL WHERE clause. I think You should use IN (…)

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [September 19, 2022, 5:47pm UTC](https://forum.genieacs.com/t/multiple-preconditions-help/2957/3 "2022-09-19T17:47:08Z")

</div>

Putting it together with what @UNKpl said above, this should do what you want:

```auto
DeviceID.OUI Not In(“first OUI”, “second OUI”, “third OUI”)

```

---

<div class="post-metadata">

**Author:** ![dustin](https://avatars.discourse-cdn.com/v4/letter/d/5daacb/32.png) [@dustin](https://forum.genieacs.com/u/dustin)\
**Post date:** [September 19, 2022, 6:17pm UTC](https://forum.genieacs.com/t/multiple-preconditions-help/2957/4 "2022-09-19T18:17:12Z")

</div>

> [@akcoder](#):
>
> `(“first OUI”, “second OUI”, “third OUI”)`

I tried both options (and other variations) above but the error is the same:  
“Precondition must be valid expression”

DR

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [September 19, 2022, 6:18pm UTC](https://forum.genieacs.com/t/multiple-preconditions-help/2957/5 "2022-09-19T18:18:11Z")

</div>

Check the quotes. Discourse replaces regular quotes with curly quotes, which are not valid for SQL expressions.

---

<div class="post-metadata">

**Author:** ![dustin](https://avatars.discourse-cdn.com/v4/letter/d/5daacb/32.png) [@dustin](https://forum.genieacs.com/u/dustin)\
**Post date:** [September 19, 2022, 7:12pm UTC](https://forum.genieacs.com/t/multiple-preconditions-help/2957/6 "2022-09-19T19:12:34Z")

</div>

I am using the same quotes that works for single evaluations - Device.ID \<\> “OUI1”.  
Tried backtiks as well, just for the sake of trying variations.

---

<div class="post-metadata">

**Author:** ![UNKpl](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/unkpl/32/977_2.png) [@UNKpl](https://forum.genieacs.com/u/UNKpl)\
**Post date:** [September 19, 2022, 7:32pm UTC](https://forum.genieacs.com/t/multiple-preconditions-help/2957/7 "2022-09-19T19:32:50Z")

</div>

Ohh, sorry.  
I didn’t realize MongoDB don’t have IN/NOT IN clause.

I see You use that example but should work `DeviceID.OUI <> "333333" OR DeviceID.OUI <> "222222" OR DeviceID.OUI <> "111111"` on version v1.2.9+20220822165235 work without error.

If You put some SQL or script code put it in quote ``

---

<div class="post-metadata">

**Author:** ![dustin](https://avatars.discourse-cdn.com/v4/letter/d/5daacb/32.png) [@dustin](https://forum.genieacs.com/u/dustin)\
**Post date:** [September 19, 2022, 7:39pm UTC](https://forum.genieacs.com/t/multiple-preconditions-help/2957/8 "2022-09-19T19:39:36Z")

</div>

Thanks. I’ll try that a little later and give some feedback.  
Thanks again everyone.

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [September 19, 2022, 8:36pm UTC](https://forum.genieacs.com/t/multiple-preconditions-help/2957/9 "2022-09-19T20:36:59Z")

</div>

Yeah, mongo doesn’t support SQL syntax. So @zaidka wrote a parser to convert SQL syntax to Mongo query syntax.

---

<div class="post-metadata">

**Author:** ![dustin](https://avatars.discourse-cdn.com/v4/letter/d/5daacb/32.png) [@dustin](https://forum.genieacs.com/u/dustin)\
**Post date:** [September 19, 2022, 10:22pm UTC](https://forum.genieacs.com/t/multiple-preconditions-help/2957/10 "2022-09-19T22:22:58Z")

</div>

While I did not get an error with multiple OR entries, it appears that the precondition did not have an effect.

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [September 19, 2022, 11:01pm UTC](https://forum.genieacs.com/t/multiple-preconditions-help/2957/11 "2022-09-19T23:01:03Z")

</div>

Because you want **AND** and not OR.

---

<div class="post-metadata">

**Author:** ![rudymartin](https://avatars.discourse-cdn.com/v4/letter/r/919ad9/32.png) [@rudymartin](https://forum.genieacs.com/u/rudymartin)\
**Post date:** [September 19, 2022, 11:46pm UTC](https://forum.genieacs.com/t/multiple-preconditions-help/2957/12 "2022-09-19T23:46:02Z")

</div>

I know I’m running late for the party but I have to ask this:

does it has to be a preset ? Why not a provision ?

In our case we use presets only to narrow the events received from the CPE and fire the proper provision. All the logic is inside provisions.

---

<div class="post-metadata">

**Author:** ![dustin](https://avatars.discourse-cdn.com/v4/letter/d/5daacb/32.png) [@dustin](https://forum.genieacs.com/u/dustin)\
**Post date:** [September 20, 2022, 12:43pm UTC](https://forum.genieacs.com/t/multiple-preconditions-help/2957/13 "2022-09-20T12:43:57Z")

</div>

I do have a few presets for different devices but there are also a couple of them that can use the same preset. So I am trying to bundle them into using the same preset.

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [September 20, 2022, 5:14pm UTC](https://forum.genieacs.com/t/multiple-preconditions-help/2957/14 "2022-09-20T17:14:24Z")

</div>

Are you using these presets to set values/tags or refresh items? If so, you really want to do this in a provision. Provision scripts give you a lot more flexibility. In our environment I have 3 main provision scripts that support/configured devices that are bridged, using tr-069, and tr-181. Inside the provision scripts is where I do all the generic config, and also any device/mfgr specific stuff.

It should be noted that GenieACS is smart enough to not send a GPV/SPV for a parameter that does not exist. For example, if in your provision script you have `declare('InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.X_SMARTRG_COM_AddSynFloodRules', {value: now}, {value: true});` and the device in question isn’t a SmartRG, or doesn’t have that path at all, then the SPV will not execute for that device. Behavior like this makes it much easier to have a few generic provision scripts.

If you are trying to set model specific values, I would not use OUI. OUI’s can and are shared amongst models within a mfgr.

---

<div class="post-metadata">

**Author:** ![dustin](https://avatars.discourse-cdn.com/v4/letter/d/5daacb/32.png) [@dustin](https://forum.genieacs.com/u/dustin)\
**Post date:** [September 20, 2022, 7:18pm UTC](https://forum.genieacs.com/t/multiple-preconditions-help/2957/15 "2022-09-20T19:18:36Z")

</div>

For my use case, I test several different models from different manufacturers. This ACS is not used in our production environment but I would sometimes point a friendly customer device to compare what I see on my lab device.  
Some models would throw 9007 errors and I ended up creating separate Provisions and Presets for those that did not work with the default options (inform, etc). It was easier to modify an individual Provision or Preset rather than one long Provision.  
If I have to, I can switch to using one long Provision with all the required logic, but I was hoping to continue with my current setup.

Regarding my use of OUIs, I had also tried ProductClass but still the same issue. I am not worried about an OUI being used with more than one model as this is a lab server and I have control over the 20 to 30 devices on there now.

Thanks again everyone for the support!  
DR

---

<div class="post-metadata">

**Author:** ![dustin](https://avatars.discourse-cdn.com/v4/letter/d/5daacb/32.png) [@dustin](https://forum.genieacs.com/u/dustin)\
**Post date:** [September 22, 2022, 2:45pm UTC](https://forum.genieacs.com/t/multiple-preconditions-help/2957/16 "2022-09-22T14:45:57Z")

</div>

Just an update:  
I switched the conditional logic to the default and inform Provision and I am getting the correct results using ‘case’.

DR
