Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

OrganizationService Update triggering change events for fields that maintain their value.

Posted on by 695

I have a webform that pulls in values from CRM (D365) On-Premise. When the form is saved, there is a date field, that even when I do not assign a value, the onchange event is fired in CRM, which in my case, fires a workflow.

If _Entity.DateField Is Nothing And Me.txtDate.Text <> "" Then
                _Entity.DateField = Me.txtDate.Text
            ElseIf _Entity.DateField IsNot Nothing Then
                If _SWTCommon.Field(_Entity.DateField, " ", 1) <> Me.txtDate.Text Then
                    _Entity.DateField = Me.txtDate.Text
                End If
            End If

The _SWTCommon.Field function formats the date time string as date only. I use the same function to fill the textbox when the web form loads. I've stepped through and seen that no value gets assigned to _Entity.DateField, but the workflow that is triggered by the onchange is still fired.

*This post is locked for comments

  • TonyN Profile Picture
    TonyN 695 on at
    RE: OrganizationService Update triggering change events for fields that maintain their value.

    I was doing exactly what you thought I was doing. Thanks for your help. I appear to have it working now.

  • Verified answer
    ashlega Profile Picture
    ashlega 34,475 on at
    RE: OrganizationService Update triggering change events for fields that maintain their value.

    Hi Tony,

     how are you updating the form? If it's like this:

     Entity a = Service.Retrieve(...);

     ...

     Service.Update(a);

     that update will be sending all the attributes back to the server, and that will be counted as an update of those attributes(even if they have not changed).

     Should be like this instead:

     Entity a = Service.Retrieve(...);

     ...

     Entity b = new Entity(...);

     b.Id = a.Id;

     //Set b attributes

     Service.Update(b);

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans