Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

How To Check in Plugin If a Lead Record Is Created by Email?

(0) ShareShare
ReportReport
Posted on by 535

Hi,

I am trying to do some custom things when a Lead is being created by Email activity. I am using as is Convert To button, i registered a plugin in Lead Create Message, when i check the attributes of the Target i can't see any attribute about this record is being created by E-mail Convert to. Which attribute should i check? My plugin is in PreOutsideTransaction

Thanks

  • furkank Profile Picture
    535 on at
    RE: How To Check in Plugin If a Lead Record Is Created by Email?

    @Bipin Kumar

    Hello, i tried your suggestion but unfortunately when this process is happening on Unified Interface, the regarding field does not set. It stays empty. Again working different from usual. Do you know if i can plug in this process and do this step manually?

    Thanks

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: How To Check in Plugin If a Lead Record Is Created by Email?

    Hello,

    I played a bit and unfortunately I see the same result also I have no other ideas unfortunately.

  • furkank Profile Picture
    535 on at
    RE: How To Check in Plugin If a Lead Record Is Created by Email?

    Unfortunately, in the Unified Interface this convert to lead works different and it is giving parent context null. It is fine when not using unified interface. Aynone got idea why same process giving parent context null in Unified Interface...

  • furkank Profile Picture
    535 on at
    RE: How To Check in Plugin If a Lead Record Is Created by Email?

    This is works too thanks

  • furkank Profile Picture
    535 on at
    RE: How To Check in Plugin If a Lead Record Is Created by Email?

    I found that ParentContext.MessageName is Convert Activity. So this resolves my problem. Thanks

  • Suggested answer
    Bipin D365 Profile Picture
    28,981 Moderator on at
    RE: How To Check in Plugin If a Lead Record Is Created by Email?

    Hi,

    When Lead gets created from Email, Email regarding field will be set to newly created lead. So you can check if newly created lead has any existing Email associated based on regarding. This way you will come to know that lead has created from Email using convert to ribbon button.

    If found helpful, Please mark my answer verified.

  • Verified answer
    Modesto Iacopino Profile Picture
    on at
    RE: How To Check in Plugin If a Lead Record Is Created by Email?

    Hello Furkan,

    you can check the parent context like the following:

    public void Execute(IServiceProvider serviceProvider)

           {

               // Obtain the execution context from the service provider.  

               IPluginExecutionContext context = (IPluginExecutionContext)

                   serviceProvider.GetService(typeof(IPluginExecutionContext));

               ITracingService tracingService =

                   (ITracingService)serviceProvider.GetService(typeof(ITracingService));

               // Obtain the organization service reference.

               IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));

               IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

               if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)

               {

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

                   if (entity.LogicalName == "lead")

                   {

                       Entity lead = entity;

                       if (context.ParentContext.ParentContext != null && context.ParentContext.ParentContext.PrimaryEntityName == "activitypointer")

                       {

                           tracingService.Trace("The lead was created by " + context.ParentContext.ParentContext.InputParameters["ActivityEntityName"].ToString());

                       }

                   }

               }

           }

    Enabling the plugin trace in your org you can see that if you use Convert To inside Email, you will have something like:

    pastedimage1593180532595v1.png

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: How To Check in Plugin If a Lead Record Is Created by Email?

    Hello,

    The only idea that I have in mind is to check "ParentContext" for some additional information. If it doesn't contain it - I'm afraid it will be really hard to define the origin of the lead creation.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 225 Super User 2025 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 97

#3
Vahid Ghafarpour Profile Picture

Vahid Ghafarpour 82 Super User 2025 Season 1

Overall leaderboard

Product updates

Dynamics 365 release plans