3 Replies Latest reply on Jul 1, 2011 6:21 PM by areohbee

    Getting Values from viewForCollectionSettings

    sandwicense Level 1

      For my publish service, I defined a UI using the publishServiceProvider.viewForCollectionSettings function.  I have a few text boxes where the user can specify a few settings.  When the user saves the collection, I want to be able to retrieve what the user entered and pass those values to the web server.  I've done this successfully using the endDialogForCollectionSettings function:


      function publishServiceProvider.endDialogForCollectionSettings(publishSettings, info)
           local tbl = info.pluginContext
           for i, v in tbl:pairs() do
                logger:trace(tostring(i).."              "..tostring(v))


      According to the documentation, endDialog... is a blocking call and I should not update the server from that function, but instead use updateCollectionSettings. The problem is, the info param does not receive the pluginContext from the viewFor...  function.


      The only way I can think of accomplishing this task, is to store it as preferences and then read the preferences.  What is the best way to do retrieve the values the user entered in the dialog?  Also just to confirm, when storing them, so they are persistent (even after LR is exited), should I store them by using the LrPrefs namepace?

        • 1. Re: Getting Values from viewForCollectionSettings
          sandwicense Level 1

          I have tried a lot of different things in the past 6 hours.  I figure I have to first save the settings first in the endDialogForCollectionSettings function, then retrive them in the updateCollectionSettings function, so I can send them to the web server via a POST request.


          Here's the main piece of the code for the endDialogForCollectionSettings function;


          catalog:withPrivateWriteAccessDo( function( context )
                              publishedCollection:setCollectionSettings( settings )
                         end )


          The problem now is, how do I reference the publish collection that I am currently dealing with?  The documentation says that endDialogForCollectionSettings returns a table called "info" containing "publishedCollection", which is a LrPublishedCollection object.  That seems right too me.  However, "publishedCollection" is always nil.  Furthermore, it is only nil, when trying to create a new collection; however, it works perfectly fine when editing an existing collection.  I seriously can't think of another way to set the collection settings.  As a side note: within the same "info" table that is returned by LR, the "collectionSettings" field is also nil, except when editing an existing collection.  There has to be a way, because LR's built-in Facebook plugin, obviously does something similar, using the same publishServiceProvider methods.



          • 2. Re: Getting Values from viewForCollectionSettings
            sandwicense Level 1

            After hours of thinking and trial and error, I finally solved my issue by rewriting based on an example I found.  I just wish the documentation was more in depth and clear.


            The main problem was improper binding of the UI.  The viewForCollectionSettings function should like this:


            function publishServiceProvider.viewForCollectionSettings(f, publishSettings, info)
                 return = f:group_box {
                      title = "Preferences",
                      size = 'small',
                      fill_horizontal = 1,
                      bind_to_object = assert( info.collectionSettings ),


            The important part is the "bind_to_object = assert( info.collectionSettings )" line of code.  When I was having the issue, I believe I was binding the UI to the function context I had created, insteadd of binding it to the LrObservableTable provided by the info param.

            • 3. Re: Getting Values from viewForCollectionSettings
              areohbee Level 6

              I'm always in favor of clearer documentation, however I think bind-to object is *always* an observable property table.