Forum Discussion

Kelemvor's avatar
Kelemvor
Icon for Expert rankExpert
2 months ago

Can a lower level Property add to an existing property or will it always overwrite it?

Hi,

If I have a property at the root level called "Property1" and it' set to a value of "Item1", is there any way to go to a lower level group or resource and set "Property1" to "Item2" and have the result be Item 1and Item2 instead of just Item2?

I didn't know if I can do anything like Property1 +=Item2 or something to have it take the Item1 that it inherited from above and add Item2 to it so they are both there.

I don't think there's a way, but it'd make things a lot easier if I could, so just wanted to make sure I'm not missing anything.

Thanks.

  • As far as I know, properties will override and not append when set at various levels. The only exception I'm aware of is system.categories. It does appear to append the various levels together (I believe it's internally stored as an array). I would be careful not to overload with manual categories though, it's heavy involved with controlling what checks are applied to devices.

    Can you cover in more general what you are looking to do? Perhaps there are other ways to implement what you are looking to do.

    • Kelemvor's avatar
      Kelemvor
      Icon for Expert rankExpert

      We have a module that uses a property to list out Windows Services that we want it to check and restart if they aren't working.  We have some services we want checked at a global level and other services that would only be at a lower level.

      If I have "Service1" I want checked everywhere, and "Service2" that I only care about on certain machines, I can add Service1 at root, but then I have to add "Service1|Service2" at the lower level to keep them both in there.  If I only add Service2 at the lower level, it will currently overwrite Service1.

      I didn't think there was a way around it, but thought if there was a syntax-type trick to make it append instead of replace, that'd be helpful.

      • Joe_Williams's avatar
        Joe_Williams
        Icon for Professor rankProfessor

        We would accomplish this with two properties then. Something like windows.services.list at the root then windows.services.list.custom wherever else. Then you can just combine them in the datasource.

  • If it's truly a global list, you try putting that filter directly in the DataSource. I didn't test this but perhaps something like this would work?

    You can also do the reverse, like monitor everything that auto-starts but add exceptions (global and custom), something like this (also untested):