3 Replies Latest reply on Jun 18, 2010 2:45 PM by juanmaorta

    Change name of publishedcollection when creating or editing

    Allen Gambrell

      I need to change the name of the publishcollection when the collection is created or edited. This is to make sure the collection name matchs the name of the one on the remote server. I have tried the following code and it executes ok, but in the end the name of the collection is not changed.

       

      here is the code

       

      function publishServiceProvider.updateCollectionSettings( publishSettings, info )      

       

          local colname = "This is my new collection name"
          LrLibLogger.outputToLog( colname )
          catalog:withWriteAccessDo( "Set name", function ()
              info.publishedCollection:setName( colname )
              LrLibLogger.outputToLog(info.publishedCollection:getName()) -- outputs the old name and not the new one
          end)  
         
      end

       

      After running this the collection name is still the old one.

        • 1. Re: Change name of publishedcollection when creating or editing
          Allen Gambrell Level 1

          I tried it another way and it changed it for a second then it went right back.

           

          function publishServiceProvider.updateCollectionSettings( publishSettings, info )

          local colname = "This is my new collection name"
              LrLibLogger.outputToLog( colname )
             
              local pubcol = catalog:getPublishedCollectionByLocalIdentifier( info.publishedCollection.localIdentifier )
              catalog:withWriteAccessDo( "Set name", function ()
                  pubcol:setName( colname )
              info.name = colname
                  LrLibLogger.outputToLog(pubcol:getName()) -- outputs the old name and not the new one
              end)   
             
          end

          • 2. Re: Change name of publishedcollection when creating or editing
            Drarvik Adobe Employee

            Looks like the name in the 'Edit collection...' dialog gets 'committed' after the name you set programmatically in your plug-in code. Thus the momentary effect you observed.

            • 3. Re: Change name of publishedcollection when creating or editing
              juanmaorta

              Hi Allen,

               

              I've tested your second version of your code, and although I can't find why the name isn't fixed, I get an error, only when creating a new collection:

              "We can only wait from within a task"

               

              I found this at the Adobe documentation for pubCollection:getName():

              "This function must be called from within an asynchronous task started using LrTasks. Must not be called from within the same catalog:with___WriteAccessDo gate in which the collection object was created."

               

              I'm very new to Lua and LR development, but I hope this helps.

               

              Regards,

               

              Juanma