Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Pre-Operation Entity References without Name

Posted on by 615

Hi,

I am trying to fix a bug that we spotted on our system...

in CRM 2011 I have a Pre-Operation plugin, on the Update of the contact

the problem is that in the target entity

var targetEntity = localContext.PluginExecutionContext.InputParameters["Target"] as Entity;

in the attributes, all the "Entity Reference" objects have a "Logical Name", an "Id", but not a "Name"

the name is always empty!

do you know why and if there is a workaround possible?

the only thing that comes to my mind is to retrieve the entity from the reference

but:

1: i would prefer not to call another service

2: there would be a problem for the fieldname (each reference has his own name)...

*This post is locked for comments

  • _Alessandro_ Profile Picture
    _Alessandro_ 615 on at
    RE: Pre-Operation Entity References without Name

    I wanted to avoid that because that mean to test a lot of stuff from the beginning...

    but I think that this is the only possible solution

  • Verified answer
    Dean Holmes Profile Picture
    Dean Holmes 55 on at
    RE: Pre-Operation Entity References without Name

    Is there a reason why you cannot register the plugin on post-operation, as the pre-image and post-image is provided at that point.

  • Suggested answer
    KZee Profile Picture
    KZee on at
    RE: Pre-Operation Entity References without Name

    Unfortunately, I can't see any other way to deal with this situation.  

    I can reproduce this behavior both in On-Premise CRM 2011 (RU18) and CRM 2016. So, my previous answer will stand.

    Please mark the answer as verified if it was helpful.

    Thanks

  • _Alessandro_ Profile Picture
    _Alessandro_ 615 on at
    RE: Pre-Operation Entity References without Name

    I am currently using the preimage

    but the preimage has the status before the update, i need to log the change so the

    preimage value and the current value

  • KZee Profile Picture
    KZee on at
    RE: Pre-Operation Entity References without Name

    Have you tried using preimage which you can register in the plugin registration tools? It is the state of the record before any modifications are done to it and saved into CRM database.

    It should have the Name attribute of entity references.

    Have a look at

    crmbook.powerobjects.com/.../registering-and-deploying-plug-ins

    community.dynamics.com/.../pre-image-38-post-image-explained-33

    e.g. if you register image name contact then you can access it using context.PreEntityImages["contact"] inside your plugin when it fires.

    I hope this helps.

    Please mark the answer as verified if it was helpful.

  • _Alessandro_ Profile Picture
    _Alessandro_ 615 on at
    RE: Pre-Operation Entity References without Name

    this problem is a pain in my ***

    since is a pre-operation I cannot retrieve the contact because the information i look for is not there jet

    and i cannot query all the entity reference because i don't know what will be the name of the field for all the entities...

    thank you anyway

  • Verified answer
    KZee Profile Picture
    KZee on at
    RE: Pre-Operation Entity References without Name

    Thanks. That makes sense now.

    The issue you are experiencing is a known behaviour / issue and has been discussed previously. Unfortunately, you might have to query the CRM again if you want to get that value.

    Following link highlights the same problem and the solution for it.

    social.microsoft.com/.../crm-2011-get-lookup-text-value

    Please mark the answer as verified if it was helpful.

  • _Alessandro_ Profile Picture
    _Alessandro_ 615 on at
    RE: Pre-Operation Entity References without Name

    i know... i am talking about the attributes of type "entity reference" contained in this entity

  • KZee Profile Picture
    KZee on at
    RE: Pre-Operation Entity References without Name

    Hi,

    The type of targetEntity object is Entity and that class has not got a property called Name.

    msdn.microsoft.com/.../microsoft.xrm.sdk.entity.aspx

    If you are looking for the name of the entity then you can use LogicalName property.

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