Run script when tags added to or removed from Folder

Hello everybody,

I would like to know if there any way I can trigger a specific script when a new tag added to a specific folder or tag removed from it.
I have a memory tag with a script on value change that reads tag paths from a parent folder. But the script does not run unless I make any modification manually on that memory tag of course. I need to find a way to run that same script once I add or remove tags in the parent folder.

Thanks in advanced.

You could use a gateway timer script or an expression tag with a change script, and just monitor that folder with system.tag.browse. You would have to have some tags to hold maybe the length or list of tag names in it. Do a compare to that at a reasonable rate.

1 Like

To avoid the XY problem: Why? @kyler.kamyszek's advice will work, and is probably the same way I would do it, but what's the actual purpose you're after here?

1 Like

Thank you @kyler.kamyszek for your advice I will give it a try.
@PGriffith I have different stations with with different number of instruments, so I decide the embedded view according to the number of instruments. I would like to give the client the flexibility to just copy and paste the instruments to add new or remove instruments and everything connect smoothly with my memory tag that saves the instruments paths and another tag that get the number of instruments from the length of the first tag.

I thought of another solution is to give the client a parameter in the station to determine the number of instruments and then on the change of that parameter I will create a script that create new tags or remove the extra tags using system.tag.configure() and system.tag.deleteTags().
I am not that expert so do you thnik it will be a wise solution or at all work?

This is not the "why", this is the "how".

Though I think I can kind of see the "why":
You want to give the possibility to the user to add or remove instruments, and you want to display them.

Why not run the script through the same mechanism that adds the tags ?

But don't leave it to our interpretation/imagination, be as specific as possible, while staying as close as possible to the goal, requirements and constraints.
Then, in a second time, you can describe the solutions you thought of, and maybe the issues they raise.

2 Likes