--- title: "Set-Contact" slug: "scripting-set-contact" tags: ["Enterprise Only"] updated: 2025-07-16T16:38:59Z published: 2025-07-16T16:38:59Z canonical: "help.agilityblue.com/scripting-set-contact" --- > ## Documentation Index > Fetch the complete documentation index at: https://help.agilityblue.com/llms.txt > Use this file to discover all available pages before exploring further. # Set-Contact ## Summary Updates an existing contact. ```powershell Set-Contact    -Entry    -BypassCustomFieldValidation ``` Returns a [contact](https://apidocs.agilityblue.com/#42542659-8ff2-4dee-aaab-2a003f98641c) object. ## Parameters | Parameter | Type | Required? | Notes | | --- | --- | --- | --- | | Entry | [Contact](https://apidocs.agilityblue.com/#42542659-8ff2-4dee-aaab-2a003f98641c) Object | Yes | | | BypassCustomFieldValdiation | Switch | No, Defaults to `false` | Ignores required field requirement for custom fields when the entry is saved. | ## Examples ### Updates an existing contact ```powershell # Update an existing contact # A common flow for updating existing data is to first retrieve the data using the GET # command, update specific fields, and then provide the modified data back using the SET command. $entry = Get-Contact -Id 79 # Update the "EmailAddress" system field: $entry.EmailAddress = "danielle.herman@company.com" # Update a basic text custom field named "Office Location" to "Los Angeles" $officeLocationField = $entry.Fields | Where-Object { $_.Label -eq "Office Location" } # This is a safety check to make sure that a value exists. For example, the value object may # not exist on a field because the custom field was added after the entry already existed. if ($null -eq $officeLocationField.Value) {  $officeLocationField.Value = @{} } # Here, we update the 'ValueAsString' property of the value because our custom field is a text- # based field. If this was a whole number, you would use 'ValueAsNumber', a decimal would be # 'ValueAsDecimal', a yes/no field would be 'ValueAsBoolean', and a date field would be 'ValueAsDate' $officeLocationField.Value.ValueAsString = "Los Angeles" # We want to update a reference custom field named "Skills" to "Document Review" $skillsField = $entry.Fields | Where-Object { $_.Label -eq "Skills" } if ($null -eq $skillsField.Value) {  $skillsField.Value = @{} } if ($null -eq $skillsField.Value.ReferenceObject) {  $skillsField.Value.ReferenceObject = @{} } $skillsField.Value.ReferenceObject.Values = @(  @{    KeyAsInteger = 1    Value = "Document Review"  } ) # Save the modified contact $data = Set-Contact -Entry $entry # Output some information to help indicate that the client was updated Write-Output "Contact $($data.ContactId) ($($data.NameAndEmailAddress)) was updated" # For debug purposes, convert the data to output as JSON so we can see all the fields Write-Output "" Write-Output "JSON Results:" $jsonOutput = $data | ConvertTo-Json -Depth 10 # Output the data Write-Output $jsonOutput ``` Execution results: ```json Contact 79 (Danielle Herman ) was updated JSON Results: {  "ContactId": 79,  "FirstName": "Danielle",  "LastName": "Herman",  "FullName": "Danielle Herman",  "EmailAddress": "danielle.herman@company.com",  "NameAndEmailAddress": "Danielle Herman ",  "PhoneNumber": null,  "TimeZoneIdentifier": null,  "EnableNotifications": false,  "AllowPortalAccess": false,  "IsFavorite": false,  "NumberOfProjects": 0,  "CreatedByFullName": "Max Miller",  "CreatedById": "25a34a2f-e3d8-4690-88f5-6b399cf88c4c",  "CreatedOn": "2024-04-17T15:06:19.2753792+00:00",  "CreatedBy": null,  "LastUpdatedByFullName": "Max Miller",  "LastUpdatedById": "25a34a2f-e3d8-4690-88f5-6b399cf88c4c",  "LastUpdatedOn": "2024-04-18T11:21:18.841203+00:00",  "LastUpdatedBy": null,  "Fields": [    {      "FieldId": 50,      "ObjectId": 7,      "DataTypeId": 10,      "DataTypeName": "Reference",      "Label": "Skills",      "IsRequired": false,      "Position": 0,      "Guid": 7413322756636,      "IsSystemField": false,      "IsReferenceValue": false,      "DefaultValue": null,      "CopyPreviousValueOnSaveAndNew": false,      "Value": {        "ObjectFieldValueId": 2178,        "ObjectFieldId": 50,        "ObjectId": 7,        "PrimaryKeyId": 79,        "ValueAsString": null,        "ValueAsBoolean": null,        "ValueAsNumber": null,        "ValueAsDecimal": null,        "ValueAsDate": null,        "ReferenceObject": {          "ObjectFieldReferenceObjectInstanceId": 326,          "ObjectFieldValueId": 2178,          "ObjectId": 16,          "Object": null,          "PrimaryObjectId": 7,          "PrimaryKeyId": 79,          "KeyType": "Int32",          "DisplayFormat": "%Name%",          "IsSystemObject": false,          "Name": null,          "NumberOfValues": 1,          "Values": [            {              "ObjectFieldReferenceObjectInstanceValueId": 244,              "ObjectFieldReferenceObjectInstanceId": 326,              "KeyAsString": null,              "KeyAsInteger": 1,              "KeyAsLong": null,              "Value": "Document Review"            }          ]        }      },      "ReferenceObject": null    },    {      "FieldId": 67,      "ObjectId": 7,      "DataTypeId": 1,      "DataTypeName": "Basic Text",      "Label": "Office Location",      "IsRequired": false,      "Position": 1,      "Guid": 1756477664260,      "IsSystemField": false,      "IsReferenceValue": false,      "DefaultValue": null,      "CopyPreviousValueOnSaveAndNew": false,      "Value": {        "ObjectFieldValueId": 2179,        "ObjectFieldId": 67,        "ObjectId": 7,        "PrimaryKeyId": 79,        "ValueAsString": "Los Angeles",        "ValueAsBoolean": null,        "ValueAsNumber": null,        "ValueAsDecimal": null,        "ValueAsDate": null,        "ReferenceObject": null      },      "ReferenceObject": null    }  ] } ```