Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. SharePoint
  4. Expiration Policy in SharePoint

Expiration Policy in SharePoint

Scheduled Pinned Locked Moved SharePoint
csharpsharepointhelpquestion
11 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    arut jothi
    wrote on last edited by
    #1

    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

    N S 2 Replies Last reply
    0
    • A arut jothi

      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

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      here[^]


      I know the language. I've read a book. - _Madmatt

      1 Reply Last reply
      0
      • A arut jothi

        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

        S Offline
        S Offline
        siva sharepoint
        wrote on last edited by
        #3

        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.

        A 1 Reply Last reply
        0
        • S siva sharepoint

          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.

          A Offline
          A Offline
          arut jothi
          wrote on last edited by
          #4

          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

          S 1 Reply Last reply
          0
          • A arut jothi

            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

            S Offline
            S Offline
            siva sharepoint
            wrote on last edited by
            #5

            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

            A 1 Reply Last reply
            0
            • S siva sharepoint

              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

              A Offline
              A Offline
              arut jothi
              wrote on last edited by
              #6

              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.

              S 2 Replies Last reply
              0
              • A arut jothi

                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.

                S Offline
                S Offline
                siva sharepoint
                wrote on last edited by
                #7

                Hello Arut, Thanks for reply. i tried but this is not working fine in my portal Regards, Siva

                1 Reply Last reply
                0
                • A arut jothi

                  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.

                  S Offline
                  S Offline
                  siva sharepoint
                  wrote on last edited by
                  #8

                  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

                  A 1 Reply Last reply
                  0
                  • S siva sharepoint

                    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

                    A Offline
                    A Offline
                    arut jothi
                    wrote on last edited by
                    #9

                    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

                    S 1 Reply Last reply
                    0
                    • A arut jothi

                      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

                      S Offline
                      S Offline
                      siva sharepoint
                      wrote on last edited by
                      #10

                      Hello Arut, Thanks, the code is working fine in my portal now . Thanks for reply :rose: Cheers, Regards, Siva

                      A 1 Reply Last reply
                      0
                      • S siva sharepoint

                        Hello Arut, Thanks, the code is working fine in my portal now . Thanks for reply :rose: Cheers, Regards, Siva

                        A Offline
                        A Offline
                        arut jothi
                        wrote on last edited by
                        #11

                        Glad to help you..

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups