modify
  • 23 May 2023
  • Dark
    Light
  • PDF

modify

  • Dark
    Light
  • PDF

Article summary

modify Task Purpose

The modify task creates a new variable from a modified copy of an existing variable. Its primary purpose is to modify an object key's boolean, number, or string value. Modify can create a new variable from both job and tasks' outgoing variables. It works with boolean, number, string, and object data types. It does not work against array data types, and it will not modify elements of an array in an object.

Properties

Incoming Description
object_to_update (required) Specify the variable to modify. You can modify job variables, a static value that can be useful when testing, or an earlier task's outgoing variable.
query (optional) If not using a query, set its reference task to static and delete the contents of its reference variable. When modifying values that have data types of boolean, number, or string, the incoming variable query is not used. If modifying values of object type and you only need to modify a field, specify a query for that field. See example below.
new_value (required) The new value can come from a job variable, a static value, or an earlier task's outgoing variable. The new value will replace the value passed in the object_to_update parameter, but if object_to_update is an object and you specify a query, the new value will only replace the matching field. See example below.


Outgoing Description
updated_object The modified value is assigned to immutable variable updated_object and returned to the job. Optionally click the Job Variables check box to create a job variable from updated_object. The immutable variable updated_object remains, and a new mutable job variable is created. HINT: When creating a job variable, provide a new name to avoid name conflicts and provide clarity.

Example

  1. Change boolean value of a job variable or a previous task's outgoing variable having a value of false. The value of updated_object (outgoing variable) will be true.

    object_to_update = <name of var>
    query = ""
    new_value = true
    
  2. Change string value of a job variable or a previous task's outgoing variable having a value of "before". The value of updated_object (outgoing variable) will be after.

    object_to_update = <name of var>
    query = ""
    new_value = "after"
    
  3. Change boolean value of "sync-status" field in a specified object having a value of true.

    object_to_update = {
        "name": "cr1.atl",
        "sync-status": true
    }
    query = "sync-status"
    new_value = false
    

    The value of updated_object (outgoing variable) will look like this:

    {
        "name": "cr1.atl",
        "sync-status": false
    }
    
  4. Change string value of "description" field in specified object having value of "Northeast region."

    object_to_update = {
        "name": "BMW-1",
        "description": "Northeast region",
        "endpoints": [
            {
                "name": "NYC",
                "device": "er1.nyc"
            },
            {
                "name": "BOS",
                "device": "er1.bos"
            }
        ]
    }
    query = "description"
    new_value = "New England Region"
    
  5. The value of updated_object (outgoing variable) will look like this:

    {
        "name": "BMW-1",
        "description": "New England Region",
        "endpoints": [
            {
                "name": "NYC",
                "device": "er1.nyc"
            },
            {
                "name": "BOS",
                "device": "er1.bos"
            }
        ]
    }
    

Was this article helpful?

What's Next
Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.