ADF expression cannot be evaluated because property 'property_name' cannot be selected. Property selection is not supported on values of type 'String'

Kolla, Venkatesh 0 Reputation points
2024-05-22T13:25:57.4733333+00:00

I have created a parameter with name p_persondetails of OBJECT type, below is the paramater value.

{

"property_name": {

"key1": "value1",

"key2": "value2"

"key3": "value3"

"key4": "value4"

}

}

I have created another parameter with name object_list of arrays and it contains the value ["key1","key2","key3","key4"]

I am using foreach loop in ADF so on each loop and my foreach statement is as below

@pipeline().parameters.object_list

My requirement is that depend upon selected item in foreach activity, I need a dynamic parameter for copy activity based on p_persondetails parameter of object type. I have used below in ADF expression builder for one of the dependent parameters for source data set of copy activity, I am getting error.

Expression: @pipeline().parameters.p_persondetails.property_name[item()]

Error:

The expression '@pipeline().parameters.p_persondetails.property_name[item()]' cannot be evaluated because property 'property_name' cannot be selected. Property selection is not supported on values of type 'String'.

So, to try this further I also used something like below by giving the direct value instead of current item from foreach activity. and it didn't work either

@pipeline().parameters.p_persondetails.property_name['key1']

FYI, the type of source dataset parameter is String as it is expecting string output values from p_persondetails (object type parameter). Can anyone help me figure out a solution for this.

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,906 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 17,866 Reputation points
    2024-05-22T20:30:58.29+00:00

    You can use the @json function to explicitly parse the parameter value as a JSON object :

    
    {
    
      "property_name": "{\"key1\": \"value1\", \"key2\": \"value2\", \"key3\": \"value3\", \"key4\": \"value4\"}"
    
    }
    
    

    And use the @json function to parse the p_persondetails.property_name as a JSON object.

    
    @json(pipeline().parameters.p_persondetails.property_name)[item()]
    
    

    Old thread : https://learn.microsoft.com/en-us/answers/questions/1062812/inconsistent-behaviour-with-data-factory-expressio