Answered by:
Unable to retrieve quotedetails at review of quote

Question
-
Hi,
I have created a plugin at the revise of a quote. I have registered it at Post operation for the create message and am checking the revision number to see it it is a new or revised quote.
I want to fetch all the products at the revise of quote. But when Im querying in the plugin it always returns the count as 0.
However I checked it by using a console application. I queried all the quotes and then there quotedetails and I was able to retrieve them.
Can anyone tell me what Im missing here?
Entity entity = (Entity)context.InputParameters["Target"];
string fetch = @" <fetch mapping='logical'><entity name='quotedetail'>
<attribute name='productid' />
<attribute name='productdescription' />
<attribute name='priceperunit' />
<attribute name='quantity' />
<attribute name='extendedamount' />
<attribute name='quotedetailid' />
<link-entity name='quote' from='quoteid' to='quoteid'></link-entity>
<filter type='and'>
<condition attribute='quoteid' operator='eq' value='{QUOTE}' />
</filter>
</entity>
</fetch> ";
fetch = fetch.Replace("{QUOTE}", entity.Id.ToString());
EntityCollection ec = service.RetrieveMultiple(new FetchExpression(fetch));
Thanks Vineet
Sunday, September 20, 2015 10:25 AM
Answers
-
Hello,
I believe it is related to sequence of operations execution. Try to switch plugin to async mode and check does it work or not. Also I would suggest to change your code to make it lighter and more readable in following way:
string fetch = string.Format(@" <fetch mapping='logical'><entity name='quotedetail'> <attribute name='productid' /> <attribute name='productdescription' /> <attribute name='priceperunit' /> <attribute name='quantity' /> <attribute name='extendedamount' /> <attribute name='quotedetailid' /> <filter type='and'> <condition attribute='quoteid' operator='eq' value='{0}' /> </filter> </entity> </fetch> ", entity.Id);
Dynamics CRM MVP
My blog- Proposed as answer by Mayank PujaraEditor Monday, September 21, 2015 9:29 AM
- Marked as answer by Mayank PujaraEditor Thursday, October 8, 2015 11:09 AM
Monday, September 21, 2015 7:37 AMModerator
All replies
-
Hello,
I believe it is related to sequence of operations execution. Try to switch plugin to async mode and check does it work or not. Also I would suggest to change your code to make it lighter and more readable in following way:
string fetch = string.Format(@" <fetch mapping='logical'><entity name='quotedetail'> <attribute name='productid' /> <attribute name='productdescription' /> <attribute name='priceperunit' /> <attribute name='quantity' /> <attribute name='extendedamount' /> <attribute name='quotedetailid' /> <filter type='and'> <condition attribute='quoteid' operator='eq' value='{0}' /> </filter> </entity> </fetch> ", entity.Id);
Dynamics CRM MVP
My blog- Proposed as answer by Mayank PujaraEditor Monday, September 21, 2015 9:29 AM
- Marked as answer by Mayank PujaraEditor Thursday, October 8, 2015 11:09 AM
Monday, September 21, 2015 7:37 AMModerator -
Thanks for the inputs.
Thanks Vineet
Tuesday, September 22, 2015 5:09 AM