Expiration Policy in SharePoint
-
Hi, I trying to create and attach Expiration Policy on a SharePoint Form Library. But this needs to be done programmatically in C#. Any pointers or code help on this? Appreciate your time and effort. Thanks Arut
-
Hi, I trying to create and attach Expiration Policy on a SharePoint Form Library. But this needs to be done programmatically in C#. Any pointers or code help on this? Appreciate your time and effort. Thanks Arut
-
Hi, I trying to create and attach Expiration Policy on a SharePoint Form Library. But this needs to be done programmatically in C#. Any pointers or code help on this? Appreciate your time and effort. Thanks Arut
Hello Arut, Create Custom View using SharePoint Object Model for the SharePoint Form Library and mentioned the Expiry Date using Filters in the View . You can Create Sorting,Grouping,Filtering the Items using CAML Query Builder so, better to use CAML query and create a Custom View for the library to get the expiration policy to your Custom Form Library Cheers, Regards, Siva(SharePoint Developer) Egon Software Pvt Ltd, Nagar Road,Pune.
-
Hello Arut, Create Custom View using SharePoint Object Model for the SharePoint Form Library and mentioned the Expiry Date using Filters in the View . You can Create Sorting,Grouping,Filtering the Items using CAML Query Builder so, better to use CAML query and create a Custom View for the library to get the expiration policy to your Custom Form Library Cheers, Regards, Siva(SharePoint Developer) Egon Software Pvt Ltd, Nagar Road,Pune.
Hi Siva, Thanks for the reply. But My requirement says that I'll have to create form library in 30 site collections programmatically and form library will be created in each site collection during the start of qtr thru WF. And whenever, I create the form library, I need to programmatically create expiration policy and enforce it. I guess the option you have mentioned would not be a suitable idea. Kindly throw some light if I'm missing anything. Appreciate your time and effort. Thanks Arut
-
Hi Siva, Thanks for the reply. But My requirement says that I'll have to create form library in 30 site collections programmatically and form library will be created in each site collection during the start of qtr thru WF. And whenever, I create the form library, I need to programmatically create expiration policy and enforce it. I guess the option you have mentioned would not be a suitable idea. Kindly throw some light if I'm missing anything. Appreciate your time and effort. Thanks Arut
Hello Arut, i tried your issue but ididnt get the solution for your issue arut plz let me know if you get the solution for this issue Regards, Siva
-
Hello Arut, i tried your issue but ididnt get the solution for your issue arut plz let me know if you get the solution for this issue Regards, Siva
I've figured out a solution after researching over internet: Get the default content type or the required content type in the list (This is required because SP policies can be attached only to a content Type or list items). Create an empty policy for that content type and get this policy into a new Policy object (This policy object has Expiration, Auditing etc. as its items). You need to create the custom string that holds the metadata for any policy item and add it on the expiration policy item of this policy. After adding any new item created upon this content type will hold the expiration policy. Code is as given below: SPList list = web.Lists[#Enter list name in string format here#]; SPContentType contentType = list.ContentTypes[0]; string MOSS_EXPIRATION_FEATURE_ID = "Microsoft.Office.RecordsManagement.PolicyFeatures.Expiration"; if (Policy.GetPolicy(contentType) == null) { Policy.CreatePolicy(contentType, null); } Policy policyOfContentType = Policy.GetPolicy(contentType); policyOfContentType.Name = "Expiration Policy"; policyOfContentType.Description = "This expiration policy was created for testing purpose"; policyOfContentType.Statement = "This expiration policy was created for testing purpose"; if (policyOfContentType.Items[MOSS_EXPIRATION_FEATURE_ID] == null) { string customData = string.Format("7Modifiedyears"); policyOfContentType.Items.Add(MOSS_EXPIRATION_FEATURE_ID, customData); } Note that you can obtain the custom data format if you programmatically read any expiration policy and debug it.
-
I've figured out a solution after researching over internet: Get the default content type or the required content type in the list (This is required because SP policies can be attached only to a content Type or list items). Create an empty policy for that content type and get this policy into a new Policy object (This policy object has Expiration, Auditing etc. as its items). You need to create the custom string that holds the metadata for any policy item and add it on the expiration policy item of this policy. After adding any new item created upon this content type will hold the expiration policy. Code is as given below: SPList list = web.Lists[#Enter list name in string format here#]; SPContentType contentType = list.ContentTypes[0]; string MOSS_EXPIRATION_FEATURE_ID = "Microsoft.Office.RecordsManagement.PolicyFeatures.Expiration"; if (Policy.GetPolicy(contentType) == null) { Policy.CreatePolicy(contentType, null); } Policy policyOfContentType = Policy.GetPolicy(contentType); policyOfContentType.Name = "Expiration Policy"; policyOfContentType.Description = "This expiration policy was created for testing purpose"; policyOfContentType.Statement = "This expiration policy was created for testing purpose"; if (policyOfContentType.Items[MOSS_EXPIRATION_FEATURE_ID] == null) { string customData = string.Format("7Modifiedyears"); policyOfContentType.Items.Add(MOSS_EXPIRATION_FEATURE_ID, customData); } Note that you can obtain the custom data format if you programmatically read any expiration policy and debug it.
Hello Arut, Thanks for reply. i tried but this is not working fine in my portal Regards, Siva
-
I've figured out a solution after researching over internet: Get the default content type or the required content type in the list (This is required because SP policies can be attached only to a content Type or list items). Create an empty policy for that content type and get this policy into a new Policy object (This policy object has Expiration, Auditing etc. as its items). You need to create the custom string that holds the metadata for any policy item and add it on the expiration policy item of this policy. After adding any new item created upon this content type will hold the expiration policy. Code is as given below: SPList list = web.Lists[#Enter list name in string format here#]; SPContentType contentType = list.ContentTypes[0]; string MOSS_EXPIRATION_FEATURE_ID = "Microsoft.Office.RecordsManagement.PolicyFeatures.Expiration"; if (Policy.GetPolicy(contentType) == null) { Policy.CreatePolicy(contentType, null); } Policy policyOfContentType = Policy.GetPolicy(contentType); policyOfContentType.Name = "Expiration Policy"; policyOfContentType.Description = "This expiration policy was created for testing purpose"; policyOfContentType.Statement = "This expiration policy was created for testing purpose"; if (policyOfContentType.Items[MOSS_EXPIRATION_FEATURE_ID] == null) { string customData = string.Format("7Modifiedyears"); policyOfContentType.Items.Add(MOSS_EXPIRATION_FEATURE_ID, customData); } Note that you can obtain the custom data format if you programmatically read any expiration policy and debug it.
Hello Arut, ya the main advantage of using Content Type is the one to create a Expiration Policy. After creating the Content Type you will get the Inforamation Right Management Policy Settings in the Content to Create the Expiration Policy to the Items in a List or a Library ...... :rose: we can done throught Program as mentioned the code above but this code is not working in the Portal let me try i will provide the code with Solution Package for this issue Regards, Siva
-
Hello Arut, ya the main advantage of using Content Type is the one to create a Expiration Policy. After creating the Content Type you will get the Inforamation Right Management Policy Settings in the Content to Create the Expiration Policy to the Items in a List or a Library ...... :rose: we can done throught Program as mentioned the code above but this code is not working in the Portal let me try i will provide the code with Solution Package for this issue Regards, Siva
Hi Siva, The code which I had sent you was tested by me and worked perfectly fine. Are you changing anything in the code such as the policy custom data etc. I'll have to see how you have incorporated this code in your portal to find out why it is not working. Thanks Arut
-
Hi Siva, The code which I had sent you was tested by me and worked perfectly fine. Are you changing anything in the code such as the policy custom data etc. I'll have to see how you have incorporated this code in your portal to find out why it is not working. Thanks Arut
Hello Arut, Thanks, the code is working fine in my portal now . Thanks for reply :rose: Cheers, Regards, Siva
-
Hello Arut, Thanks, the code is working fine in my portal now . Thanks for reply :rose: Cheers, Regards, Siva
Glad to help you..