Hi All,
The scenario is if in the subgrid there is no record then on-load/on-save it pop-up a message using javascript.
Please suggest, If, Is there any way to do the same.
Thanks in advance.
*This post is locked for comments
Hi All,
The scenario is if in the subgrid there is no record then on-load/on-save it pop-up a message using javascript.
Please suggest, If, Is there any way to do the same.
Thanks in advance.
*This post is locked for comments
Yes you are right ,put a check on form type == 2 .
Hi Goutam Das,
Thanks for your response!
As you suggested, that register the function in the forms onSave event.
But this is not working because when I am going to create a new case record and then hit the save button without added any record in subgrid it is showing the notification and prevent save functionality which is good.
But I guess without save the new record I am unable to add a record from subgrid because (+) button of subgrid is not visible. This is only visible after save the record.
You can develop custom plugin
Hi Shanti,
Straight forward way its not possible using OOB workflow as you can not get child record inside workflow. So if you need server side validation go for plugin or custom workflow otherwise do client side script.
Is there any other way to do this without Script?
Just asking for information!
Hi Shakti ,
Try with this , instead of alert show form notification . Register this function in the forms onsave event of the forms . Dotnt forget to replace subgrid id .
function ValidateSelectedStageOnSave(context) {
var count = 0;
//Replace the subgrid name in below
if (Xrm.Page != null && Xrm.Page != undefined && Xrm.Page.getControl("subgridcompetitorid") != null && Xrm.Page.getControl("subgridcompetitorid") != undefined) {
count = Xrm.Page.getControl("subgridcompetitorid").getGrid().getTotalRecordCount();
}
if (count == -1 || count == 0) {
Xrm.Page.ui.setFormNotification("Please add at least one competitor", "INFO", "2001"); // Set notification
context.getEventArgs().preventDefault();
return false;
}
else {
Xrm.Page.ui.clearFormNotification("2001"); // Clear notification
}
}
Hi Shakti,
Use the script below:
if (Xrm.Page != null && Xrm.Page != undefined && Xrm.Page.getControl("Name_Of_SubGrid") != null && Xrm.Page.getControl("Name_Of_SubGrid") != undefined) {
var count = Xrm.Page.getControl("Name_Of_SubGrid").getGrid().getTotalRecordCount();
alert("Records:"+count);
}
can you visit the link to show more about Sub Grid:
https://community.dynamics.com/crm/b/mscrmcustomization/posts/sub-grid-client-side-script-methods
André Arnaud de Cal...
292,516
Super User 2025 Season 1
Martin Dráb
231,409
Most Valuable Professional
nmaenpaa
101,156