Custom Update AD Object Invalid JSON primitive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 09:37 AM
Hello,
I have a workflow calling a custom activity (copied Update AD Object) to update user phone numbers.
When I use the test inputs and paste in my JSON it works perfectly. Coming from the workflow input I get errors and I've tried many things.
I was able to get it to work with one variable but when I try to update multiple phone number fields in AD it doesn't work, I tried using .replace to no avail.
My workflow script builds the JSON based on the catalog item variables. Then I create the scratchpad:
var objectDataJSON = JSON.stringify(objectData);
workflow.scratchpad.objectData = objectDataJSON;
gs.info("Update AD Phone - objectData: " + workflow.scratchpad.objectData);
The result in my test is Update AD Phone - objectData: {"homePhone":"51355","ipPhone":"551542"}
Initially I was using $inputData = ConvertFrom-Json -InputObject $ObjectData which was giving the invalid JSON error. I started using $inputData = $ObjectData | ConvertFrom-StringData which works if I am only updating one variable.
Now in the custom powershell script:
$inputData = $ObjectData
$jsonObject = ConvertFrom-Json -InputObject $inputData
Result: 2023-11-27 11:20:08 Env vars: $env:SNC_credType:AD $env:SNC_domainController:btusa.boystown.org $env:SNC_objectData:homePhone=51355`nipPhone=551542$env:SNC_objectName:che256 $env:SNC_type:User
Invalid JSON primitive: homePhone.
HRESULT: [-2147024809]
I tried using .replace in the string but it didn't change my powershell log results.
Please help!
Thank you.