Friday, August 24, 2012

FormEntityContextRule Example



 CustomActions:

        <CustomActions>
          <CustomAction Id="Mscrm.SubGrid.new_test.AddExistingAssocCustom" Location="Mscrm.SubGrid.new_test.AddExistingStandard" Sequence="30" >
            <CommandUIDefinition>
              <Button Id="Mscrm.SubGrid.new_test.AddExistingStandard" Command="Mscrm.AddExistingRecordFromSubGridStandardCustom" Sequence="30" LabelText="CustomAddExistingStd" Alt="$Resources(EntityDisplayName):Ribbon.SubGrid.AddExisting" Image16by16="/_imgs/ribbon/AddExistingStandard_16.png" Image32by32="/_imgs/ribbon/AddExistingStandard_32.png" TemplateAlias="o1" ToolTipTitle="$Resources(EntityDisplayName):Mscrm_SubGrid_EntityLogicalName_MainTab_Management_AddExistingStandard_ToolTipTitle" ToolTipDescription="$Resources(EntityDisplayName):Mscrm_SubGrid_EntityLogicalName_MainTab_Management_AddExistingStandard_ToolTipDescription" />
            </CommandUIDefinition>
          </CustomAction>

          <CustomAction Id="Mscrm.SubGrid.new_test.AddNewStandardCustom" Location="Mscrm.SubGrid.new_test.AddNewStandard" Sequence="20" >
            <CommandUIDefinition>
              <Button Id="Mscrm.SubGrid.new_test.AddNewStandard" Command="Mscrm.AddNewRecordFromSubGridStandardCustom" Sequence="20" LabelText="CustomAddNewStd" Alt="$Resources(EntityDisplayName):Ribbon.SubGrid.AddNew" Image16by16="/_imgs/ribbon/NewRecord_16.png" Image32by32="/_imgs/ribbon/newrecord32.png" TemplateAlias="o1" ToolTipTitle="$Resources(EntityDisplayName):Mscrm_SubGrid_EntityLogicalName_MainTab_Management_AddNewStandard_ToolTipTitle" ToolTipDescription="$Resources(EntityDisplayName):Mscrm_SubGrid_EntityLogicalName_MainTab_Management_AddNewStandard_ToolTipDescription" />
            </CommandUIDefinition>
          </CustomAction>
        </CustomActions>



CommandDefinitions:

        <CommandDefinitions>
          <CommandDefinition Id="Mscrm.AddExistingRecordFromSubGridStandardCustom">
            <EnableRules>
              <EnableRule Id="Mscrm.AppendToPrimary" />
              <EnableRule Id="Mscrm.EntityFormIsEnabled" />
            </EnableRules>
            <DisplayRules>
              <DisplayRule Id="Mscrm.AddExisting" />
              <DisplayRule Id="Mscrm.ShowForOneToManyGrids" />
              <DisplayRule Id="Mscrm.AppendToPrimary" />
              <DisplayRule Id="Mscrm.AppendSelected" />
              <DisplayRule Id="Mscrm.CanWriteSelected" />
              <DisplayRule Id="Mscrm.CustomShow" />
            </DisplayRules>
            <Actions>
              <JavaScriptFunction FunctionName="Mscrm.GridRibbonActions.addExistingFromSubGridStandard" Library="/_static/_common/scripts/RibbonActions.js">
                <CrmParameter Value="SelectedEntityTypeCode" />
                <CrmParameter Value="SelectedControl" />
              </JavaScriptFunction>
            </Actions>
          </CommandDefinition>
          <CommandDefinition Id="Mscrm.AddNewRecordFromSubGridStandardCustom">
            <EnableRules>
              <EnableRule Id="Mscrm.AppendToPrimary" />
              <EnableRule Id="Mscrm.EntityFormIsEnabled" />
            </EnableRules>
            <DisplayRules>
              <DisplayRule Id="Mscrm.ShowForOneToManyGrids" />
              <DisplayRule Id="Mscrm.AppendToPrimary" />
              <DisplayRule Id="Mscrm.CreateSelectedEntityPermission" />
              <DisplayRule Id="Mscrm.AppendSelected" />
              <DisplayRule Id="Mscrm.HideAddNewForChildEntities" />
              <DisplayRule Id="Mscrm.CustomShow" />
            </DisplayRules>
            <Actions>
              <JavaScriptFunction FunctionName="Mscrm.GridRibbonActions.addNewFromSubGridStandard" Library="/_static/_common/scripts/RibbonActions.js">
                <CrmParameter Value="SelectedEntityTypeCode" />
                <CrmParameter Value="PrimaryEntityTypeCode" />
                <CrmParameter Value="FirstPrimaryItemId" />
                <CrmParameter Value="PrimaryControl" />
              </JavaScriptFunction>
            </Actions>
          </CommandDefinition>
        </CommandDefinitions>


RuleDefinition:
        <RuleDefinitions>
          <TabDisplayRules />
          <DisplayRules>
            <DisplayRule Id="Mscrm.CustomShow" >
              <FormEntityContextRule EntityName="account" InvertResult="true" />
            </DisplayRule>
          </DisplayRules>
          <EnableRules />
        </RuleDefinitions>

No comments:

Post a Comment