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,...
Answered

Custom button working only on Quote table

(3) ShareShare
ReportReport
Posted on by 54
Good afternoon,
 
I'm running into an interesting problem.
 
I created a custom button on the Quote subgrid (using the Ribbon Workbench) with a simple Javascript function call.  I added the Quote subgrid to both the Account and Opportunity forms.
 
When I select the button from the Opportunity the function triggers and does what it is supposed to do.
When I select the button from the Account nothing happens.  The first line in the function is a simple output to console ("you are in function X").
 
Same button, same function but only triggers on the Opportunity and not the Account.
 
I have recreated the button and and updated the forms multiple times but nothing seems to take.
 
Any suggestions?
 
Thank you.
Categories:
I have the same question (0)
  • Suggested answer
    ManoVerse Profile Picture
    738 Super User 2026 Season 1 on at
    Its very likely happening because the button’s command isn’t receiving the correct parameters when the Quote subgrid is on the Account form. On subgrid buttons, PrimaryControl is not passed, so if the JavaScript function expects it, the command can silently fail. On the Opportunity form it may work only because something on that form makes the call succeed, but on the Account form the same call returns null, so nothing happens.
    In Ribbon Workbench, update the command to pass these parameters instead:
    SelectedControl
    SelectedControlSelectedItemIds
    and avoid using PrimaryControl inside the function for subgrid commands.
    If this doesn’t resolve it, then I would need to see your Ribbon Workbench command setup (screenshot of the Command -> Actions -> Parameters) and the simple JS function signature to confirm there isn’t another issue.
     
    Regards,
    Manoj
    ✅If this answer helped you, please consider marking it as Verified, it really helps others in community
     
  • Tuddrussel Profile Picture
    54 on at
    Thanks for the suggestion ManoVerse but sadly that didn't work.  I updated the ribbon to include SelectedControl and it behaved the same way.  Would work on on form but not the other.
     
    Here is the information you requested (I put everything back in the original state):
     
    Ribbon customization:
     
    Code:
    var CreateQuote_NS = CreateQuote_NS || {};
    CreateQuote_NS.createQuote = function (primaryControl) {
        const formContext = primaryControl; // RIBBON call
        const entityName = formContext.data.entity.getEntityName();
        console.log("Called from " + entityName);
        /**
         * get data from either account or opportunity here an proceed
         */
    }
  • Suggested answer
    Zhilan Profile Picture
    83 on at
    Hey,

    check your function name in the button command in Ribbon work bench, and provide your script if it's possible so we can determine which part is running of the code,
    try to add some debugging lines and monitor it in inspector

    Regards,

    ✅If this answer helped you, please consider marking it as Verified, it really helps others in community
  • Tuddrussel Profile Picture
    54 on at
    After digging around I eventually found the problem.  It appears that one of my earlier scripts wasn't using namespaces correctly (or at all).  Once I remove the offending script things worked and both button functioned as intended.  Looks like I have some work to do to go in and cleanup old scripts.
  • Verified answer
    ManoVerse Profile Picture
    738 Super User 2026 Season 1 on at
    @Tuddrussel glad you were able to fix your code , below is the setup to show who is having same questions with working example :
     
    Ribbon workbench :
    Create button:
    create command like this :
     
    your JS file with function should look like this :
     
    var CreateQuote_NS = CreateQuote_NS || {};
     
    CreateQuote_NS.createQuote = function (selectedControl, selectedIds) {
     
        // Parent form (always works in Ribbon commands)
        var formContext = Xrm.Page;
     
        // Get parent entity name (account, opportunity, etc.)
        var parentEntityName = formContext.data.entity.getEntityName();
     
        // Show alert
        Xrm.Navigation.openAlertDialog({
            text: "Parent Entity: " + parentEntityName
        });
    };
     
    Result : 
     
     
    Regards,
    Manoj
    ✅If this answer helped you, please consider marking it as Verified, it really helps others in community
     
     

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 189 Super User 2026 Season 1

#2
CU11031447-0 Profile Picture

CU11031447-0 100

#3
NeerajPawar Profile Picture

NeerajPawar 66

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans