Hi
I'm using FetchXML in a CRM online plugin.
Do I need a post image when using FetchXML?
Note I'm using the context.PrimaryEntityId to id the record I want so don't think I need a pre image for that part.
*This post is locked for comments
Hi
I'm using FetchXML in a CRM online plugin.
Do I need a post image when using FetchXML?
Note I'm using the context.PrimaryEntityId to id the record I want so don't think I need a pre image for that part.
*This post is locked for comments
If sCountry is guid type field then please try as below:
EntityReference country=c.GetAttributeValue<EntityReference>("tri_country");
sCountry=country.id;
Hope this helps:)
Hi,
Can you please try to get guid as follow:
sCountry = c.GetAttributeValue<EntityReference>("tri_country");
Guid country=sCountry.id;
Hi and thanks
That seems to give the same result "Microsoft.Xrm.Sdk.EntityReference"
Hi,
If you are trying to get guid then i guess you are missing following code:
sCountry=c.GetAttributeValue<EntityReference>("tri_country").id.ToString();
Hope this helps:)
Hi again!
Ive now got the data coming from the FetchXML and can see it in debug and its inserting into my external SQLserevr db. Happy days.
But, I have a problem with EntityReferences.
They are ending up in my db as "Microsoft.Xrm.Sdk.EntityReference"
I think i need to convert to strings so I can store a value like "8F3E4A08-1263-E611-80C0-308D99276D29" ??
An example of my code for a guid is;
sCountry = c.GetAttributeValue<EntityReference>("tri_country").ToString();
Many thanks
Hi Stuie,
don't look at the count - check if you code is entering the loop. Depending on when you are looking at the count, it can be 0 or not.. The query is not, really, executed until you enter "foreach"..
Enother option might be to try var entityList = results.Entities.ToList(); There you will have the count.
Hi again
Thanks for all the help.
I'm not getting any plugin errors anymore. It seems to run fine.
The XML I'm using for the fetch tests ok in the online testing tool against our CRM.
The problem now, even though the testing tool returns data, is all the variables I'm populating from the results are blank! I'm using hard coded xml in terms of the condition to be sure I replicate the test.
When debugging I can see that the loop shows a count of Zero entities.
That cannot be correct can it? foreach (var c in results.Entities) <- this = 0
Why would that be and why would all the values be blank even though I'm 100% sure there is data.
Many thanks
Have a look at this:
community.dynamics.com/.../beware-the-aliasedvalue-attribute-dynamics-crm
(Scroll down to the bottom - there is sample code)
Thank you
I think I've managed to do it using
sAppID = c.GetAttributeValue<string>("tri_studyapplicationid");
Just need to figure the same method now for Alias records from Linked Entities -_-
You just need to add a condition - use entity.Contains("attributeName") to check if an attribute is present in the entity (it won't be there if it's null)
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,235 Most Valuable Professional
nmaenpaa 101,156