How to Set the Sub grid read only using Ribbon Work Bench Latest Version in MS CRM 365
*This post is locked for comments
How to Set the Sub grid read only using Ribbon Work Bench Latest Version in MS CRM 365
*This post is locked for comments
Hi,
In order to disable the subgrid using javascript, use the code below.
function DisableSubgrid() { // Get subgrid control var subGridCtrl = window.parent.document.getElementById("SubgridName_span"); // If subgrid is not loaded yet, then call same function after some time. if (subGridCtrl == null) { setTimeout(DisableSubgrid, 1000) return; } // Disable the subgrid control subGridCtrl.disabled = true; }
Hope this helps.
Hi Sars,
- you need to register it on the entity which will be added to the subgrid (create/update)
- in the plugin, you need to check the lookup field. If it's not there, you can just exit from the plugin
- If the lookup is there (target.Contains(<lookup_attrib_name>), then you need to check whatever conditions you want to check. For example, you might retrieve the "parent" entity and see if it's "inactive":
var parent = service.Retrieve(((EntityReference)target[<lookup_attrib_name>]).logicalName, ((EntityReference)target[<lookup_attrib_name>]).Id, new ColumnState("statecode"));
if((int)parent["statecode"] != 0) //I believe state code is int, but could be an optionsetvalue
{
throw new InvalidPluginExecutionException("Parent entity is read-only");
}
That said, you can do the same with a real-time workflow (just create a workflow, register on the update/create of the child entity, verify parent conditions, and stop it as "cancelled" if needed - the user will see an error message similar to that you'll throw from the plugin)
Hi Alex,
Can you please give me outline logic for to write the plugin code to control add the new rows in subgrid?
Thanks
Saravanan
Hi Sars,
have a look at this article - it outlines all the options (plus there is a link to Ribbon Workbench.. never tried it for subgrids, though):
crmbusiness.wordpress.com/.../crm-2013-disabling-a-subgrid
Personally, I'd just go with a real-time workflow or plugin to display an error when a user attempts to add something to the "readonly" subgrid
Hi ,
Thanks for ur reply.
please let me know if any other way to set sub grid is read only.
and also if possible to set sub grid disabled using java script code.
Hi,
It is not possible to set the sub-grid read only using ribbon workbench.
André Arnaud de Cal...
292,494
Super User 2025 Season 1
Martin Dráb
231,305
Most Valuable Professional
nmaenpaa
101,156