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)

not getting value in plugin on post create

(0) ShareShare
ReportReport
Posted on by 1,562

Hello All,

In CRM, want to create plugin with below business logic:

 Custom Entity(Seller Profile) having lookup Product and category that value need to send via email to user.

So whenever plugin trigger on create not able to get product and category value in email body.

I am using create message with post operation .7450.123.JPG

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    Do you register a post image under the post create step (using the plugins registration tool)?

    msdn.microsoft.com/.../gg309673.aspx

    You need to access the post image to get the field values.

    var postimage = context.PostImage["XXX"];

    var fieldvalue = postimage.getAttributeValue<EntityReference>("LOOKUPFIELD");

  • ashlega Profile Picture
    34,477 on at

    It should be working without the postimage as well (it's post-create.. whatever shows up in the postimage should also show up in the target). Maybe you could post your plugin code here?

  • Community Member Profile Picture
    on at

    I think you can use out of box workflow to send email with product and category in the body.

  • Tin Profile Picture
    1,562 on at

    but why i have to register POST image .

    Yeah i can get this lookup value ...its working

    but i dont know why i am used this way ??

    could you please give me brief about the logic.

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi Tin,

    Please try using the code below.

    var lookupName=Entityobject.GetAttributeValue<EntityReference>("lookupFieldname").Name;

                                                                             OR

    var lookup = (Microsoft.Xrm.Sdk.EntityReference)(entity.Attributes["lookupFieldName"]);
    var lookupObject = service.Retrieve(lookup.LogicalName, lookup.Id, new ColumnSet(true));
    var lookupName = lookupObject["FieldName"].ToString();

    Hope this helps.

  • Community Member Profile Picture
    on at

    Then you use the target image since it is create message

  • Tin Profile Picture
    1,562 on at

    In target i am not getting "name" i can get only lookup id.

  • Tin Profile Picture
    1,562 on at

    Thanks Nithya,

    Second option is working,but may i know why i am not getting this lookup name on "target" image.

    I can only get lookup ID.

  • Suggested answer
    ashlega Profile Picture
    34,477 on at

    Ah.. that actually makes sense now..

    stackoverflow.com/.../unable-to-get-name-from-entityreference

    postimage is more or less an extra "retrieve"

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi Tin,

    Have you tried the code below?

    var lookupName = ((Microsoft.Xrm.Sdk.EntityReference)(target .Attributes["lookupName"])).Name;


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