I'm dynamically creating custom retention actions for information management policies. My problem is that in the retention action dropdown menu, I would like to show only some custom retention actions - specifically, custom actions that were created within the scope of the content database for the current site collection (the one we're creating a policy for):
- if I'm creating a policy for a site collection that is stored in WSS_Content1 database, I would like to display 2 additional custom actions in the drop down, "Action_1" and "Action_2";
- if I'm creating a policy for a site that is stored in WSS_Content2 database, I would like to display 3 additional custom actions in the drop down, "Action_X", "Action_Y", "Action_Z".
Right now, I use
PolicyResourceCollection.Add(policyXml); to register a policy action. This works fine, except that no matter what site collection I'm creating a policy for, all registered (farm wide?) actions appear in the drop down. In the previous example this means that I will always see 5 actions, "Action 1", "Action 2", "Action_X", "Action_Y" and "Action_Z".
Is there a way I can achieve this, i.e. only show some custom policies in the drop down or ideally register them in some scoped way?
My policy action xml looks roughly like this:
<?xml version="1.0" encoding="utf-8" ?> <p:PolicyResource id="ID01234" featureId="Microsoft.Office.RecordsManagement.PolicyFeatures.Expiration" type="Action" xmlns:p="urn:schemas-microsoft-com:office:server:policy"> <p:Name>$OPERATION_NAME$</p:Name> <p:Description>...</p:Description> <p:Publisher>PublisherName</p:Publisher> <p:AssemblyName>MyAssembly.RetentionAction, Version=126.96.36.199, Culture=neutral, PublicKeyToken=b04c63c6e5e66367</p:AssemblyName> <p:ClassName>MyAssembly.RetentionAction.Callback</p:ClassName> </p:PolicyResource>
$OPERATION_NAME$ is replaced programatically prior to adding policy action.
One thing that works is modification of the code that populates the drop down (i.e. filter the options), but this produces an unsupported SharePoint state.