我试图隐藏/显示CRM 2011
功能区中定义的条件的按钮JavaScript
。JavaScript 函数返回true/false
. 所以我不想将 XML 更改为Hide/Show
按钮。
我试图按如下方式进行操作,但没有任何运气。谁能建议我正确的方法。
提前致谢
<RibbonDiffXml>
<CustomActions>
<CustomAction Id="Email.Form.email.MainTab.Send.CustomAction" Location="Mscrm.Form.email.Send" Sequence="2">
<CommandUIDefinition>
<Button Id="Mscrm.Form.email.Send" Command="Mscrm.Form.email.Send_Custom" Sequence="1" Alt="$Resources:Ribbon.Form.email.MainTab.Actions.Send" LabelText="$Resources:Ribbon.Form.email.MainTab.Actions.Send" Image16by16="/_imgs/SFA/SendAsEmail_16.png" Image32by32="/_imgs/SFA/SendAsEmail_32.png" TemplateAlias="o1" ToolTipTitle="$Resources:Mscrm_Form_email_MainTab_Actions_Send_ToolTipTitle" ToolTipDescription="$Resources:Mscrm_Form_email_MainTab_Actions_Send_ToolTipDescription" />
</CommandUIDefinition>
</CustomAction>
</CustomActions>
<Templates>
<RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
</Templates>
<CommandDefinitions>
<CommandDefinition Id="Mscrm.Form.email.Send_Custom">
<EnableRules/>
<DisplayRules>
<DisplayRule Id="Mscrm.CanWritePrimary" />
<DisplayRule Id="Mscrm.Form.email.InDraftOrFailedState" />
<DisplayRule Id="Mscrm.Form.email.Send.DisplayRule" />
</DisplayRules>
<Actions>
<JavaScriptFunction FunctionName="HideSendEmailButton" Library="$webresource:sandbox_email.js" />
</Actions>
</CommandDefinition>
</CommandDefinitions>
<RuleDefinitions>
<TabDisplayRules />
<DisplayRules>
<DisplayRule Id="Mscrm.Form.email.Send.DisplayRule">
<ValueRule Field="new_type" Value="false" InvertResult="false" />
</DisplayRule>
</DisplayRules>
<EnableRules />
</RuleDefinitions>
<LocLabels />
</RibbonDiffXml>
Javascript
function HideSendEmailButton() {
// Query for full name of the current user
var userId = Xrm.Page.context.getUserId();
if(userId == '---some Id---')
{
return true;
}
else
{
return false;
}
}