Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Auto-Populate "Phone Number" field while creating a campaign activity

Posted on by

When I'm creating a phone call campaign activity, I'd like to fill in the "Phone Number" field on the phone call activity so users can make the necessary phone call all from the activity form without having to go look up the contact's number. I tried creating a workflow for this by setting the "Phone Number" field to the regarding contact's home phone on create of the activities, but this did not work. 

How might I go about doing this? Thanks for any help. 

*This post is locked for comments

  • fishyjj Profile Picture
    fishyjj on at
    RE: Auto-Populate "Phone Number" field while creating a campaign activity

    Thank you, this is great!

  • Verified answer
    Alagunellaikumar Profile Picture
    Alagunellaikumar 6,210 on at
    RE: Auto-Populate "Phone Number" field while creating a campaign activity

    Hi

    Please find below

    Message name":Create

    Primary Entity:Phone call

    Operation: Pre

    Here I have used mobilePhone field from contact moved to phoneCall entity

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

               {

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

                   if (objEntity == null || objEntity.LogicalName == null)

                       return;

                   EntityCollection objToEntityCollection = (EntityCollection)objEntity.Attributes["to"];

                   if (objToEntityCollection == null || objToEntityCollection.Entities.Count == 0)

                       return;

                   EntityReference objPartyEntityReference = (EntityReference)objToEntityCollection[0].Attributes["partyid"];

                   if (objPartyEntityReference == null || objPartyEntityReference.Id == null || objPartyEntityReference.LogicalName != "contact")

                       return;

                   QueryExpression objQueryContact = new QueryExpression("contact");

                   objQueryContact.ColumnSet = new ColumnSet(new string[1] { "mobilephone" });

                   ConditionExpression objConditionExpression = new ConditionExpression();

                   objConditionExpression.AttributeName = "contactid"; objConditionExpression.EntityName = "contact";

                   objConditionExpression.Values.Add(objPartyEntityReference.Id);

                   objQueryContact.Criteria.AddCondition(objConditionExpression);

                   EntityCollection arrContact = service.RetrieveMultiple(objQueryContact);

                   if (arrContact != null && arrContact.Entities.Count == 0)

                       return;

                   if (!objEntity.Attributes.Contains("phonenumber"))

                   {

                       if (arrContact.Entities[0].Attributes.Contains("mobilephone"))

                       {

                          // EntityReference objPhone = new EntityReference();

                           objEntity.Attributes["phonenumber"] = arrContact.Entities[0].Attributes["mobilephone"];

                       }

                   }

               }

  • fishyjj Profile Picture
    fishyjj on at
    RE: Auto-Populate "Phone Number" field while creating a campaign activity

    Hi. Thanks for your reply. Do you have a link to any sample plugins that show something similar to what you suggested?

  • Suggested answer
    Alagunellaikumar Profile Picture
    Alagunellaikumar 6,210 on at
    RE: Auto-Populate "Phone Number" field while creating a campaign activity

    Hi

    I have tried this below link, please check and it worked

    crmtipoftheday.com/.../make-a-copy-of-forms-with-read-only-fields

  • Suggested answer
    Alagunellaikumar Profile Picture
    Alagunellaikumar 6,210 on at
    RE: Auto-Populate "Phone Number" field while creating a campaign activity

    Phone number is a read only field so workflow cant update. SO try plugin

    In the plugin configure

    message name:Create

    Entity:Phone call

    Operation:POST

    pseudocode

    1)Get the id of regarding field

    2)Use query expression to get the phone number of contact

    3)Update phone number in the phone call activity

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans