Announcements
No record found.
Hi Everyone,
i need to enable or disable a field based on the value added in sub-grid.
Example: If i add a value in product sub-grid as cisco, then i need to hide a field.
what is the best approach to acheive this.
Any suggestion are appreciated.
You can do this by client side scripts.
On the form editor -> double click the subgrid -> add event handler.
Hi Ram,
You could add your logic inside the Subgrid OnLoad event, fire the subgridOnchange function at form onLoad event.
Code below is when any contact record is added/removed, then it will tell user current total rows in account's contact subgrid.
function subgridOnchange(execContext) { var totalRows = ""; var formContext = execContext.getFormContext(); var subgridObject = formContext.getControl("Contacts"); var myContactsGridOnloadFunction = function() { // totalRows = subgridObject.getGrid().getRows().getLength(); // alert(totalRows); // perform your logic }; subgridObject.addOnLoad(myContactsGridOnloadFunction); }
When there is any item be added/removed from subgrid, your function will be executed.
Regards,
Clofly
Thanks for your answers.
@emily we dont have these option for subgrid in unified service.
@clofly your code works fine to fetch the count. i would be glad if we can get the value or name of the object added in subgrid.
I used the below code but coudnt get the values.
subgridObject.getGrid().getRows().get(1).getData() //not working
As @emily already provide you to direction of code but the thing you do wrong here is when you enter the product in subgrid if it is the first record in subgrid then you can access these records in 0th index.
like subgridObject.getGrid().getRows().get(0).getData();
For more brief look this forum you can easily get the ATTRIBUTE value from the subgrid too for check weather these product is cisco or not
https://community.dynamics.com/crm/f/microsoft-dynamics-crm-forum/212977/get-rows-in-a-subgrid-and-updating-field-on-form
Hope it helps
> You can get a specific row record by(make sure that the attribute/field is available in subgrid):
subgridObject.getGrid().getRows().get(i).getData().getEntity().attributes.getByName("fullname").getValue();
> You can get the last row record by(add check condition when total count is 0):
subgridObject.getGrid().getRows().get(totalRows - 1).getData().getEntity().attributes.getByName("fullname").getValue();
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.
Congratulations to our 2026 Super Stars!
We are thrilled to have these Champions in our Community!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
ManoVerse 103 Super User 2026 Season 1
11manish 83
Muhammad Shahzad Sh... 69 Most Valuable Professional