Work with objects and fields

Best practices and considerations when working with objects and fields using the Skedulo CLI.

Overview

The Skedulo CLI allows you to manage objects and fields efficiently, providing operations such as create, delete, update, and list.

This guide covers best practices for safely managing objects and fields, modifying vocabulary options on standard fields, and understanding reference field behaviors.

Manage objects and fields

Objects and fields represent data structures and attributes within Skedulo. Fields are defined within objects and each object can have multiple custom fields to store various types of data.

The Skedulo CLI allows you to manage these elements via commands that enable you to create, update, retrieve, and delete custom objects and fields. For more on this, see the Work with artifacts section or the artifacts command reference.

Object labels

Standard and custom objects both have a singular label and a plural label, but you manage each using a different artifact.

Standard object labels

Override a standard object’s label with the standard-object-override artifact. For a first-time rename, write a state file yourself; there’s no existing override to export yet. For example, to rename Jobs to Appointments, create Jobs.standard-object-override.json:

{
  "metadata": {
    "type": "StandardObjectOverride"
  },
  "objectName": "Jobs",
  "label": "Appointment",
  "labelPlural": "Appointments"
}

Then apply it:

sked artifacts standard-object-override upsert -f Jobs.standard-object-override.json

To read back an override that already exists, use get:

sked artifacts standard-object-override get --objectName Jobs

You must set at least one of label or labelPlural; whichever you leave out keeps the object’s derived value. Deleting the artifact clears the override and reverts the object to its derived labels; it doesn’t delete the object itself.

This override works the same way as one set from Objects & fields in the web app; see Where a customized object label appears for where the new label does and doesn’t show up.

Custom object labels

A custom object’s custom-object artifact carries both a singular label and a labelPlural, alongside its other properties:

sked artifacts custom-object get --name MyCustomObject
{
  "metadata": {
    "type": "CustomObject"
  },
  "name": "MyCustomObject",
  "label": "My Object",
  "labelPlural": "My Objects",
  "description": "My Object Description"
}
sked artifacts custom-object upsert -f MyCustomObject.custom-object.json

This only applies to objects you’ve created yourself. Targeting a standard object’s name with custom-object fails; use standard-object-override above instead.

Considerations when deleting objects and fields

Data loss

When you delete an object or field via the Skedulo CLI, it is removed from the system and any associated data is immediately lost forever.

Reference type fields

When you delete a Lookup field, all corresponding Has-many relationships that reference the deleted Lookup field will also be deleted. However, deleting a Has-many field does not affect the corresponding Lookup field.

For example, if you have two fields:

  1. AssignedResource: A Lookup field on Jobs that references Resources.
  2. ResourceJobs: A Has-many field on Resources that references the AssignedResource Lookup.

deleting AssignedResource will also delete ResourceJobs. However, deleting ResourceJobs will not delete AssignedResource.

See the Lookup and Has-many field type documentation for more information about how these fields work.

Modify vocabulary options on standard fields

While you cannot edit the definition of a standard field, you can customize the vocabulary options (i.e., the allowed values) associated with a standard field, such as the AbortReason field on Jobs. Standard fields can be found in the object reference or in the Objects & fields section in the settings menu of the Skedulo web app.

For example, the AbortReason field on Jobs is a StandardPicklist. You can edit or deactivate existing options, or add new options by following the steps below:

  1. Export the current state of the AbortReason field by running the following Skedulo CLI command:

    sked artifacts custom-field get --objectName Jobs --name AbortReason 
    

    This command will retrieve the field state and save it as a .custom-field.json file.

  2. Open the exported file (Jobs-AbortReason.custom-field.json) in a text editor and modify the existing options, or add new ones. In this example, Weather related has been added and Appointment missed has been deactivated:

    {
      "metadata": {
        "type": "CustomField"
      },
      "objectName": "Jobs",
      "name": "AbortReason",
      "field": {
        "type": "StandardPicklist",
        "allowedValues": [
          {
            "value": "Customer no show",
            "label": "Customer no show",
            "active": true,
            "default": false
          },
          {
            "value": "Canceled by customer",
            "label": "Canceled by customer",
            "active": true,
            "default": false
          },
          {
            "value": "Appointment missed",
            "label": "Appointment missed",
            "active": false,
            "default": false
          },
          {
            "value": "Weather related",
            "label": "Weather related",
            "active": true,
            "default": false
          }
        ]
      }
    }
    
  1. Once you are satisfied with the changes to the vocabulary options, you can apply the updates by running the following command:

    sked artifacts custom-field upsert -f Jobs-AbortReason.custom-field.json
    

    This will update the AbortReason field on Jobs with the new vocabulary options you have defined.

Next steps

Now that you’ve managed objects and fields with the Skedulo CLI, check out:

Work with artifacts

Work with packages

Skedulo CLI command reference

Help and troubleshooting