Displaying Attachment Data with AutoText
Information about attachments present on the app or scenario can be displayed in a custom view by using the AutoText component.
This is achieved by adding the data-text attribute to an HTML element.
The tag name of the attachment must be specified, along with the name of the field that you wish to display:
- filename: The filename of the attachment.
- description: The description of the attachment.
- tags: A comma-separated list of all tags present on the attachment.
- lastModifiedDate: The date when the attachment file contents were last modified.
- lastModifiedUser: The name of the user who last modified the attachment file contents.
- hidden: Whether or not the attachment is hidden in the UI (either "True" or "False").
The examples below demonstrate how to use the
data-text attribute:
The filename of the app attachment tagged with input-sheet is: <span data-text="attachment:app/input-sheet/filename"></span> The description of the scenario attachment tagged with result-chart is: <span data-text="attachment:scenario/result-chart/description"></span> <!-- For scenario attachments, the "scenario/" prefix is optional: --> The scenario attachment tagged with input-sheet was last modified by: <span data-text="attachment:input-sheet/lastModifiedBy"></span>
A
ScenarioObserver must then be created, and
bindAutoText called, passing a CSS selector which matches the HTML elements to be populated:
var view = insight.getView(); view.withFirstScenario() .bindAutoText('span[data-text]') .start();
If no attachment exists with the specified tag, the HTML element will be populated with a fallback message,
The attachment is not currently available. An alternative message can be specified using the
data-fallback attribute. For example:
The filename of the app attachment tagged with input-sheet is: <span data-text="attachment:app/input-sheet/filename" data-fallback="No input sheet has been uploaded"> </span>