Versions Compared

Key

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

A common use case involves modifying updating the properties of existing checklist items.


Steps

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

    Code Block
    oChecklistItem[] items = fromJson(DoD);
  2. Loop over the collection and apply the desired changes. For example, you could remove the status of a specific item.

    Code Block
    for(oChecklistItem item in items) {
        if (item.name == "Code reviewed") {
            item.statusId = "none";
        }
    }
  3. Update the custom field by passing it the same collection that was initially extracted from the custom field converted to JSON.

    Code Block
    DoD = toJson(items);

Example

Here is a full example that can be used to modify a checklist to:

  • Uncheck all items;

  • Clear items with the “In Progress” status;

  • Make the “Code reviewed” item optional.

In this example, the checklist field’s name is DoD.

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

for(oChecklistItem item in items) {
    // Uncheck all items
    item.checked = false;

    // Remove statuses for items "In progress"    
    if (item.statusId == "inProgress") {
        // "none" is the system value for "no status"
        item.statusId = "none";
    }
    
    // Item "Code reviewed" is changed to be optional (not mandatory)
    if (item.name == "Code reviewed") {
        item.mandatory = false;
    }
}

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