Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

Disable or Display the New and Add Existing button in Ribborn.

$
0
0

I try to disable the Add Existing button, just like I configurate xml for custom button I ever done before.

The following is my fragment of Xml:

---------------------------------------------------------------------------------------------------------------------

          <CustomAction Id="Mscrm.SubGrid.salesorder.AddExistingStandard.CustomAction" Location="Mscrm.SubGrid.salesorder.AddExistingStandard">
            <CommandUIDefinition>
              <Button Id="Mscrm.SubGrid.salesorder.AddExistingStandard" Command="Mscrm.AddExistingRecordFromSubGridStandard" Sequence="30" LabelText="$Resources(EntityDisplayName):Ribbon.SubGrid.AddExisting" 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>

---------------------------------------------------------------------------------------------------------------------

          <CommandDefinition Id="Mscrm.AddExistingRecordFromSubGridStandard">
            <EnableRules>
              <EnableRule Id="Mscrm.AppendToPrimary" />
              <EnableRule Id="Mscrm.EntityFormIsEnabled" />
              <EnableRule Id="Mscrm.AddExistingRecordFromSubGridAssociated.Enabled.Custom"/>
            </EnableRules>
            <DisplayRules>
              <DisplayRule Id="Mscrm.AddExisting" />
              <DisplayRule Id="Mscrm.HideAddExistingThroughOpportunityForQOI" />
              <DisplayRule Id="Mscrm.ShowForOneToManyGrids" />
              <DisplayRule Id="Mscrm.AppendToPrimary" />
              <DisplayRule Id="Mscrm.AppendSelected" />
              <DisplayRule Id="Mscrm.CanWriteSelected" />
            </DisplayRules>
            <Actions>
              <JavaScriptFunction FunctionName="Mscrm.GridRibbonActions.addExistingFromSubGridStandard" Library="/_static/_common/scripts/RibbonActions.js">
                <CrmParameter Value="SelectedEntityTypeCode" />
                <CrmParameter Value="SelectedControl" />
              </JavaScriptFunction>
            </Actions>
          </CommandDefinition>

---------------------------------------------------------------------------------------------------------------------

           <DisplayRule Id="Mscrm.AddExisting">
              <ReferencingAttributeRequiredRule Default="false" InvertResult="true" />
            </DisplayRule>
            <DisplayRule Id="Mscrm.HideAddExistingThroughOpportunityForQOI">
              <FormEntityContextRule Default="false" EntityName="opportunity" InvertResult="true" />
            </DisplayRule>
            <DisplayRule Id="Mscrm.AppendToPrimary">
              <EntityPrivilegeRule AppliesTo="PrimaryEntity" PrivilegeType="AppendTo" PrivilegeDepth="Basic" />
            </DisplayRule>
            <DisplayRule Id="Mscrm.AppendSelected">
              <EntityPrivilegeRule AppliesTo="SelectedEntity" PrivilegeType="Append" PrivilegeDepth="Basic" />
            </DisplayRule>
            <DisplayRule Id="Mscrm.CanWriteSelected">
              <EntityPrivilegeRule AppliesTo="SelectedEntity" PrivilegeType="Write" PrivilegeDepth="Basic" />
            </DisplayRule>
            <DisplayRule Id="Mscrm.ShowForOneToManyGrids">
              <RelationshipTypeRule AppliesTo="SelectedEntity" RelationshipType="OneToMany" />
            </DisplayRule>
          </DisplayRules>

-----------------------------------------------------------------------------------------------------------------------------

            <EnableRule Id="Mscrm.AppendToPrimary">
              <RecordPrivilegeRule AppliesTo="PrimaryEntity" PrivilegeType="AppendTo" />
            </EnableRule>
            <EnableRule Id="Mscrm.EntityFormIsEnabled">
              <FormStateRule State="Disabled" InvertResult="true" />
            </EnableRule>

            <EnableRule Id="Mscrm.AddExistingRecordFromSubGridAssociated.Enabled.Custom">
              <CustomRule Default="false" FunctionName="EnableNewButton" Library="/CustomToolsButton/EnableButton.js">
                <CrmParameter  Value="PrimaryEntityTypeName" />
              </CustomRule>

            </EnableRule>

--------------------------------------------------------------------------------------------------

I have a EnableButton.js file under CustomToolsButton directory, the following is the function:

function EnableNewButton(PrimaryEntityTypeCode) {
    alert("heee");
    return false;
}

I want to know the funtion EnableNewButton is called,  but it can't pop up after I click the other related entity.

and the New Existing button is still be enabled.

I don't know what's wrong with it, it's so weird.

Hope someone help me,

Thanks in advance.


Viewing all articles
Browse latest Browse all 8223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>