The WrapStack function allows advanced users to perform bulk operations on wraps. Users can insert new wraps, update existing wraps, or add fields to a wrap template. This can save considerable time when many new wraps need to be created regularly, e.g. for daily inspection, or when the same change needs to be done to many or all wraps.
When wraps are used to document work that is repeated regularly, users may have to enter the same data over and over again. WrapStack offers a simple structure for automation of such monotonous processes, where users can easily prefill or prepopulate the database with all the necessary checklists.
WrapStack can also be used to assign a new value to one or more fields in existing wraps, or add one or more new fields to all wraps.
You can manually create a static list of the Unique Keys that are to be inserted or updated in bulk. If the operation affects several wraps, it may be easier to create a MyWraps report that contains all the Unique Keys that you want to participate in the bulk operation. Driven by the Unique Keys in the MyWraps report, WrapStack automatically inserts new or updates existing target wraps with the field contents you have provided.
All WrapStack operations are serialized through a job queue that ensures that the database is never overloaded by background operations. To further reduce the load on the system, we recommend that you retain the default option to not recalculate wraps while they are being added or updated. In most cases, it is better to save this for later.
Example: At the beginning of a day, it is known what trains will arrive at a depot for inspection. A WrapStack job is used to create a new daily inspection checklist wrap for each carriage in each train that arrives at the depot. The correct checklist is used for each type of carriage in the train.
When WrapStack enqueues a job, you can log the event in the Audit Trail.
To use WrapStack, you build a “control” wrap that contains one or more WrapStack functions. The control wrap initiates the background jobs that perform the requested bulk operations.
When you convert this spreadsheet to a wrap, each WrapStack function appears as a Create Instances button. The user presses this button to initiate the bulk operation.
Each WrapStack function in the control wrap has an instance data table that describes the bulk operations it will perform. In the screenshot above, the instance data table is marked with yellow. The contents of the instance data table are described in detail below.
An error in your instance data table may result in an attempt to create an instance of the Target wrap that already exists. If you have selected Create instances as the Action for the WrapStack function, this will terminate the operation.
Example: a daily inspection wrap contains the inspection date as part of the Unique Key. When using WrapStack, you can insert today’s date automatically. All the new wraps will now have a unique key, since today’s date wouldn’t have been used for any previous daily inspection. You can use an autonumber field with an asterisk “*” as the autonumber to ensure that new wraps always have a unique serial number as part of their Unique Key.
An error in your instance data table may result in an attempt to update a Target wrap that doesn’t exist. If you have selected Update instances as the Action for the WrapStack function, this will terminate the operation.
Example: a daily inspection wrap contains the inspection date as part of the Unique Key. When using WrapStack with a Source MyWraps report that doesn’t contain a date, you must insert the appropriate date using the instance data table. You can then update all the existing wraps that have the Unique Keys provided by the Source MyWraps report and the date specified in the instance data table.
The WrapStack function also has an Action to both Update existing instances and create new instances. If a Unique Key already exists, the wrap will be updated, if not it will be inserted as a new wrap. This ensures that all Unique Keys provided by the Source MyWraps report and the instance data table exist for the Target wrap.
However, it also increases the risk of errors, and you may want to consider running this as two separate jobs, one Create and one Update job, to have the Unique Keys properly validated as non-existing (for the Create job)) and existing (for the Update job).
The TargetWrap column is the left-most column in the instance data table, and contains the name of the wrap that is subject to the bulk operation defined by the row.
If this column is empty for a row in the instance data table, the row is ignored. This makes it possible for you to design an “intelligent” data table that manipulates a variable number of wraps, e.g. for trains that appear in different fixed combinations of carriages.
To create such an intelligent table entry, you can use function calls similar to this:
The column heading for this column must be TargetWrap.
The SourceMyWraps column is the right-most column in the instance data table. It allows you to finely designate what wraps you want to manipulate for each row in the instance data table, by using a MyWraps report to provide their Unique Keys.
The Source MyWraps report link is created just like any other report in MyWraps. You will spend most of the time tweaking the filters in the report link to ensure that it generates exactly the Unique Keys that you want to create in the Target Wrap. Remember that you can use filters also on columns that are not included in the report.
The output of a MyWraps link is partially controlled by the MaxRows, pageSize, and page parameters. WrapStack respects all three parameters. Read more in the MyWraps help for MaxRows.
When the MyWraps report fulfills your requirements, you copy the second half of the MyWraps link (everything after /MyWraps/, in blue below) from the browser’s Address field to the SourceMyWraps column.
The SourceMyWraps report is only used to provide the Unique Keys for each wrap that is affected by the bulk operation. Any data you want to insert into the affected wraps must be provided as static content, see below.
The column heading for this column must be SourceMyWraps.
There are several types of static content for the new or updated wraps that you may want to provide in the instance data table:
A column in the instance data table that provides static content for a field in the wrap must use the field name as the column header. If you want to assign a value to a field called inspection_date in the wrap, the heading for this column in the instance data table must be inspection_date. All field names must be in lower case.
It is possible to manipulate two or more wraps in the Target for each instance in the Source MyWraps report. This usually happens when the Target wrap has additional Unique Keys that are provided in the instance data table. In the example below, the Target has a Projectcode key. For each instance in the Source Mywraps report, WrapStack will generate or update one instance of Target with Projectcode A, one with Projectcode B and one with Projectcode set to C. All other components of the Unique Key for the new instances of the Target are provided by the Source MyWraps report.
If a cell evaluates to a null value, it will be ignored. No insert or update will be made for the corresponding field.
If a cell evaluates to an empty string, the corresponding cell in the new or updated wrap will be set to an empty string.
You can assign static values also to checkboxes, but since these are stored as strings in the ExcelWraps database you cannot use True/False values in the Instance Data Table. When providing static content for a checkbox field,
Note that this only applies to checkboxes. Other Boolean fields in the database are set using the expected True/False values.
You can provide static content for the following reserved cell names:
The WrapStack function can affect many wraps, which can create a heavy extra load on the database infrastructure. WrapStack places the entire bulk operation as a wrap job on the Wrapsite’s server queue. All the database operations for one WrapStack function are run as one wrap job.
After a user press Create instances and a wrap job has been queued in order to perform the required database operations, the user gets a wrap job ID in return. The Wrap job id appears in the confirmation message
and in the Wrap at the position of the WrapStack function. You should instruct users to save this job ID for future reference.
You can follow the serialized processes by monitoring the Wrap Jobs queue on the wrapsite. Learn more on the Wrap administration help page.
If you want the control wrap to offer a link to the Wrap Jobs Queue, you can use the following formula in the source spreadsheet:
=HYPERLINK("/MoreVision.ExcelWraps/WrapJobsAdmin" ,"Wrap Jobs Queue")
A WrapStack can be a complicated operation to set up. If you make a mistake that you don’t notice until the job has been run, you can use the Undo feature to roll back all the changes made by the WrapStack job.
In the example above, the bulk action defaults to “create new instances”. New wraps will be created for the WrapStackTarget wrap. One wrap will be created for each Unique Key in the Source MyWraps report. If the Unique Key already exists, the job will be terminated.
The following cell formula is inserted in the cell.
=WrapStack(instance_data_table, recalculate_instances, action)
Each WrapStack function is associated with an instance data table in a designated cell range. The format of this table is described under Definitions above.
If you don’t specify a valid cell range, the conversion will fail.
If you want to execute all the formulas, WrapLinks, etc for each wrap already during the bulk operation, set the recalculate_instances option to True. This will make the bulk operation considerably slower than if you allow this to happen the next time each wrap is opened.
The default is False.
Select the bulk operation to be performed using an integer 1-3:
The default is 1.
When WrapStack processing is complete, the WrapStack function returns the job id.