Update custom field in contact and ticket

Is it possible to update a contact as well as a ticket custom field? Could use some guidance.

It is possible and it was working, but I cannot get it to work anymore.

I was able to get this to work by taking this guys code and turning it towards contacts instead of assets.

Here’s what I did below and it works great. Adjust as you need, I am not skilled at coding I can code just enough to take other people’s work and make it work how I need it to. My purpose for this is we use MS Power Automate and forms for new user creation. This updates the custom property inside the client’s contacts for billing purposes based on what MS license they choose during user setup. I’m happy to answer any questions you have.

        	[Parameter(Mandatory = $true)]
        	[string] $ContactID = "" ,
        	[Parameter(Mandatory = $true)]
        	[string] $CustomFieldValue = "" 

$ApiToken = 

$ApiBaseURL = "syncromsp.com"

$ApiSubDomain = "YOURDOMAIN"

$CustomField = "YOUR CUSTOM FIELD" 

function Contact-Update-Field ($ApiToken,$Id,$CustomField,$CustomFieldValue) {
$headers = @{
    Authorization="Bearer $ApiToken" 

$payload = @"
  "properties": {
    "$CustomField": "$CustomFieldValue"

  $ApiPath = "/api/v1/contacts"
  $resp = try {
    Invoke-RestMethod -Method PUT "https://$($ApiSubDomain).$($ApiBaseURL)$($ApiPath)/$($ContactID)" -Headers $headers -Body "$payload" -ContentType "application/json"
  } catch {
    Write-Host "ERROR!"
    $result = $_.Exception.Response.GetResponseStream()
    $reader = New-Object System.IO.StreamReader($result)
    $reader.BaseStream.Position = 0
    $responseBody = $reader.ReadToEnd();
    Write-Host $responseBody

Contact-Update-Field -ApiToken $ApiToken -Id $ContactID -CustomField $CustomField -CustomFieldValue $CustomFieldValue
1 Like

Hi, We have a dev working on some automations.
We are experiencing an issue whereby we can update the value of a ticket custom field with no issue, however the value does not show on screen unless you manually go in to edit the custom field and it auto populates with the info sent via the API.

Although the fields are populated , we also cannot filter by “service board” unless we manually select it via the UI ?