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)

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

(0) ShareShare
ReportReport
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

I have the same question (0)
  • Suggested answer
    Alagunellaikumar Profile Picture
    6,212 on at

    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

  • Suggested answer
    Alagunellaikumar Profile Picture
    6,212 on at

    Hi

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

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

  • fishyjj Profile Picture
    on at

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

  • Verified answer
    Alagunellaikumar Profile Picture
    6,212 on at

    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
    on at

    Thank you, this is great!

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