SP007
SP007

Reputation: 1921

Ribbon button should be hidden based on lead status - CRM 2011

I have custom button in lead ribbon. The custom button should be hidden when lead is qualified. How can I do that? Can any one please explain. I appreciate.

Upvotes: 1

Views: 3444

Answers (1)

Peter Majeed
Peter Majeed

Reputation: 5362

You can actually accomplish this entirely with built-in DisplayRule functionality. When a Lead is qualified, the StatusCode property is set to "Qualified", which translates into an OptionSet value of "3". You can check for the value of this property in a ValueRule and display/hide the control appropriately. I can think of two ways to achieve this:

Erik Pool's Visual Ribbon Editor Lead

RibbonXml

<RibbonDiffXml>
  <CustomActions>
    <CustomAction Id="CompanyName.Form.lead.MainTab.Actions.Sample.CustomAction" Location="Mscrm.Form.lead.MainTab.Actions.Controls._children" Sequence="41">
      <CommandUIDefinition>
        <Button Id="CompanyName.Form.lead.MainTab.Actions.Sample" Command="CompanyName.Form.lead.MainTab.Actions.Sample.Command" Sequence="29" ToolTipTitle="$LocLabels:CompanyName.Form.lead.MainTab.Actions.Sample.LabelText" LabelText="$LocLabels:CompanyName.Form.lead.MainTab.Actions.Sample.LabelText" ToolTipDescription="$LocLabels:CompanyName.Form.lead.MainTab.Actions.Sample.Description" TemplateAlias="isv" />
      </CommandUIDefinition>
    </CustomAction>
  </CustomActions>
  <Templates>
    <RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
  </Templates>
  <CommandDefinitions>
    <CommandDefinition Id="CompanyName.Form.lead.MainTab.Actions.Sample.Command">
      <EnableRules />
      <DisplayRules>
        <DisplayRule Id="CompanyName.Form.lead.MainTab.Actions.Sample.Command.DisplayRule.ValueRule" />
      </DisplayRules>
      <Actions>
        <Url Address="http://www.bing.com" />
      </Actions>
    </CommandDefinition>
  </CommandDefinitions>
  <RuleDefinitions>
    <TabDisplayRules />
    <DisplayRules>
      <DisplayRule Id="CompanyName.Form.lead.MainTab.Actions.Sample.Command.DisplayRule.ValueRule">
        <ValueRule Field="statuscode" Value="3" />
      </DisplayRule>
    </DisplayRules>
    <EnableRules />
  </RuleDefinitions>
  <LocLabels>
    <LocLabel Id="CompanyName.Form.lead.MainTab.Actions.Sample.LabelText">
      <Titles>
        <Title languagecode="1033" description="Sample" />
      </Titles>
    </LocLabel>
    <LocLabel Id="CompanyName.Form.lead.MainTab.Actions.Sample.Description">
      <Titles>
        <Title languagecode="1033" description="Sample Description" />
      </Titles>
    </LocLabel>
  </LocLabels>
</RibbonDiffXml>

Upvotes: 2

Related Questions