Information Classification: External Restricted.
See https://www.chili-publish.com/security

Updating Variable Values and Definitions

Variable Data inside a CHILI document can be set using a variety of functions.

You can use JavaScript: ??Javascript Variable Input Forms

You can use External Snippets (dragged and dropped by the user, but populated with variables by your own application): ?External Snippets XML

You can modify the full document's XML, by using ?Webservice Functions - ResourceItemGetXML, updating the definitions/values of the variables in there, and saving it back using ?Webservice Functions - ResourceItemSave (see lower)

You can also use specific functions to update ONLY the variable data (without needing to fetch/save the entire XML):

IMPORTANT NOTE: the latter functions (updating the document's XML or calling the more specific functions) WILL update the variable definitions + values, but WILL NOT update any other part of the XML (for example the reference of the variable value inside a text). This has some important consequences when you try to use them for workflows where that document's XML is not opened within CHILI Editor.

We recommend not to use any special characters(example: single quote ' ) in any of the variable names. It can cause error on some of the Webservice functions.

Those calculations / updates are performed by CHILI Editor. So this might result in a situation where:

  • You update a document's XML (using any of those methods)
  • You request a PDF or preview of the document, but don't see the new values in a variable text frame
  • You open the document inside the Editor, and DO see the new values in those same variable text frames (because the editor will perform the necessary actions)

For situations where no end user will actually edit the document inside CHILI Editor, you can tell CHILI to perform these calculations / updates inside the XML by telling it that it still requires the calculations. This can be done in a number of ways. The main functionality for this (the other ways are basically shortcuts to the same) is to modify the document's XML, and setting, on the root "document" node, the property "savedInEditor" to "false":

<document width="210mm" height="297mm" savedInEditor="false" ...more_properties... >
   ... all of the document content ...
</document>

By doing so, the next time CHILI (on the server side) requires the XML for preview or PDF generation, it will first execute the necessary processing.

To facilitate the (commonly used) DocumentSetVariableValues and DocumentSetVariableDefinitions functions, the XML supplied to those functions can include the same "savedInEditor" attribute (internally, this won't stay there, but rather it will be applied to the "document" root node, as above):

<variables savedInEditor="false"  >
   ...variable value or definition items...
</variables>

Updating Variables with Actions

When updating variables that contain "onChange" actions, the action must be triggered on the variable by adding the attribute "triggerChangeOnLoad". This attribute should be added at the <item> node level, and should be added to each item that contains an action.

 <document>
  <variables>
    <item id="123-456-789" triggerChangeOnLoad="true" name="Variable1" displayName="First Variable" dataType="string" value="FIRST VALUE" />
  </variables>
</document>

See Variables XML for more detailed information on the XML format applicable to variables

All information on this page must be treated as External Restricted, or more strict. https://www.chili-publish.com/security