Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
MOVC
Helper II
Helper II

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:

 

@first(activity('Get Max Mod').output.resultSets) since each the response is an array, but each line in the array is an object so I can't do @first(activity('Get Max Mod').output.resultSets.rows) or anything.
 
It's probably straightforward but I just can't see it.
1 ACCEPTED SOLUTION

Found it!

 

@activity('Get Max Mod').output.resultSets[0].rows[0].MaxMod
 
I guess the first() breaks it. Thanks for pointing me in the right direction.

View solution in original post

7 REPLIES 7
ajarora
Microsoft Employee
Microsoft Employee

Did you try `@first(activity('Get Max Mod').output.resultSets[0].rows` ? 

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. 

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.

Found it!

 

@activity('Get Max Mod').output.resultSets[0].rows[0].MaxMod
 
I guess the first() breaks it. Thanks for pointing me in the right direction.

Hi @MOVC 

 

Thank you for using Microsoft Fabric Community.

Glad to know that your issue got resolved. Please continue using fabric for help regarding your issues.

NandanHegde
Super User
Super 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




----------------------------------------------------------------------------------------------
Nandan Hegde (MSFT Data MVP)
LinkedIn Profile : www.linkedin.com/in/nandan-hegde-4a195a66
GitHUB Profile : https://github.com/NandanHegde15
Twitter Profile : @nandan_hegde15
MSFT MVP Profile : https://mvp.microsoft.com/en-US/MVP/profile/8977819f-95fb-ed11-8f6d-000d3a560942
Topmate : https://topmate.io/nandan_hegde
Blog :https://datasharkx.wordpress.com

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.fabric.png

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.