Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Plugin on Post Event update

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi All,

Requirement - I have an entity which has a field A (Data type - Integer) and  need to update the field B value on Account entity. Plugin is triggering on Create- Post operation but not on Update. Created Post Image with filtering attributes and added on step as well which is not working. neither triggering nor giving an error. looks like something is missing.

Please suggest.

Thanks.

*This post is locked for comments

  • Verified answer
    gdas Profile Picture
    gdas 50,089 on at
    RE: Plugin on Post Event update

    Hi Ashwin,

    You need to create two steps both update, create message of the entity. In addition you need to register both pre-image and post image to check the differences whether Accounts lookup updated or not by getting value from pre and post image. Don't forget to check null when you get the pre-image as for Create message you wont get pre-image , you will get only on update case.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Plugin on Post Event update

    plugin needs to trigger on Loyalty score update, account is a lookup field on Loyalty entity which contains loyalty score. Every time loyalty score gets updated it should trigger.

  • Dynamics365 Rocker Profile Picture
    Dynamics365 Rocker 7,755 on at
    RE: Plugin on Post Event update

    Please make sure when your plugin get trigger:

    On Loyalty score or on Account update.

    You will get fields that has been updated in Target.

    If you need fields that are not updated then you have to use Pre-post images.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Plugin on Post Event update

    Plugin is triggering on Account field update but not on the other filed. i want it to trigger on loyaltyscore field.

  • Suggested answer
    Dynamics365 Rocker Profile Picture
    Dynamics365 Rocker 7,755 on at
    RE: Plugin on Post Event update

    No, post image for account as it is not updating.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Plugin on Post Event update

    Thanks for your help...

    But account field will not be updated on the record. Other field which is loyalty score will gets updated and plugin should trigger.

    Post Image i need to add only loyalty score field, correct?

  • Verified answer
    Dynamics365 Rocker Profile Picture
    Dynamics365 Rocker 7,755 on at
    RE: Plugin on Post Event update

    Your code is fine. Just Update below line:

    Entity entity = (Entity)context.InputParameters["Target"];

    Entity postImageEntity=(Entity)context.PostEntityImages["PostImage"];

    Guid loyid = new Guid(entity.Id.ToString());

    if (!postImageEntity.Attributes.Contains("account") )

    {

    return;

    }

    accountid = ((EntityReference)postImageEntity.Attributes["account"]).Id;

    Also make sure that You must register Post image through plugin registration tool.

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: Plugin on Post Event update

    Hi,

    If you do not update "account" field during update. Below code is the root cause,

    if (!entity.Attributes.Contains("account"))
    
    return;


    If the field is not updated, it will not include in Target Entity

    You can refer below post.

    [View:https://stackoverflow.com/questions/30287320/how-to-push-a-value-of-an-unchanged-field-into-the-target-in-a-plugins-input-pa:750:50]

    are you trying to check if this trigger from account entity? if yest ,you should

    if (entity.LogicalName != "account")
    
    return;

    Additional , you also can put extra checking to differentiate the code for create and update.

    crmbusiness.wordpress.com/.../

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Plugin on Post Event update

    Account field contains data, during update Account will not update. plugin should trigger on another field update which is not happening. On create it is working fine

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: Plugin on Post Event update

    Hi,

    When you test with update, did you update the "account" field as well? is this "account" field contain data?

    If you do not update "account" field during update. Below code is the root cause, 

    if (!entity.Attributes.Contains("account"))
    
    return;


    You can refer below post. 

    stackoverflow.com/.../how-to-push-a-value-of-an-unchanged-field-into-the-target-in-a-plugins-input-pa

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans