Error "withWriteAccessDo " caused by catalog:getCollectionByLocalIdentifier

Community Beginner ,
Jan 04, 2022 Jan 04, 2022

Copy link to clipboard

Copied

Hello everybody,

I am new to the world of Lua development and plugins with the Lightroom SDK (version LrC_11.0_202110120910-0bccc70d.release_SDK)

I'm trying to make a plugin that allows you to retrieve a collection from its id, but I get the following error:

Can't get collection information after creating collection inside the same withWriteAccessDo function


Here is my program:

local Require = require "Require" .path ("../debuggingtoolkit.lrdevplugin").reload ()
local Debug = require "Debug" .init ()
require "strict"
local LrApplication = import 'LrApplication'
local LrDialogs = import 'LrDialogs'
local LrTasks = import 'LrTasks'

local function main ()
local catalog = LrApplication.activeCatalog ()
local collections = catalog: getChildCollections ()
LrDialogs.message ("Collection list", catalog: getCollectionByLocalIdentifier ("387") .. collections [1]: getName ())
Debug.pauseIfAsked ()
end

LrTasks.startAsyncTask (Debug.showErrors (main))

 

My problem is caused by this line :

LrDialogs.message ("Collection list", catalog: getCollectionByLocalIdentifier ("387") .. collections [1]: getName ())


Can you explain to me how to do it please because I do not understand this error well?

I thank you in advance.

Arno

TOPICS
SDK

Views

46

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jan 04, 2022 Jan 04, 2022
That one threw me for a bit. The problem is with this expression: catalog:getCollectionByLocalIdentifier ("387") That method takes a number as an argument, not a string. It's a LR bug that it throws that weird error message when you pass a string.  So try this: catalog:getCollectionByLocalIdentifier (387)

Likes

Translate

Translate
LEGEND ,
Jan 04, 2022 Jan 04, 2022

Copy link to clipboard

Copied

That one threw me for a bit. The problem is with this expression:

 

catalog:getCollectionByLocalIdentifier ("387")

 

That method takes a number as an argument, not a string. It's a LR bug that it throws that weird error message when you pass a string.  So try this:

 

catalog:getCollectionByLocalIdentifier (387)

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 04, 2022 Jan 04, 2022

Copy link to clipboard

Copied

LATEST

omg I had already tried this fix, logical, but I had the error "assertion failed" because I had written catalog: getCollectionByLocalIdentifier (387) .getName () out of habit of having other languages :'(

 

Thx John! 🙂

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines