Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

AutoPopulate Phone number on phone call activity

Posted on by 155

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

  • rosschester84 Profile Picture
    rosschester84 20 on at
    RE: AutoPopulate Phone number on phone call activity

    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.

  • Suggested answer
    Ren Jones Profile Picture
    Ren Jones 80 on at
    RE: AutoPopulate Phone number on phone call activity

    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.

  • Fubar Profile Picture
    Fubar 2,752 on at
    RE: AutoPopulate Phone number on phone call activity

    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:

    • Phone Calls can be for Account, Contact or User (i.e. your code needs to handle different Entity Types).
    • Call direction (determines if you really want the To or the From party)
    • To and From are Party Lists (so can potentially contain more than one record when the user edits the form - and could contain Account, Contact and User records at the same time)
    • You will want to trigger your code onload, and onchange (call direction, To and From)
  • Suggested answer
    Kumar Viju Profile Picture
    Kumar Viju 1,026 on at
    RE: AutoPopulate Phone number on phone call activity

    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.

    arunpotti.com/.../

    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!

  • RickPagliarulo Profile Picture
    RickPagliarulo 5 on at
    RE: AutoPopulate Phone number on phone call activity

    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.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: AutoPopulate Phone number on phone call activity

    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?

    pastedimage1586521759754v1.png

    2. Also, when I remove the contact, an error message is generated. Why do you suppose this is happening?

    pastedimage1586521818634v2.png

    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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: AutoPopulate Phone number on phone call activity

    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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: AutoPopulate Phone number on phone call activity

    you can use the javascript to populate the phone number by having custom workflow  activity on workflow possibly real time,.

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: AutoPopulate Phone number on phone call activity

    Hi

    you can use below code to acheive it.

    1680.9.PNG

    For Account

    5700.8.PNG

    For Contact

    6866.7.PNG

    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.

    1680.9.PNG

    6471.10.PNG

  • Suggested answer
    Alok Singh Profile Picture
    Alok Singh 910 on at
    RE: AutoPopulate Phone number on phone call activity

    Hi ,

    You can user real time workflow to auto populate phone number from Account or Contact on creation of Phone call.

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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans