How can we auto populate phone number field on phone call activity from contact/account (Other than Javascript or Plugin)??
*This post is locked for comments
How can we auto populate phone number field on phone call activity from contact/account (Other than Javascript or Plugin)??
*This post is locked for comments
Have you ever tried using https://grizzlysms.com/tiktok-douyin service before? It's a great choice if you struggle with sms verification or activation, and these actions are pretty easy and fast, it's also useful for facebook, instagram, tiktok phone verification and other social media.
As the other replies have suggested- there isn't really a quick and easy out-of-the-box solution to this if you need the value on form open (so sync workflows aren't an option). The best 'no code' way I've found is the following:
Add a quick view form off the 'regarding' look-up: You'll can then expose the phone number via the regarded record- rather than 'call to', as they'll often be intimately related (e.g. a lead when you're calling the parent contact).
To do this- there are a couple of steps:
1. Make sure your phone number is on the regarded record- this may involve adding a custom field and/or a field mapping (e.g. lead, parent contact).
2. Create/modify you're quick view form to ensure the phone number is on there.
3. Remove the text phone number field and add the quick view to the phone call form (using the regarding look-up, then select the relevant entity, then the quick view).
The nice thing about quick views is that they'll only show if the relationship is there- so you can potentially have a few on there (e.g. one for regarded contact, one for regarded lead) and the right one will be shown according to the regarded record.
I have recently done this, but can't give the code for it as it was done for a specific customer - but can confirm that it is possible using JavaScript (including Xrm.WebApi.retrieveRecord).
There are a couple of things to watch out for:
Assumption 1: If you are going to create Phone Call from Account UCI (Timeline)
(No Code Approach)
a. Create a custom N:1 Relationship between Account and Phone Call using Phone Call Activity ( OOB Relation will not work as it is managed to add any mappings. I doubt even if it has mapping label)
b. Add mapping between Primary Phone and the Phone Number
(Code Approach)
Refer to this blog to get the basics of retrieving values using JScript and WebApi. It will help you, in the long run, to perform and type of queries.
Advice:
1. Avoid using traditional\custom workflow for any of your business needs if you are in Cloud and use PowerAtumate(Flow) to have a stable long term solution. Workflows are soon to be deprecated!
Hi Georgi,
For question #1 - It might work if you configure the script to run OnLoad, as well (from what I can see based on Wei's instructions, it looks like the script it firing OnChange of that "Call To" field. I am not sure how it will behave when creating a new record, but you could try to have the script run when the form loads as well, instead of just when that specific "Call To" field changes.
As for question #2, I think the error may be occurring because the script is running when the "Call To" field changes. Since your process is currently to clear out that Call To field, and then fill it back in, you are changing the field twice. The first time the script runs is when you clear out the "Call To" field -- at this point the script is trying to read and execute actions based on a blank value -- hence the message "cannot read property EntityType of undefined." Maybe you can add a condition to the beginning of the script, that says to only carry out an action if the "Call To" field contains data.
I hope this helps! My experience with javascript web resources is pretty limited, but I've run into these same types of issues in the past, so I think the answers above do address your questions.
Hello Wei,
Thank you for the solution. I am however facing a few issues with it:
1. When I open the phone call activity, the phone is not pre-populated. I have to remove the already pre-added contact and add it again. Is it possible to change that?
2. Also, when I remove the contact, an error message is generated. Why do you suppose this is happening?
Here is the error message:
TypeError: Cannot read property 'entityType' of undefined
at getphonecall (sentiadev.crm4.dynamics.com/.../sen_phonenumbercopy:6:60)
at mp.executeFunction (sentiadev.crm4.dynamics.com/.../app.js
at mp.execute (sentiadev.crm4.dynamics.com/.../app.js
at up._executeIndividualEvent (sentiadev.crm4.dynamics.com/.../app.js
at up._executeEventHandler (sentiadev.crm4.dynamics.com/.../app.js
at Object.execute (sentiadev.crm4.dynamics.com/.../app.js
at O._executeSyncAction (sentiadev.crm4.dynamics.com/.../app.js
at O._executeSync (sentiadev.crm4.dynamics.com/.../app.js
at O.executeAction (sentiadev.crm4.dynamics.com/.../app.js
at t.dispatch (sentiadev.crm4.dynamics.com/.../app.js
Thanks for your help!
Regards,
Georgi
Hello Wei,
Thank you for the solution. I am however facing a few issues with it:
1. When I open the phone call activity, the phone is not pre-populated. I have to remove the already pre-added contact and add it again. Is it possible to change that?
2. Also, when I remove the contact, an error message is generated. Why do you suppose this is happening? Here is the error message:
TypeError: Cannot read property 'entityType' of undefined
at getphonecall (sentiadev.crm4.dynamics.com/.../sen_phonenumbercopy:6:60)
at mp.executeFunction (sentiadev.crm4.dynamics.com/.../app.js
at mp.execute (sentiadev.crm4.dynamics.com/.../app.js
at up._executeIndividualEvent (sentiadev.crm4.dynamics.com/.../app.js
at up._executeEventHandler (sentiadev.crm4.dynamics.com/.../app.js
at Object.execute (sentiadev.crm4.dynamics.com/.../app.js
at O._executeSyncAction (sentiadev.crm4.dynamics.com/.../app.js
at O._executeSync (sentiadev.crm4.dynamics.com/.../app.js
at O.executeAction (sentiadev.crm4.dynamics.com/.../app.js
at t.dispatch (sentiadev.crm4.dynamics.com/.../app.js
Thanks for your help!
Regards,
Georgi
you can use the javascript to populate the phone number by having custom workflow activity on workflow possibly real time,.
Hi
you can use below code to acheive it.
For Account
For Contact
function getphonecall(executionContext) { var formContext = executionContext.getFormContext(); if(formContext.getAttribute("to").getValue() != null) { var entity = formContext.getAttribute("to").getValue()[0].entityType; var id = formContext.getAttribute("to").getValue()[0].id; id = id.replace("{", "").replace("}", ""); var query ; if(entity == "account") { query = "/api/data/v9.1/accounts("+id+")?$select=telephone1"; // remember to change v9.1 to your correct version, i am using telephone1, if you are using other field, please change it accordingly } else if (entity == "contact") { query = "/api/data/v9.1/contacts("+id+")?$select=telephone1";// remember to change v9.1 to your correct version, i am using telephone1, if you are using other field, please change it accordingly } var req = new XMLHttpRequest(); req.open("GET", Xrm.Page.context.getClientUrl()+query,true); req.setRequestHeader("OData-MaxVersion", "4.0"); req.setRequestHeader("OData-Version", "4.0"); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-Type", "application/json; charset=utf-8"); req.setRequestHeader("Prefer", "odata.include-annotations=\"*\""); req.onreadystatechange = function() { if (this.readyState === 4) { req.onreadystatechange = null; if (this.status === 200) { var result = JSON.parse(this.response); var telephone1 = result["telephone1"]; formContext.getAttribute("phonenumber").setValue(telephone1);// i am using telephone1, if you are using other field, please change it accordingly } else { Xrm.Utility.alertDialog(this.statusText); } } }; req.send(); } }
I register above JS on "Call TO " , you also can imporve the JS to do more checking.
Hi ,
You can user real time workflow to auto populate phone number from Account or Contact on creation of Phone call.
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,280 Super User 2024 Season 2
Martin Dráb 230,214 Most Valuable Professional
nmaenpaa 101,156