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

I have the same question (0)
  • Verified answer
    Dengliang Li Profile Picture
    Microsoft Employee on at
    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

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 > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
iampranjal Profile Picture

iampranjal 75

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 41 Super User 2025 Season 2

#3
Pallavi Phade Profile Picture

Pallavi Phade 24

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans