web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

How to customize the behavior of the phone icon button on the phone number field

(0) ShareShare
ReportReport
Posted on by 3
When I click the button, I want to execute custom logic.What should I do?
I have the same question (0)
  • Suggested answer
    Dengliang Li Profile Picture
    Microsoft Employee on at
    Hi,
     
    First, find the HTML element where the button is located in the browser's backend, and then add custom logic by getting the button through the element selector.
     
    function onload(executionContext) {
     
        //Set a delay of 3 seconds to wait for the form to finish loading.
        setTimeout(function(){
     
            //Get the Mobile Phone field Button element with the element selector.
            var phone_btn = parent.parent.window.document.querySelector("span[data-id='mobilephone.fieldControl-phone-action-icon']");
     
                //Add the click event to the button
                phone_btn.addEventListener("click",function(){
     
                    //You can write custom logic here
                        alert("Hello, World!");
                   
                })
               
        },3000)
     
    }
     
    The final result is shown below.
     
     
    If my answer was helpful, please click Like, and if it solved your problem, please mark it as verified to help other community members find more.
    If you have further questions, please feel free to contact me .
     
    Best Regards,
    Dengliang Li
     
  • Community member Profile Picture
    3 on at
    I'm glad to receive your reply. Yes, currently, I'm also using this approach. It's an imperfect solution, and adding callbacks can help improve this method as much as possible. Because in the window load event, the elements have not yet been loaded.
     
     TestPhoneNumberBtn: function () {
                // Gets the element of the current button.
                var phoneBtn = top.$('[data-id="mobilephonenumber.fieldControl-phone-action-icon"]');

                if (phoneBtn .length > 0) {  
     
                    // mark
                    phoneBtn .attr("mark", "mark");
                    phoneBtn .on('click', function () {
                        alert("Hello world!");
                    });
                } else {
                    // no mark
                    if (phoneBtn .attr("mark") != "mark") {
                        setTimeout(function () {
                            TestPhoneNumberBtn();
                        }, 100);
                    }
                }
            }
  • Dengliang Li Profile Picture
    Microsoft Employee on at
    Hi,
     
    Apologies for the defects in the solution, due to my lack of proficiency with JavaScript.
    Thank you very much for being able to make improvements to the solution.

    Best Regards,
    Dengliang Li
     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 202 Super User 2026 Season 1

#2
CU11031447-0 Profile Picture

CU11031447-0 100

#3
NeerajPawar Profile Picture

NeerajPawar 70

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans