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 :
Microsoft Dynamics CRM (Archived)

Getting Business phone number from list of Active Contacts system view.

(0) ShareShare
ReportReport
Posted on by

Hello,

Within the Contacts entity, I have a list of contacts in the Active Contacts system view. I have a button that I want to use to extract the "telephone1" attribute from a highlighted (or checked) contact. Does anyone have any suggestions for this? My main issue it determining how to use the entity name, which I would assume is "contacts", while using the Xrm.Page.getControl("contacts") method.

As it stands right now, the above method returns a null value.

numberSelect.PNG

Any help is appreciated.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    To do that you will have do following:

    1. In Ribbon Workbench pass selected records as parameter to function that handles click of your button.

    2. Retrieve field based on identifier of record using crm endpoints.

    Good luck.

  • Community Member Profile Picture
    on at

    So I add a parameter, then enter what in the "Crm parameter = " field?

    Also, can you please elaborate on your second point?

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    1. Should be something like:

    1663.Ribbon.png

    2. To retrieve phone you will have to fetch data using CRM endpoint. I would suggest to use WebApi for that purpose. To make life easier you can use CrmRestBuilder tool to generate request.

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    In your JavaScript code you can have the following function (that you are setting from Ribbon Workbench) as Andrew showed:

    function updateSelected(SelectedControlSelectedItemIds, SelectedEntityTypeName) {

       SelectedControlSelectedItemIds.forEach(

           function (selected, index) {

               getPhoneNumber(selected, SelectedEntityTypeName);

           });

    }

    function getPhoneNumber(id, entityName) {

       var query = "telephone1";

       Sdk.WebApi.retrieveRecord(id, entityName, query, "",

       function (result) {

           var telephone1 = result.telephone1;

           // Do the additional processing you need here

       },

       function (error) {

           alert(error);

       })

    }

    You will need to get the WebApi library from here:

    www.zacrmguy.com/js-crud-operations-with-web-api-in-crm-2016

    There are other libraries available to use with WebApi, or you can do this on your own (without the use of library).

    This should give you a good enough starting point after your set the Ribbon Workbench.

    I also recommend adding the SelectedEntityTypeName parameters to the ribbon function call if you need it (as shown in the code above).

    Hope this helps.

  • Community Member Profile Picture
    on at

    Thank you! That looks like it will save me a headache.

  • Community Member Profile Picture
    on at

    Okay, that's clearer. Thank you for the help.

  • Community Member Profile Picture
    on at

    How do I install the library after downloading it?

  • Verified answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    It is just a javascript file. Add it to your solution as a web resource, and then add it to the libraries area in your form properties.

    If you can't find the library, PM me and I will send it to you.

  • Community Member Profile Picture
    on at

    I found it. So, in the Ribbon Workbench, should my Custom Javascript Action for the button be similar to

    Library: new_dial              

    Function Name: updateSelected

    and the two CRM parameters would be SelectedControlSelectedItemIds and SelectedEntityTypeName?

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 > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans