Script locks and change propagation
- Last UpdatedJun 24, 2024
- 3 minute read
When you lock a script in a template, the following rules apply:
-
The name of a script and its existence is implicitly always locked. This means:
-
You cannot delete the script in derived objects.
-
You cannot change the name of the script in derived objects.
-
If you rename the script in the template, the name changes in all derived objects.
-
If you delete a script from the template, the script is deleted from all derived objects.
-
If you add a script to the template, the script is added to all derived objects.
-
You can add scripts to derived objects. Adding scripts to derived objects does not affect parent object scripts.
-
-
You can lock or unlock the script text in a template. There is script text for Declarations, Execute, Startup, Shutdown, On Scan and Off Scan.
-
You cannot separately lock a script in the script editor. A single group lock is used to lock or unlock all scripts at once. Once a script is locked, derived templates and instances cannot modify any of the script text.
-
You can lock alias names and alias references separately.
-
When you create aliases for a script, an AliasReference attribute is created for each script with aliases. To lock alias references, you must lock the AliasReference attribute.
-
Changes to alias names only propagate to derived objects when aliases are locked in the Scripts page.
-
Changes to alias references only propagate to derived objects when the AliasReference attribute is locked in the Attributes page.
-
If the AliasReference attribute is not locked, the alias references will be editable in derived objects, but changes made in the parent template will not propagate to derived objects.
-
-
The script description, runs asynchronous flag, expression, trigger type, trigger period, deadband and execution error alarm are individually lockable and can be locked separately from the script text. A group lock is provided for this group of attributes.
-
When you add a script to a template, all properties of the script are editable.
-
When you add a script to an instance, all properties of the script are editable, except the lock properties (locks do not serve any purpose in instances since you cannot derive child objects from them).
Important: An expression typically uses attribute references. If you lock the expression and the associated script in a template, use aliases in both the expression and the script. This allows you to specify the attributes that the aliases point to on a per-instance basis while the script code is locked.
The following rules apply to the derivation behavior of locked script attributes:
-
If an attribute is locked in a template, then all templates and instances derived from the template share the copy of the value of the locked attribute. A change to the value is only allowed in the template that locked it. The change propagates to all derived templates and instances.
For scripts, locking an attribute of the script, such as its script text or execution type, in a template means all derived templates and instances point to that locked attribute. Future changes to that locked attribute’s value, such as modifying the script text, propagate and appear in all derived templates and instances.
If instances are deployed, they are marked pending update status. After they are redeployed, the change to the locked attribute in the template exists in the deployed instance.
-
If an attribute is not locked in a template, then all templates and instances derived from that template receive their own copy of the value of that unlocked attribute. A change to that unlocked value is allowed in derived templates and instances because they own their own copy. Any change to the unlocked attribute value in the template does not propagate to any derived template or instance.
An unlocked attribute in a script (such as expression or script order) in a template means that all derived templates and instances have their own copy and the value of that unlocked attribute can change. Future changes to that locked attribute’s value (for example, modified expression) in the template does not propagate to any derived template or instance. If instances are deployed, their status does not change to pending update. Redeploying them does not cause the value to change in the deployed instance.