Fetching the child element in a column from salesforce

60 views Asked by At

I am querying the data from salesforce using python

The soql that I am using is select {column} from {salesforce_object_name} where type = 'sports' "

In this, for few columns, I am getting the results like this OrderedDict([('attributes', OrderedDict([('type', 'Contact'), ('url', 'hvhcgcuhkjhkncvgcgc')])), ('Name', 'NA - Holding Off')]). Actually, I want the value which is in the Name field. In this case, NA - Holding Off.

In the column parameter in the query, I am passing as column_name.Name but I am still getting the results as I mentioned above. Someone pls help

1

There are 1 answers

0
amsh On

You can access the name value by using: column_name['Name']

e.g.

from collections import OrderedDict

dict_ = OrderedDict([('attributes', OrderedDict([('type', 'Contact'), ('url', 'hvhcgcuhkjhkncvgcgc')])), ('Name', 'NA - Holding Off')])

print(dict_['Name']) #will output 'NA - Holding Off'

More details on OrderedDict.