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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Gerald23
Helper I
Helper I

Query Dynamics CRM PartyList

Hi Everyone,

 

Anyone has experience with getting data from Dynamics CRM from PartyList type fields? I try to get phone call information into power bi but i can't get the data from the To and From field because these are PartyList fields. 

 

This is the query i use and it works but it only returns Null values for these fields.

 

Gerald23_0-1619182845610.png

 

 

let
    GetResults = (z as text, x as number) =>
        let
            S = Json.Document(Web.Contents(ServiceRootURL, [RelativePath="/phonecalls", Headers=[Prefer="odata.include-annotations=*"],Query=[fetchXml="
			<fetch  distinct=""True"" page=""" & Text.From(x) & """ paging-cookie=""" & z & """>
				<entity name=""phonecall"">                                   <all-attributes />
                    
                    
<link-entity name=""activityparty"" from=""activityid"" to=""activityid"" link-type=""inner"" alias=""ad""><filter type=""and""><condition attribute=""participationtypemask"" operator=""in""><value>1</value><value>2</value></condition></filter></link-entity>
				</entity>
			</fetch>"]])),
            P = try Xml.Document(S[#"@Microsoft.Dynamics.CRM.fetchxmlpagingcookie"]) otherwise null,
            R = if P <> null 
                then List.Combine({S[value],@GetResults(Text.Replace(Text.Replace(Text.Replace(Uri.Parts("http://a.b?d=" & Uri.Parts("http://a.b?d=" & P{0}[Attributes]{1}[Value])[Query][d])[Query][d], ">", "&gt;"), "<", "&lt;"), """", "&quot;"), x + 1)})
                else S[value]
        in
            R,
    ResultsList = GetResults("", 1),
    ResultsTable = if List.IsEmpty(ResultsList) 
                    then #table(
                                    type table[                                             #"Subject"= text,
                                            #"Activity Status (statecode)"= text,
                                            #"Activity Status"= text,
                                            #"Priority (prioritycode)"= text,
                                            #"Priority"= text,
                                            #"Due"= text,
                                            #"Created By (createdby)"= text,
                                            #"Created By"= text,
                                            #"Regarding (regardingobjectid)"= text,
                                            #"Regarding"= text,
                                            #"activityid"= text,
                                            #"Call To (to)"= text,
                                            #"Call To"= text,
                                            #"Call From (from)"= text,
                                            #"Call From"= text  ],{})
                    else #"Converted to Table",
	#"Converted to Table" = Table.FromList(ResultsList, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", 
                                        {
                                            "subject",
                                            "statecode",
                                            "statecode@OData.Community.Display.V1.FormattedValue",
                                            "prioritycode",
                                            "prioritycode@OData.Community.Display.V1.FormattedValue",
                                            "scheduledend@OData.Community.Display.V1.FormattedValue",
                                            "_createdby_value",
                                            "_createdby_value@OData.Community.Display.V1.FormattedValue",
                                            "_regardingobjectid_value",
                                            "_regardingobjectid_value@OData.Community.Display.V1.FormattedValue",
                                            "activityid",
                                            "_to_value",
                                            "_to_value@OData.Community.Display.V1.FormattedValue",
                                            "_from_value",
                                            "_from_value@OData.Community.Display.V1.FormattedValue"
                                        }, 

                                        {
                                            "subject",
                                            "statecode",
                                            "statecode@OData.Community.Display.V1.FormattedValue",
                                            "prioritycode",
                                            "prioritycode@OData.Community.Display.V1.FormattedValue",
                                            "scheduledend@OData.Community.Display.V1.FormattedValue",
                                            "_createdby_value",
                                            "_createdby_value@OData.Community.Display.V1.FormattedValue",
                                            "_regardingobjectid_value",
                                            "_regardingobjectid_value@OData.Community.Display.V1.FormattedValue",
                                            "activityid",
                                            "_to_value",
                                            "_to_value@OData.Community.Display.V1.FormattedValue",
                                            "_from_value",
                                            "_from_value@OData.Community.Display.V1.FormattedValue"
                                        }),
    #"Renamed Columns" = Table.RenameColumns(#"Expanded Column1",
                                        {
                                            {"subject", "Subject"},
                                            {"statecode", "Activity Status (statecode)"},
                                            {"statecode@OData.Community.Display.V1.FormattedValue", "Activity Status"},
                                            {"prioritycode", "Priority (prioritycode)"},
                                            {"prioritycode@OData.Community.Display.V1.FormattedValue", "Priority"},
                                            {"scheduledend@OData.Community.Display.V1.FormattedValue", "Due"},
                                            {"_createdby_value", "Created By (createdby)"},
                                            {"_createdby_value@OData.Community.Display.V1.FormattedValue", "Created By"},
                                            {"_regardingobjectid_value", "Regarding (regardingobjectid)"},
                                            {"_regardingobjectid_value@OData.Community.Display.V1.FormattedValue", "Regarding"},
                                            {"activityid", "activityid"},
                                            {"_to_value", "Call To (to)"},
                                            {"_to_value@OData.Community.Display.V1.FormattedValue", "Call To"},
                                            {"_from_value", "Call From (from)"},
                                            {"_from_value@OData.Community.Display.V1.FormattedValue", "Call From"}
                                        }),
    #"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",
{
                                            {"Subject", type text},
                                            {"Activity Status (statecode)", type text},
                                            {"Activity Status", type text},
                                            {"Priority (prioritycode)", type text},
                                            {"Priority", type text},
                                            {"Due", type datetime},
                                            {"Created By (createdby)", type text},
                                            {"Created By", type text},
                                            {"Regarding (regardingobjectid)", type text},
                                            {"Regarding", type text},
                                            {"activityid", type text},
                                            {"Call To (to)", type text},
                                            {"Call To", type text},
                                            {"Call From (from)", type text},
                                            {"Call From", type text}
})
,
#"Result" = if List.IsEmpty(ResultsList) 
                then ResultsTable
                    else #"Changed Type"
in
    #"Result"

 

3 REPLIES 3
Ya_Katrin
Regular Visitor

Hi!

 

Did you found the solution?

v-jingzhang
Community Support
Community Support

Hi @Gerald23 

 

I doubt whether Power BI supports the PartyList type from the Dynamics CRM. I will try to find if there is any workaround to this.

 

Regards,
Community Support Team _ Jing

Ok i will also continue searching and in case i find something i will post it here for everyone that has the same problem in the future

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors