Skip to main content
Skip table of contents

Adding items to checklists using SIL

You may need to extend an existing checklist with additional items.


Steps

  1. Retrieve the current list of checklist items converted from JSON to the oChecklistItem structure.

    CODE
    oChecklistItem[] items = fromJson(DoD);
  2. Create an item and set the values you require.

    CODE
    oChecklistItem newItem;
    newItem.name = "Acceptance criteria for each issue met";
  3. Add the new item to the current values.

    CODE
    items += newItem;
  4. Update the custom field by passing it the same collection that was initially extracted from the custom field converted to JSON.

    CODE
    DoD = toJson(items);

Example

Here is a full example that can be used to add two items to an existing checklist:

CODE
// Retrieve the items in a Structure array to facilitate manipulations
oChecklistItem[] items = fromJson(DoD);

// Create the new items and set their values
oChecklistItem newItem1;
newItem1.name = "Acceptance criteria for each issue met";
newItem1.assigneeIds = {"smith"};

oChecklistItem newItem2;
newItem2.name = "Functional tests passed";

// To add an item at a specific rank, SIL requires to split the current array and merge it back with the item in the required position.
// Warning: array indexes are zero based!
number insertAtPosition = 3;
oChecklistItem[] first2Items = subarray(items, 0, insertAtPosition - 1);
oChecklistItem[] restOfItems = subarray(items, insertAtPosition - 1, arraySize(items) - 1);

// Concatenate all items
items = first2Items + newItem1 + restOfItems + newItem2;

// 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.