9 Replies Latest reply on Nov 19, 2010 8:12 AM by PeterPow

    Store PageItem version

    PeterPow Level 1

      Hello guys,

       

      I would like to store a pageitem with all its properties and then revert it after it has been changed (Version Cue?). Is there a possibility to do this by scripting?

      Thanks

        • 1. Re: Store PageItem version
          Harbs. Level 6

          I'm not sure what you're after, but saving it as a snippet is probably your best bet...

           

          Harbs

          • 2. Re: Store PageItem version
            PeterPow Level 1

            Hello Harbs,

             

            thanks for your quick answer, but that is not exactly what I need. Here is the scenario:

             

            I would like to implement a checkout/checkin mechanism on page items. If a page item is checked out it can be freely changed (content, geometrics...). Now the user has two options:

             

            checkin page item: the document is stored with the changed page item

            undoCheckout page item: the page item has to be reverted to its previous state, including geometrics and content.

             

            Now my question is, what way is the best to do this.

            Thanks.

            • 3. Re: Store PageItem version
              Harbs. Level 6

              That's what I figured.

               

              This type of thing is best done as a plugin. You can probably do it as a script using my suggestion of saving a snippet.

               

              Here's one way to go about it:

               

              1) Export a snippet of the page item.

              2) Get the contents of the snippet file.

              3) Save that string somewhere in your document. (You can use a custom label, and even save it into the page item if deletion is not an issue. Alternatively, you can save custom labels into the doc itself.)

              4) When you need to revert the object, save the snippet string to a file, and import it to replace the page item.

               

              Harbs

              • 4. Re: Store PageItem version
                PeterPow Level 1

                The only problem with this solution is that the page item id would be changed if a new page item is created by importing the snippet, right? Or is there a way to manipulate the id to remain the same?

                • 5. Re: Store PageItem version
                  Harbs. Level 6

                  No.

                   

                  You'd have to adjust the id in whatever mechanism you use to track your "versions".

                   

                  If you don't want to go the snippet route, you could try to save all the properties of the page item in a label (or what-have-you), but that's going to be a lot more work to get it right...

                   

                  Harbs

                  • 6. Re: Store PageItem version
                    PeterPow Level 1

                    What do you mean with "You'd have to adjust the id". When I delete a page item and place another one from a snippet, the property "id" will change, and that is not possible in our environment.

                     

                    I also thought about saving all properties, but this might not be enough, because the content is not saved correctly in textframe e.g.

                     

                    But thanks anyway

                    • 7. Re: Store PageItem version
                      Harbs. Level 6

                      PeterPow wrote:

                       

                      What do you mean with "You'd have to adjust the id". When I delete a page item and place another one from a snippet, the property "id" will change, and that is not possible in our environment.

                      I know nothing about your system. I assume you have some kind of lookup to identify page items and their versions


                      When the id changes you would need to change the reference in your lookup (if one exists). I don't see why that's not possible, but then again, I know nothing about your system...

                       

                      Harbs

                      • 8. Re: Store PageItem version
                        PeterPow Level 1

                        I now understand what you mean. Well changing all references is quite overloaded But maybe I will try to find a way through saving the properties instead. Thanks!

                        • 9. Re: Store PageItem version
                          PeterPow Level 1

                          I solved the problem by saving necessary properties and restore them later on, this seems to work.