Need to to capture a grid column value, using the onchange event.

apollo7
apollo7 used Ask the Experts™
on
Dynamics 365 8.2.3,

We are running Dynamics 365 8.2  and having an issue with editable grids.  When using the editable grid, XRM.Page is not supported so code to summarize grid data and update a field on the parent form only works when the form is Refreshed, not when the value is edited “in-line”.

I can make this work, but I need to to capture the grid column value, when changed on the “onchange” event.

According to the documentation I have found, the code examples seem to utilize Dynamics 365.  I’m not sure the Javascript we have supports the examples I have seeing online…specifically the “getFormContext”

Please review the code below and let me know what I need to change.

Thanks

function pvalue(context) { 
    alert("here");  //this works
 
    var estimatedvalue = context.getFormContext().data.entity  // this does not
    var val = estimatedvalue.attribute.getByName("ring_estimatedvolume");
    alert(val.getValue()); 
}
 

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Analyst Developer
Distinguished Expert 2018
Commented:
but I need to capture the grid column value when changed on the “onchange” event.

Not sure but I think you need to attach a change event instead in you JS code like :

document.querySelector("[name='ring_estimatedvolume']").addEventListener('change', function(e){
    alert(e.target.value);
})

Open in new window

Author

Commented:
Thank you, we will test this and get back with any questions.
Rikin ShahMicrosoft Dynamics CRM Consultant

Commented:
Hi,

Your code looks good and it should work. Can you specify your attribute is of which type?

Author

Commented:
This change event solved the problem

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial