Personalized Community is here!
Quickly customize your community to find the content you seek.
Check out the latest Sales updates!Learn about the key capabilities and features of Dynamics 365 Sales and experience some of the new features.
Download overview guide | Watch Sales video
2021 Release Wave 2Discover the latest updates and new features releasing from October 2021 through March 2022.
2021 release wave 2 plan
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Community | FastTrack Program | Finance and Operations TechTalks | Customer Engagement TechTalks | Upcoming TechTalks | All TechTalks
I am trying to get the name of the sales agency but I am getting only the id of it, I used $expand to get data from the id but it is giving me a "Bad Request" error.
var response = client.GetAsync("leads?$select=firstname,_zav_salesagency_value&$top=1&$expand=zav_salesagency").Result; //"Bad Request" error
This $expand is working fine,
var response = client.GetAsync("accounts?$select=name&$top=2&$expand=primarycontactid").Result; // Working
What is the issue can anyone tell me how I can get the Sales Agency name instead of id.
The $expand directs that related records should be retrieved in the record or collection being retrieved.
You can refer following link to know more details:
From your description, Sales Agency is one custom entity and it has one relationship with leads.
The relationship between Sales Agency and leads is 1:N or N:1? Which are different.
For testing, I have created two custom entitites (Custom1 and Custom2), Custom1 and lead is 1:N relationship and Custom2 and lead is N:1 relationship.
If so, you need locate the name of the lookup field behind $expand.
If so, you need locate the name of the entity relationship that defines this relationship behind $expand.
Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.
1) Yes, right Sales Agency is one entity and it has a relationship with leads.
1 Lead has 1 Sales Agency.
2) Hear, sales Agency (zav_salesagencyname) if FK in leads and it is PK of account.
Leads table screenshot.
but why this query giving me "Bad request error"
3) Here, for parentaccountid is also FK and I am getting results for that below is the query,
4) I made a console application and trying to get the data.
What I am missing or anything is wrong is this query please assist.
Thank you for your query.
Does it work without expand? Make sure the property name (agency lookup) is correct.
Please note, the name of the expand (navigation property) is case sensitive. It is possible in the DB it shows lower case, however the schema name in OData endpoint is Camel notation (or other).
Please try the following:
In the file look for Contact or Agency entity and note the navigation property name (with case).
You could also try to list all columns of contact (without expand) and notice the property name for sales agency lookup.
Maybe you can build it with the help of the tool--CRM REST Builder:
Download page: https://github.com/jlattimer/CRMRESTBuilder
For example, Custom1 is one lookup field in the lead form:
Settings in CRM REST Builder tool:
Clicking 'Create Request':
Business Applications communities