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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Custom fields of the entity is not visible in the plugin

(0) ShareShare
ReportReport
Posted on by 76

Hello All,

We have added a couple of custom of fields to the contact entity and added them to the form.
The new fields work fine. But when we try to get hold of the entity in the plugin presave using the generic Entity object,

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

we cant find the custom fields as a part of the entity object.
Should we typecast the generic entity to "contact" using a proxy class that's generated with  "CrmSvcUtil"?

Thanks & Regards,
Clement

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    pavanmanideep Profile Picture
    1,331 on at

    Hi Clement,

    1. You have to make sure the custom fields you were referring are present in the Target, as only those fields which were updated would be present in the Plugin target.

    2. Suspect you were referring to PreUpdate Message as we don't have any PreSave event for Plugins. In such case you can register a Preimage and you should be able to get all the fields present including the fields newly added and those not available in the Target.

    3. See below posts which might help you understand and register images step by step.

    http://www.toplinestrategies.com/blogs/net/dynamics-crm-plugins-how-determine-updated-fields

    https://carldesouza.com/dynamics-365-plugins-pre-post-images/ 

  • Suggested answer
    Kokulan Profile Picture
    18,054 on at

    Hi

    CrmServiceUtil is used to for generating Early Bound strongly typed classes but I think the new fields added to your entity are not in the list of fields to be passed as part of the entity Image.

    If you connect to your CRM instance using Plugin Registration tool, navigate to the Plugin DLL and expand the particular plugin in question and check the Pre/post images

    ScreenClip-_5B00_387_5D00_.png

    If the Parameters say All Attributes, you dont have to do anything but if it lists some attributes, then you will have to tick the new ones as shown below

    ScreenClip-_5B00_387_5D00_.png

    ScreenClip-_5B00_386_5D00_.png

    If you are deploying your solution from Visual Studio, you could check the RegisterFile.crmregister file in the Package project and see whats under the Images tag for the plugin

    If it looks like the following, it means all attributes are passed, if it only lists a fiew, add the new ones to the list

    <Images>
    <clear />
    <Image EntityAlias="PreImage" Name="PreImage" Id="5e7717a3-ae43-e811-a958-002248072825" MessagePropertyName="Target" ImageType="PreImage" />
    <Image EntityAlias="PostImage" Name="PostImage" Id="91ae54b1-ae43-e811-a954-002248072abd" MessagePropertyName="Target" ImageType="PostImage" />
    </Images>

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi ,

    Make sure you have added those fields in the filtering attributes .

    docs.microsoft.com/.../include-filtering-attributes-plugin-registration

    In addition create Pre Image and Post Image as suggested above.

  • Suggested answer
    Charles Abi Khirs Profile Picture
    3,569 on at

    Hello Clement,

    First you should include the needed attributes in the Filtering Attributes of the plugin step.

    Second, as a best practice, you should check for the attribute existance using the following line of code:

    if(entity.Attributes.Contains("<AttributeSchemaName>") && entity.Attributes["<AttributeSchemaName>"] != null) {

    //implement your code here

    }

    In addition, if you are not updating the desired field that triggers the plugin, you can always add a preimage for the plugin step (as mentioned by the others) and then check the existance of the field in the "preimage" entity instance.

    if(preimage.Attributes.Contains("<AttributeSchemaName>") && preimage.Attributes["<AttributeSchemaName>"] != null) {

    //implement your code here

    }

    Hope this helps!

    If found helpful, please mark the answer as verified.

    Charles Abi Khirs.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans