It works for me, but I have the script in the global “shared” namespace. I think since it’s in your project namespace the tag doesn’t know which project to look at, since tags are global. Move the script to the global shared area and try it again.
Oh, and the gateway doesn’t have a user or roles – system.security.getRoles() won’t work. That’s only meaningful at a client. If it must be a tag, it’ll have to be a client tag. And client tags can call project scripts, so you don’t need to make it shared.
I created a shared script with a method that accepts three parameters. Two strings and a number. So something like
The method calculates an end date as now(), a start date as 15 seconds earlier, then calls system.tag.queryTagCalculations where the parameters are used to calculate the tag name, and Average is returned.
The last statement in the method is result.getValue(0,1) to get the float value
When I link this to a button in my project it works
When I link it to a tag using runScript(“shared.script_a.calc_method(‘0’,‘middle’,15)”), there are no errors but the result is always null.
Ultimately I want to use this in an alarm, but I can always alarm on the expression tag.
Hi, I have an error in a simple runScript in expression tag, and it is located in shared scripts.
The error message doesn´t indicate too much. Attached you Will find the images.
This is in ignition 8. Any suggestions?
I see that you are in Ignition 8 instead of the original posts which are in 7.9. There is no longer the “Global” project that you are familiar with in 7.9. Instead, tags have access to scripts that are in the Gateway Scripting Project. This is configured on the gateway web page Config > Gateway Settings > Gateway Scripting Project.
At this point, the script you want to access in the tag HAS to be on that project. Tags cannot run scripts from another project that inherits that project. From your pictures, it looks like maybe you have upgraded from 7.9 and that’s why you have a folder named “shared” which is fine, but if you upgraded from 7.9 chances are your Gateway Scripting Project is going to be Global and therefore the script has to be in the project named Global.
Thank you osolorzano, I followed your advice and it worked perfectly!
you are right, this Gateway was loaded from Ignition 7.9, and it created automatically the Gateway Scripting Project with the name Global.