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
Thank you, this is great!
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"];
}
}
}
Hi. Thanks for your reply. Do you have a link to any sample plugins that show something similar to what you suggested?
Hi
I have tried this below link, please check and it worked
crmtipoftheday.com/.../make-a-copy-of-forms-with-read-only-fields
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
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156