Page 1 of 1

try catch with jsCallback

Posted: Wed Sep 07, 2022 11:25 am
by rodneyt
You can do something like this at Chrome console

Code: Select all

try { ...your javascript here... } catch (error) {'0'}
.. but it seems JSCallback doesn't like try/catch. Has anyone observed this before, perhaps I am doing something wrong?

Rod

Re: try catch with jsCallback

Posted: Sat Sep 10, 2022 1:59 am
by rodneyt
The solution is to wrap in a function like this

Code: Select all

function getActiveOB3EntityName () {
    let tDocName
    try {
            tDocName = io.openbook.viewport.Application.getActiveTab().record.data.properties.title
        }
            catch (error) {
            tDocName ='error';
    }
    return tDocName
}

getActiveOB3EntityName();