2012年2月11日土曜日

セキュリティロールによるリボンの表示制御 第2回

4.リボンをカスタマイズします。

4-1.リボンのカスタマイズに使うツール
・Ribbon Browser
・XML Notepad
・Ribbon Editor

Ribbon Browserで、取引先企業のグリッドリボン、ビュータブのIdを確認します。
「Mscrm.HomepageGrid.account.View.Groups」となっています。










次に、取引先企業エンティティを含むソリューションを作ってエクスポートして、Xml Notepadでリボンを編集します。

4-2.リボン編集

//RibbonDiffXml/CustomActionsに、「帳票」グループと二つの帳票ボタンを定義します。
・Group
<CustomAction Id = "Mscrm.HomepageGrid.account.View.Tyohyo" Location = "Mscrm.HomepageGrid.account.View.Groups._children">
<CommandUIDefinition>
<Group Command = "Mscrm.Enabled" Id = "Mscrm.HomepageGrid.account.View.Tyohyo_Group" Image32by32Popup = "/_imgs/advfind/progress.gif" Sequence = "40" Template = "Mscrm.Templates.3" Title = "帳票">
<Controls Id = "Mscrm.HomepageGrid.account.View.Tyohyo.Controls">
 <Button Alt = "帳票A" Command = "Mscrm.TyohyoA" CommandType = "General" Id = "Mscrm.HomepageGrid.account.View.TyohyoA" Image16by16 = "/_imgs/advfind/and.gif" Image32by32 = "/_imgs/advfind/progress.gif" LabelText = "帳票A" Sequence = "10" TemplateAlias = "o1" ToolTipDescription = "帳票Aを出力します。" ToolTipTitle = "帳票A"/>
 <Button Alt = "帳票B" Command = "Mscrm.TyohyoB" CommandType = "General" Id = "Mscrm.HomepageGrid.account.View.TyohyoB" Image16by16 = "/_imgs/advfind/and.gif" Image32by32 = "/_imgs/advfind/progress.gif" LabelText = "帳票B" Sequence = "20" TemplateAlias = "o1" ToolTipDescription = "帳票Bを出力します。" ToolTipTitle = "帳票B"/>
 </Controls>
 </Group>
 </CommandUIDefinition>
 </CustomAction>

・MaxSize
<CustomAction Id = "Mscrm.HomepageGrid.account.View.Scaling_MaxSize.CustomAction" Location = "Mscrm.HomepageGrid.account.View.Scaling._children">
<CommandUIDefinition>
 <MaxSize GroupId = "Mscrm.HomepageGrid.account.View.Tyohyo_Group" Id = "Mscrm.HomepageGrid.account.View.Tyohyo_MaxSize" Sequence = "15" Size = "Large"/>
 </CommandUIDefinition>
 </CustomAction>

・Scale
 <CustomAction Id = "Mscrm.HomepageGrid.account.View.Scaling_Scale.CustomAction" Location = "Mscrm.HomepageGrid.account.View.Scaling._children">
<CommandUIDefinition>
 <Scale GroupId = "Mscrm.HomepageGrid.account.View.Tyohyo_Group" Id = "Mscrm.HomepageGrid.account.View.Tyohyo_Scale" Sequence = "55" Size = "Popup"/>
 </CommandUIDefinition>
 </CustomAction>

//RibbonDiffXml/CommandDefinitionsに、コマンドを定義します。
<CommandDefinition Id = "Mscrm.TyohyoA">
 <EnableRules/>
<DisplayRules>
 <DisplayRule Id = "Mscrm.TyohyoA_Show"/>
 </DisplayRules>
 <Actions/>
 </CommandDefinition>
<CommandDefinition Id = "Mscrm.TyohyoB">
 <EnableRules/>
<DisplayRules>
 <DisplayRule Id = "Mscrm.TyohyoB_Show"/>
 </DisplayRules>
 <Actions/>
 </CommandDefinition>

//RibbonDiffXml/RuleDefinitions/DisplayRulesに、表示ルールを定義します。
 <DisplayRule Id = "Mscrm.TyohyoA_Show">
 <EntityPrivilegeRule Default = "false" InvertResult = "false" EntityName = "new_tyohyoa" PrivilegeDepth = "Global" PrivilegeType = "Read"/>
 </DisplayRule>
<DisplayRule Id = "Mscrm.TyohyoB_Show">
 <EntityPrivilegeRule Default = "false" InvertResult = "false" EntityName = "new_tyohyob" PrivilegeDepth = "Global" PrivilegeType = "Read"/>
 </DisplayRule>

修正が終わったら、ソリューションをインポートして公開します。
※追加した二つのボタンがなぜかDisable状態になった場合に、Ribbon Editorでもう一度公開すれば直ります。

5.動作確認します。

・システム管理者でログインした場合、帳票Aボタン、帳票Bボタンは両方表示されます。

・ユーザAでログインした場合、帳票Aボタンのみ表示されます。

・ユーザBでログインした場合、帳票Bボタンのみ表示されます。
以上

0 件のコメント:

コメントを投稿