Add-Object

Prev Next

Summary

Creates a new object.

Add-Object
    -Entry

Returns an object object.

Parameters

Parameter

Type

Required?

Notes

Entry

Object Object

Yes


Examples

Create a new object

This example shows how to make a “Vendor” custom object with the following fields: Name (basic text), Locations (multiple choice), Contacts (reference object), and Notes (rich text).

# Create an object with required fields
# Note that one field must be marked as "IsReferenceValue". This is the field that is used to
# Display within the UI that when clicked on, opens up a window that shows the rest of the data
$object = @{
    Name    = "Vendor"
    Fields  = @(
        @{
            DataTypeId  = 1
            Label       = "Name"
            IsRequired  = $true
            Position    =  1
            IsReferenceValue = $true
        },
        @{
            DataTypeId  = 9
            Label       = "Locations"
            IsRequired  = $false
            Position    = 2
            DefaultValue = "Minneapolis`nLos Angeles`nDallas`nSeattle`nNew York City`nMiami"
        },
        @{
            DataTypeId  = 10
            Label       = "Contacts"
            IsRequired  = $false
            Position    = 3
            ReferenceObject = @{ ObjectId = 7 }
        },
        @{
            DataTypeId  = 2
            Label       = "Notes"
            IsRequired  = $false
            Position    = 4
        }
    )
}

# Create the object
$object = Add-Object -Entry $object

Write-Output "Created object '$($object.Name)' (Id: #$($object.ObjectId))"

# For debug purposes, convert the entity to output as JSON so we can see the available fields
Write-Output ""
Write-Output "JSON Results:"

$jsonOutput = $object | ConvertTo-Json -Depth 10

# Output the entity
Write-Output $jsonOutput

Execution results:

Created object 'Vendor' (Id: #24)

JSON Results:
{
  "ObjectId": 24,
  "Name": "Vendor",
  "Description": null,
  "AllowCustomFields": true,
  "DefaultDisplayFormat": "%Name%",
  "KeyType": "Int32",
  "IsSystemObject": false,
  "IsListed": true,
  "ListSortOrder": 0,
  "NumberOfFields": 4,
  "Fields": [
    {
      "FieldId": 134,
      "ObjectId": 24,
      "DataTypeId": 1,
      "DataTypeName": "Basic Text",
      "Label": "Name",
      "IsRequired": true,
      "Position": 1,
      "Guid": 45385704063,
      "IsSystemField": false,
      "IsReferenceValue": true,
      "DefaultValue": null,
      "CopyPreviousValueOnSaveAndNew": false,
      "Value": null,
      "ReferenceObject": null
    },
    {
      "FieldId": 135,
      "ObjectId": 24,
      "DataTypeId": 9,
      "DataTypeName": "Multiple Choice",
      "Label": "Locations",
      "IsRequired": false,
      "Position": 2,
      "Guid": 987442716047,
      "IsSystemField": false,
      "IsReferenceValue": false,
      "DefaultValue": "Minneapolis\nLos Angeles\nDallas\nSeattle\nNew York City\nMiami",
      "CopyPreviousValueOnSaveAndNew": false,
      "Value": null,
      "ReferenceObject": null
    },
    {
      "FieldId": 136,
      "ObjectId": 24,
      "DataTypeId": 10,
      "DataTypeName": "Reference",
      "Label": "Contacts",
      "IsRequired": false,
      "Position": 3,
      "Guid": 9678513142778,
      "IsSystemField": false,
      "IsReferenceValue": false,
      "DefaultValue": null,
      "CopyPreviousValueOnSaveAndNew": false,
      "Value": null,
      "ReferenceObject": {
        "ObjectFieldReferenceObjectId": 33,
        "ObjectFieldId": 136,
        "ObjectId": 7,
        "Object": null,
        "KeyType": "Int32",
        "DisplayFormat": "%Val%",
        "IsSystemObject": true,
        "Name": null,
        "NumberOfDefaultValues": 0,
        "DefaultValues": []
      }
    },
    {
      "FieldId": 137,
      "ObjectId": 24,
      "DataTypeId": 2,
      "DataTypeName": "Rich Text",
      "Label": "Notes",
      "IsRequired": false,
      "Position": 4,
      "Guid": 4891671771177,
      "IsSystemField": false,
      "IsReferenceValue": false,
      "DefaultValue": null,
      "CopyPreviousValueOnSaveAndNew": false,
      "Value": null,
      "ReferenceObject": null
    }
  ],
  "CreatedByFullName": "Max Miller",
  "CreatedById": "510e109b-6ff5-4442-9670-cd5e3cd82a7a",
  "CreatedOn": "2026-01-22T14:14:01.8625662+00:00",
  "CreatedBy": null,
  "LastUpdatedByFullName": "Max Miller",
  "LastUpdatedById": "510e109b-6ff5-4442-9670-cd5e3cd82a7a",
  "LastUpdatedOn": "2026-01-22T14:14:01.8625662+00:00",
  "LastUpdatedBy": null
}