I work in a farm environment and i want to add a CustomAction
in a specific SPList
. The list is created programmatically, so i cannot know the ID
. For that i tried to register the action with RegistrationId="{$ListId:Lists/MyList;}"
.
<CustomAction
Id="MyCustomAction"
Location="CommandUI.Ribbon.ListView"
RegistrationType="List"
RegistrationId="{$ListId:Lists/MyList;}">
...
</CustomAction>
As i read and figure out, there is a bug in farm environment and i cannot register the action this way. I decided to add the action programmatically
SPUserCustomAction action = splist.UserCustomActions.Add();
action.Location = "CommandUI.Ribbon.ListView";
action.CommandUIExtension = @"
<CommandUIExtension xmlns='http://schemas.microsoft.com/sharepoint/'>
<CommandUIDefinitions>
<CommandUIDefinition Location='Ribbon.ListItem.Actions.Controls._children'>
<Button
Id='MyCustomActionButton'
Command='MyCustomActionCommand'
Image16by16='/_images/info_16x16.png'
Image32by32='/_images/info_32x32.png'
LabelText='$Resources:MyResources,Title;'
TemplateAlias='o1'
Sequence='25'
/>
</CommandUIDefinition>
</CommandUIDefinitions>
...
</CommandUIExtension>
";
action.Update();
Now action is registered successfully but the problem is with the button label text. How it can be localized through code?
EDIT
There is the property CommandUIExtensionResource
in SPUserCustomAction
, that i suppose i could use, but i cannot find any example. I have use TitleResource
in SPList
, but the same usage in this case does not work.