Skip to main content
Skip table of contents

Updating checklists with new sets of items using SIL

A common use case involves clearing the checklist’s existing content and rebuilding it from the ground up.


Steps

  1. Create an empty collection of the oChecklistItem struct that will contain the new items.

    CODE
    oChecklistItem[] items;
  2. Create an item and add it to the collection.

    CODE
    oChecklistItem newItem;
    newItem.name = "Unit test passed";
    items += newItem;
  3. Update the custom field by passing it the newly created collection converted to JSON.

    CODE
    DoD = toJson(items);

Example

Here is a full example that can be used to update a checklist with a new set of items:

CODE
// We create a user routine to facilitate readability and maintainability of the script.
function createItem(string name, boolean mandatory){
    oChecklistItem newItem;
    newItem.name = name;
    newItem.mandatory = mandatory;
    
    return newItem;
}

// Create an empty oChecklistItem array to facilitate manipulations.
oChecklistItem[] items;

// Create each item and set the required values to each item, adding each new item to the array along the way.
items += createItem("Unit test passed", true);
items += createItem("Code reviewed", false);

// Update the checklist with its new values
DoD = toJson(items);


JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.