web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

LINQ in query expression calling PrevalidationUpdate in CRM 365 online

(0) ShareShare
ReportReport
Posted on by 2,667

Hi All,

I am using below code to get timezone code value from timezone entity which is a lookup in Opportunity


var query = new QueryExpression(OPPORTUNITY.EntityLogicalName);
query.ColumnSet.AddColumns(OPPORTUNITY.timezoneid, OPPORTUNITY.nristarttime, OPPORTUNITY.nriendtime, OPPORTUNITY.OpportunityId);
query.Criteria.AddCondition(OPPORTUNITY.OpportunityId, ConditionOperator.Equal, targetEntity.Id);
var tZ = query.AddLink("new_timezone", "new_timezoneid", "new_timezoneid", JoinOperator.LeftOuter);
tZ.EntityAlias = "tZ";
tZ.Columns.AddColumns("new_timezonecode");
EntityCollection retrieveColl = organizationService.RetrieveMultiple(query);
tracingService.Trace("Line 323 " + retrieveColl.Entities.Count);
if (retrieveColl != null && retrieveColl.Entities.Count > 0)
{
timeZoneCode = retrieveColl.Entities[0].Attributes.Contains("tZ.new_timezonecode") ? ((AliasedValue)retrieveColl.Entities[0].Attributes["tZ.new_timezonecode"]).Value.ToString() : string.Empty;
tracingService.Trace("Line 325 " + timeZoneCode);
GetLeadData(tracingService, ref nriStartDate, ref nriEndDate, ref timezoneID, retrieveColl);
}

Here when timezone is first time empty & we are trying to update this field value then getting retrieveColl count as 1 but Linq is not working means timezone code not getting.Anything doing wrong here?

But it is working if 2nd time i am updating timezone lookup value on opportunity
pastedimage1669374293885v1.png

But in postoperationUpdate its working fine in prevalidation its taking previous value.

Thanks,

Jharana

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    The reason is that Pre-Operation plugin is executed Before the server operation (so writing the data to the SQL) that's why it queries the old and not new data. And that's why the code works in post operation (because the server operation completed already).

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    If my reply (or replies) answers your question take a minute and verify the answer. You can do it by clicking "Yes" at the top of the reply (or replies) under the label "Does this answer your question?"

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 85 Super User 2026 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

#3
11manish Profile Picture

11manish 64

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans