0 Replies Latest reply on Aug 15, 2010 3:48 PM by Allen Gambrell

    Cannot add more the 3 pubcollections at a time

    Allen Gambrell Level 1

      I am trying to programly add publish collections and then add images to them.

       

      If I try to add more the 3 inside one withWriteAccessDo block then on the 4th one I get a nil value. It will work except where it trys to create more than 3 collections!

       

      This is just a example of the code, not the full verion

      LrTasks.startAsyncTask( function ()

           catalog:withWriteAccessDo( "Add Collections", function ()

                local parentset = mainset

                for i,photo in ipairs(photos) do

                     parentset = publishService:createPublishedCollectionSet(word, parentset, true)
                     photocollection = publishService:createPublishedCollection(word, parentset, true)

                     photocollection:addPhotos({photo})

                end

           end)

      end)

       

      But if I use a withWriteAccessDo block for each image then it works correctly, except that it is much slower and I have lots of undo points vs one undo point in the first.

       

      example

       

      LrTasks.startAsyncTask( function ()

           local parentset = mainset

           for i,photo in ipairs(photos) do

                catalog:withWriteAccessDo( "Add Collections", function ()

                     parentset = publishService:createPublishedCollectionSet(word, parentset, true)
                     photocollection = publishService:createPublishedCollection(word, parentset, true)

                     photocollection:addPhotos({photo})

                end)

           end

      end)

       

      I also tried using withProlongedWriteAccessDo with the same problem.

       

      I have been trying to figure this out for a while with no luck. Is it a bug?