Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Plugin's Target missing attributes

Posted on by 30

Hello,

I have an entity called Student with two attributes - an OptionSet field called Status and a Lookup field called Faculty.

On a record update (Post-Op) I'd like to trigger a plug-in whenever the Status changes to a certain value.

The record to be updated has a Faculty attached to it already.

My code is as follows - 

        Entity studentTarget = context.InputParameters["Target"] as Entity;
            new_student student = studentTarget.ToEntity<new_student>();
            if (student.Contains("new_faculty") && student.new_Faculty != null && student.new_Status.Value == 3)
            {
// some logic
}

But the Faculty attribute returns null. 

P.S. When registering a new step to the plug-in , in Filtering Attributes, I included both Faculty and Status attributes.

What could be the problem here?

Is it because the Faculty doesn't change that the attribute returns null? If so, how can I resolve this problem?

Thank you

*This post is locked for comments

  • Verified answer
    Guido Preite Profile Picture
    Guido Preite 54,081 Super User 2024 Season 1 on at
    RE: Plugin's Target missing attributes

    in the update message the target contains only the attributes that changed. If you need to access other fields you need to register an image

    more details here

    https://community.dynamics.com/crm/b/thinkdynamicdodynamic/archive/2018/01/21/pre-image-and-post-image-in-dynamics-crm

  • Suggested answer
    Kokulan Profile Picture
    Kokulan 18,048 on at
    RE: Plugin's Target missing attributes

    Hi

    I would first check if the attribute is passed in the entity image before converting to new_student.

    you could try something like this 

    var hasAttribute =  studentTarget.Attributes.Contains("new_faculty")
    throw new InvalidPluginExecutionException("Faculty attribute passed? : " + hasAttribute); }

    If this exception displays true for attribute passed, the problem is in the mapping to early bound class.

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans