Search code examples
dynamics-crm-online

Dynamics CRM Online Business Rules for child grids


Can you create business rules based on child grids?

When creating an Opportunity there is a grid called "Sales Team" and a field called "Identify Sales Team".

I would like to create the following business rules when creating an Opportunity or moving it between stages in the workflow Process.

  1. User must enter at least one row in the Sales Team grid.
  2. The Identify Sales Team value is set to "Mark Complete" when no rows. If one or more rows are added then the Identify Sales Team value is set to "Complete".

How can this be done?


Solution

  • Not using business rules as far as I know.

    You can use JavaScript to count the number of records in a sub grid, then set the field conditionally in JavaScript.

    var count = Xrm.Page.getControl("sales_team_grid").getGrid().getTotalRecordCount();
    
    if(count > 0) {
    ... set your field value
    }