Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

The SubGrid OnRecord Select event does not trigger when the grid is not editable.

(1) ShareShare
ReportReport
Posted on by 11
Our requirement is to have a subgrid that recalculates the voucher price whenever a data item is selected, and it should also perform the recalculations for multiple selections. Is this something that Dynamics cannot do? From what I understand, we can only trigger the event when the grid is editable, which is not what we want. Is there any way to do this? 

  • Verified answer
    Dengliang Li Profile Picture
    Microsoft Employee on at
    The SubGrid OnRecord Select event does not trigger when the grid is not editable.
    Hi,
     
    You can implement this through a custom rule for the subgrid button:
    Execute a specific method when a subgrid record is selected.
     
    In my example, when a Opportunity subgrid record is selected, the unbound action Recalculate is performed to recalculate the amount for that Opportunity.
     
    The code is below.
     
    async function main(SelectedItemIds){
        //If any subgrid records are selected.
        if(SelectedItemIds.length !==0){
            console.log(SelectedItemIds);
            //Iterate through all selected opportunity records and recalculate their amounts.
            for(let item of SelectedItemIds){
               await Recalculate(item).then(
                function success(response) {
                    if (response.ok) { console.log("Success"); }
                }
            ).catch(function (error) {
                console.log(error.message);
            });
            }
        }
       
        //Returns false and always hides the button.
        return false;
    }
     
    function Recalculate(ID){
     
        //Perform the unbound operation Recalculate.
        var execute_RecalculatePrice_Request = {
           
            entityLogicalName: "opportunity", // Edm.String
            entityId: {guid: ID }, // Edm.Guid
       
            getMetadata: function () {
                return {
                    boundParameter: null,
                    parameterTypes: {
                        entityLogicalName: { typeName: "Edm.String", structuralProperty: 1 },
                        entityId: { typeName: "Edm.Guid", structuralProperty: 1 }
                    },
                    operationType: 0, operationName: "RecalculatePrice"
                };
            }
        };
       
        return Xrm.WebApi.execute(execute_RecalculatePrice_Request)
    }
     
     
    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
     
     

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,261 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,017 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans