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 :
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

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 144 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 59

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 52 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans