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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Ribbon Work Bench: Show/Hide Custom Button based on Selected TypeName or TypeCode

(0) ShareShare
ReportReport
Posted on by 77

Hi,

I have added a custom button on subgrid of queueItem entity and I want to show that button only when particular entityType is selected. At present, It is visible all the time irrespective of the queue item selected.

For example: If I select phonecall queueItem, I want to show the custom button otherwise I would like to hide the custom button for other EntityTypes.

Alternative approach to above - If one or many queue items selected from the sub-grid for the custom button is not a phonecall then want to throw an alert message saying selected queueitem is not phonecall but the problem is I need to check all the selected records and see if there any other entity type other than phone call.

Could someone suggest me how I can achieve this. Thanks

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

    Hello,

    The only way I see is to customize the command of the existing button and add a custom enable rule to it.

  • Suggested answer
    Mohsin Ali Profile Picture
    3,634 on at

    Since queueitem contain multiple types of records so  you can't apply enable rules only. So below is the left option only.

    Use below CRM parameter from available list of parameters in your custom button command and pass it as parameter to the JS function. 

    pastedimage1642856368010v1.png

    Here is sample JS as well. 

    function selectedItemsRefs(itemsRef) {
        debugger;
    
        if (itemsRef.length == 1 && itemsRef[0].TypeName == "phonecall") {
            ///DO SOMETHING
            return;
        }
        for (var index = 0; index < itemsRef.length; index  ) {
            ///DO SOMETHING
        }
    }

    Additionally to make sure the button is not showing all the time, you can add below Enable Rule and make sure it is bind to above command as well. Please refer below screenshots for the same.

    pastedimage1642856672742v2.png

    pastedimage1642856693961v3.png

  • D365Admin Profile Picture
    77 on at

    Hi Mohsin Ali and a33ik ,

    Thank you for your time in trying to help me on my issue.

    May be I was not clear enough in explaining the issue above so I will try to explain my issue again!!

    Actually, I have added a custom button on Queue Item subgrid, when user click on custom button...I am moving the queueitem to another queue and changing the status of the queueitem which I have implemented using Ribbon Workbench and JavaScript and all working fine as expected.

    Also I am showing button only when atleast one queueitem is selected from the subgrid by adding Enable Rules.

    But, my main issue here is....I want to have this custom button only enabled on Phonecall related queueitems and for other EntityType queueitems(ex: email,task etc.,) either I want to throw an alert message to user saying selected queueitem is not of type 'phonecall' or hide the custom button from the subgrid buttons if the selected queueitem is not of type 'phonecall'. My main problem is identifying the type of selected item....!!

    I have tried to retrieve the TYPENAME using below code but I am getting the same type everytime as 'queueitem' whichever queueitem I have selected from the subgrid.

    Is it possible in any other way either to hide the button or to know the entitytype based on the selection? Please let me know. Thanks

    function run(selectedItems)

    {

       var selectedItem = selectedItems[0];

       alert("Id=" + selectedItem.Id + "\nName=" + selectedItem.Name + "\nTypeCode=" + selectedItem.TypeCode.toString() + "\nTypeName=" + selectedItem.TypeName);

    }

    Result:

    Id = 17D0EF3A-9B72-46E8-AA88-DAA5FC462FA4

    Name = Test

    TypeCode = 2029

    TypeName = queueitem

  • Verified answer
    Mohsin Ali Profile Picture
    3,634 on at

    The only possible way is to query CRM using guids to get the original entity type name. Because by default it gives you only reference of queuitem instead of phonecall.

  • D365Admin Profile Picture
    77 on at

    Yes, I agree with you. we have to query based on the GUID. Thanks for re-confirming.

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

News and Announcements

Season of Giving Solutions is Here!

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
Pallavi Phade Profile Picture

Pallavi Phade 98

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 79 Super User 2025 Season 2

#3
TAHER Mehdi Profile Picture

TAHER Mehdi 48

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans