Forum Discussion
Retrieve Item from Object
What's the syntax for getting something out of an Object to store in a string variable? I use a script activity to return a single value from a data warehouse:
{ "resultSetCount": 1, "recordsAffected": 0, "resultSets": [ { "rowCount": 1, "rows": [ { "MaxMod": "2023-01-01T00:00:00Z" } ] } ], "outputParameters": {}, "outputLogs": "", "outputLogsLocation": "", "outputTruncated": false, "executionDuration": 55 }
I was trying to use the output, along the lines of:
Found it!
@activity('Get Max Mod').output.resultSets[0].rows[0].MaxModI guess the first() breaks it. Thanks for pointing me in the right direction.
7 Replies
- NandanHegdeSuper User
Hey,
Do you mean to say the below is your activity output:
{ "resultSetCount": 1, "recordsAffected": 0, "resultSets": [ { "rowCount": 1, "rows": [ { "MaxMod": "2023-01-01T00:00:00Z" } ] } ], "outputParameters": {}, "outputLogs": "", "outputLogsLocation": "", "outputTruncated": false, "executionDuration": 55 }
and what value are you excatly after? can you highlight the part and your desired output so it would be clear to us?
BUt based on my understanding, you can select a specifc array and then iterate it over via for each else you can convert the output to string using string function- MOVCResolver I
Apologies if I wasn't clear, I need to store the value '2023-01-01T00:00:00Z' in a string variable (set variable activity) and I need to know what I need to enter into the Value field (Pipeline expression builder) in order to do that.
- ajaroraMicrosoft Employee
Did you try `@first(activity('Get Max Mod').output.resultSets[0].rows` ?
- MOVCResolver I
Didn't work, got the same "Can't put an Object into a string variable" error message. If I do @first(activity('Get Max Mod').output.resultSets[0].rows[0].MaxMod) then the activity succeeds but the stored value is just "1" and not the date/time I need.
- MOVCResolver I
I switched the activity from Script to Lookup which got me what I need. I used the same query then
@activity('Get Max Mod').output.firstRow.MaxMod with the "first row only" option ticked worked. But there still should be a way to do this with Script activities.