Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

You may want to remove some items from a checklist, but not all of them. This can be useful to filter out unnecessary items in a checklist.

Info

To remove all items or reset a checklist, see Updating checklists with new sets of items using SIL instead.


Steps

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

    Code Block
    oChecklistItem[] items = fromJson(DoD);
  2. Remove the targeted items from the collection.

    Code Block
    for(oChecklistItem item in items) {
        // We only keep items that are named "Code reviewed" or are checked
        if (item.name != "Code reviewed" && !item.checked) {
            items -= item;
        }
    }
  3. Update the custom field by passing it the newly created collection converted to JSON.

    Code Block
    DoD = toJson(items);

Example

Here is a full example that can be used to remove all items with the “Not Applicable” status:

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

for(oChecklistItem item in items) {
    // Remove all items whose status is "Not Applicable"
    if (item.statusId == "notApplicable") {
        items -= item;
    }
}

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

Status
titleSERVER DOCUMENTATION
(On Cloud? Go here.)
Have questions? Contact our Service Desk for help anytime.