Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

I Need Emailaddress1 and 2 check if exists or not in Contact entity using plugin in D365 with Plugin code and Registration Steps

Posted on by 95

Hi team,

My request : Emailaddress1 and 2 check if exists or not in Contact entity using plugin.only

if i update/create the emailAddress1 value the plugin Check if exists or not in Contact entity.

if i update/create the emailAddress2 value the plugin Check if exists or not in Contact entity.

I need code and plugin Registration steps also.

Thanks

Saravanan 

  • sars Profile Picture
    sars 95 on at
    RE: I Need Emailaddress1 and 2 check if exists or not in Contact entity using plugin in D365 with Plugin code and Registration Steps

    Hi ,

    Thanks for your reply

    Can you please help me, am not understand the above code so please write full code and plugin registration steps.Its very urgent .

    Thanks

    Saravanan

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: I Need Emailaddress1 and 2 check if exists or not in Contact entity using plugin in D365 with Plugin code and Registration Steps

    Hi,

    For update message steps you can add pre-image to get the data if one of the Email Address is not updated.

    Say User has only updated Email Address 1 then in context you will get this field data. However Email Address 2 field will not be there in context as this is not updated by the used. in this  you need to use pre-image to get the field data.

    Logic -

    First check if field contains in context and not null

          Get Field Data

    Else if Check field and null in pre-image

          Get field data

    If found helpful, Please mark my answer verified.

  • sars Profile Picture
    sars 95 on at
    RE: I Need Emailaddress1 and 2 check if exists or not in Contact entity using plugin in D365 with Plugin code and Registration Steps

    Hi ,

    Thanks for your reply,

    If we have use any images inside the plugin and register the plugin.

    Thanks

    Saravanan

  • Suggested answer
    LeoAlt Profile Picture
    LeoAlt 16,329 on at
    RE: I Need Emailaddress1 and 2 check if exists or not in Contact entity using plugin in D365 with Plugin code and Registration Steps

    Hi partner,

    1.You could use FetchExpression or QueryExpression to check if the emailaddress you update/create is existed in contact.

    Sample code here:https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/org-service/entity-operations-query-data

    2.Since you want to check it when creating or updating the record, you should register the step in 2 event. One is Create and other is Update, post and pre are all appropriate.

    First you should connect to your D365 environment.

    Then create a new Assembly with you plug-in dll file.

    pastedimage1596618815820v1.png

    Next create steps below the Assembly to choose the trigger event and entity.

    pastedimage1596618903345v2.png

    You could refer to the following links for more details.

    https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/tutorial-write-plug-in#register-plug-in

    https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/register-deploy-plugins

    Best Regards,

    Leo

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: I Need Emailaddress1 and 2 check if exists or not in Contact entity using plugin in D365 with Plugin code and Registration Steps

    Hi,

    if i update/create the emailAddress1 and  emailAddress2 value on which entity?

    Plugin registration steps -

    Message - create and update

    Entity - ?

    execution pipeline - pre-operation

    Mode - sync

    For update message - Select Email Address1 and Email Address2 in filtering attributes

    Plugin Code-

    Entity target =context.inputParameters["Target"] as Entity;

    if(target.Attributes.Contains("Email address 1") && target["Email Adddress 1"]!=null)

    {

    //Use service.retrievemultiple to check if email address 1 is present in contact

    //You can use query expression or fetch xml

    //if count is >0 do whatever you need to do

    }

    if(target.Attributes.Contains("Email address 2") && target["Email Adddress 2"]!=null)

    {

    //Use service.retrievemultiple to check if email address 2 is present in contact

    //You can use query expression or fetch xml

    //if count is >0 do whatever you need to do

    }

    Sample code - docs.microsoft.com/.../plugin-development

    If found helpful, Please mark my answer verified.

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