Tuesday, August 28, 2012

How to add custom button in entity? and how to set custom rules for the added buttons in MS CRM 2011?




Use the below defined XML code to add custom button and set custom rules.

      <RibbonDiffXml>
        <CustomActions>
          <CustomAction Id="vps.Form.quote.MainTab.Actions.Button.Approve.CustomAction" Location="Mscrm.Form.quote.MainTab.Actions.Controls._children" Sequence="20">
            <CommandUIDefinition>
              <Button Id="vps.Form.quote.MainTab.Actions.Button.Approve" Command="vps.Form.quote.MainTab.Actions.Button.Approve.Command" LabelText="$LocLabels:vps.Form.quote.MainTab.Actions.Button.Approve.LabelText" ToolTipTitle="$LocLabels:vps.Form.quote.MainTab.Actions.Button.Approve.LabelText" ToolTipDescription="$LocLabels:vps.Form.quote.MainTab.Actions.Button.Approve.ToolTip" TemplateAlias="o1" Image16by16="$webresource:new_approved16" Image32by32="$webresource:new_approved32" />
            </CommandUIDefinition>
          </CustomAction>
          <CustomAction Id="vps.Form.quote.MainTab.Actions.Button.Reject.CustomAction" Location="Mscrm.Form.quote.MainTab.Actions.Controls._children" Sequence="30">
            <CommandUIDefinition>
              <Button Id="vps.Form.quote.MainTab.Actions.Button.Reject" Command="vps.Form.quote.MainTab.Actions.Button.Reject.Command" LabelText="$LocLabels:vps.Form.quote.MainTab.Actions.Button.Reject.LabelText" ToolTipTitle="$LocLabels:vps.Form.quote.MainTab.Actions.Button.Reject.LabelText" ToolTipDescription="$LocLabels:vps.Form.quote.MainTab.Actions.Button.Reject.ToolTip" TemplateAlias="o1" Image16by16="$webresource:new_reject16" Image32by32="$webresource:new_reject32" />
            </CommandUIDefinition>
          </CustomAction>
          <CustomAction Id="vps.Form.quote.MainTab.Actions.Button.Seek.CustomAction" Location="Mscrm.Form.quote.MainTab.Actions.Controls._children" Sequence="10">
            <CommandUIDefinition>
              <Button Id="vps.Form.quote.MainTab.Actions.Button.Seek" Command="vps.Form.quote.MainTab.Actions.Button.Seek.Command" LabelText="$LocLabels:vps.Form.quote.MainTab.Actions.Button.Seek.LabelText" ToolTipTitle="$LocLabels:vps.Form.quote.MainTab.Actions.Button.Seek.LabelText" ToolTipDescription="$LocLabels:vps.Form.quote.MainTab.Actions.Button.Seek.ToolTip" TemplateAlias="o1" Image16by16="$webresource:new_seekdiscount16" Image32by32="$webresource:new_seekdiscount32" />
            </CommandUIDefinition>
          </CustomAction>
        </CustomActions>
        <Templates>
          <RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
        </Templates>
        <CommandDefinitions>
          <CommandDefinition Id="vps.Form.quote.MainTab.Actions.Button.Approve.Command">
            <EnableRules>
              <EnableRule Id="vps.Form.quote.CheckApprovalDiscountPercentageValue.EnableRule" />
            </EnableRules>
            <DisplayRules>
              <DisplayRule Id="vps.Form.quote.CheckApprovalDiscountPercentageValue.DisplayRule" />
            </DisplayRules>
            <Actions>
              <JavaScriptFunction Library="$webresource:new_vpsquote" FunctionName="approvediscountrequest" />
            </Actions>
          </CommandDefinition>
          <CommandDefinition Id="vps.Form.quote.MainTab.Actions.Button.Reject.Command">
            <EnableRules>
              <EnableRule Id="vps.Form.quote.CheckRejectDiscountPercentageValue.EnableRule" />
            </EnableRules>
            <DisplayRules>
              <DisplayRule Id="vps.Form.quote.CheckRejectDiscountPercentageValue.DisplayRule" />
            </DisplayRules>
            <Actions>
              <JavaScriptFunction Library="$webresource:new_vpsquote" FunctionName="rejectdiscountrequest" />
            </Actions>
          </CommandDefinition>
          <CommandDefinition Id="vps.Form.quote.MainTab.Actions.Button.Seek.Command">
            <EnableRules>
              <EnableRule Id="vps.Form.quote.CheckDiscountPercentageValue.EnableRule" />
            </EnableRules>
            <DisplayRules>
              <DisplayRule Id="vps.Form.quote.CheckDiscountPercentageValue.DisplayRule" />
            </DisplayRules>
            <Actions>
              <JavaScriptFunction Library="$webresource:new_vpsquote" FunctionName="seekapprovalfordiscount" />
            </Actions>
          </CommandDefinition>
        </CommandDefinitions>
        <RuleDefinitions>
          <TabDisplayRules />
          <DisplayRules>
            <DisplayRule Id="vps.Form.quote.CheckApprovalDiscountPercentageValue.DisplayRule">
              <FormStateRule State="Create" InvertResult="true" />
            </DisplayRule>
            <DisplayRule Id="vps.Form.quote.CheckDiscountPercentageValue.DisplayRule">
              <FormStateRule State="Create" InvertResult="true" />
            </DisplayRule>
            <DisplayRule Id="vps.Form.quote.CheckRejectDiscountPercentageValue.DisplayRule">
              <FormStateRule State="Create" InvertResult="true" />
            </DisplayRule>
          </DisplayRules>
          <EnableRules>
            <EnableRule Id="vps.Form.quote.CheckApprovalDiscountPercentageValue.EnableRule">            
              <CustomRule Library="$webresource:new_vpsquote" FunctionName="CustomRuleForApproveReject" Default="true" />
            </EnableRule>
            <EnableRule Id="vps.Form.quote.CheckDiscountPercentageValue.EnableRule">
              <ValueRule Field="discountpercentage" Value="null" InvertResult="true" />
              <CustomRule Library="$webresource:new_vpsquote" FunctionName="QuoteDiscountOnChange" Default="true" />
            </EnableRule>
            <EnableRule Id="vps.Form.quote.CheckRejectDiscountPercentageValue.EnableRule">            
              <CustomRule Library="$webresource:new_vpsquote" FunctionName="CustomRuleForApproveReject" Default="true" />
            </EnableRule>
          </EnableRules>
        </RuleDefinitions>
        <LocLabels>
          <LocLabel Id="vps.Form.quote.MainTab.Actions.Button.Approve.LabelText">
            <Titles>
              <Title languagecode="1033" description="Approve Discount" />
            </Titles>
          </LocLabel>
          <LocLabel Id="vps.Form.quote.MainTab.Actions.Button.Approve.ToolTip">
            <Titles>
              <Title languagecode="1033" description="Approve discount request" />
            </Titles>
          </LocLabel>
          <LocLabel Id="vps.Form.quote.MainTab.Actions.Button.Reject.LabelText">
            <Titles>
              <Title languagecode="1033" description="Reject Discount" />
            </Titles>
          </LocLabel>
          <LocLabel Id="vps.Form.quote.MainTab.Actions.Button.Reject.ToolTip">
            <Titles>
              <Title languagecode="1033" description="Reject discount request" />
            </Titles>
          </LocLabel>
          <LocLabel Id="vps.Form.quote.MainTab.Actions.Button.Seek.LabelText">
            <Titles>
              <Title languagecode="1033" description="Seek Discount" />
            </Titles>
          </LocLabel>
          <LocLabel Id="vps.Form.quote.MainTab.Actions.Button.Seek.ToolTip">
            <Titles>
              <Title languagecode="1033" description="Seek approval for discount" />
            </Titles>
          </LocLabel>
        </LocLabels>
      </RibbonDiffXml>


No comments:

Split the String values with a special character in MS Flow to convert this into Array

 Many times we have a requirement to prepare the Mailing address for some of the documents, suppose there are Address Line1, Address Line2, ...