UI Refresh script
A UI refresh script can be defined for a container (catalog or hierarchy). The script operates with a Refresh button on the single-edit and multi-edit pages of the interface.
- On the client, takes all the changes that are made and sends them to the server.
- On the server, for each entry in the set,
- Retrieve the current copy of the item from the database.
- Apply the Entry Build script.
- Apply the pending changes that are transferred from the client.
- Apply the Default Value rules and the Non-persisted Value rules.
- Apply the UI Refresh script.
- Add the updated entry to a set to be sent to the client.
- On the server, return the set of updated entries to the client.
- On the client, render the data on the screen.
In single edit, the UI Refresh script is applied to the displayed entry where any attribute's value changed. In multi-edit, the Refresh is disabled unless a row is selected, and the UI Refresh script is applied only to selected entries (rows), where they contain attributes whose values changed, and in the order of those rows from descending order.
Specifying the UI Refresh script
/scripts/catalog
and
for a hierarchy it is /scripts/category_tree
. To
define the script name to the container, use the script operation setContainerAttribute
with
the key UI_REFRESH_SCRIPT_NAME
, and specify the name
but not the directory, as illustrated in the following example script
(where the script name is ui_refresh.wpcs
):var container = getCtgByName("CATALOG");
var attrs = [];
attrs.add("ui_refresh.wpcs");
container.setContainerAttribute("UI_REFRESH_SCRIPT_NAME", attrs);
container.saveCatalog();
Refresh script contents
A UI refresh script can contain any script operations. The entry on which script operates is
available through the implicit variable entry
, and in general the set of implicit
variables is the same as that for a Post-save script.
If a UI refresh script is used to change the values of attributes in the entry, the order of
those changes is completely under the control of the script's author. If the transitive dependencies
(attribute A
depends on attribute B
, which depends on attribute
C
) the changes must be done in the correct order (in this example,
C
, then B
followed by A
).
spec
that has two String
attributes A
and B
:
var val_B = entry.getEntryAttrib("spec/B");
entry.setEntryAttrib("spec/A", "The value of B is: " + val_B);