Javascript API get locks info doesn't return correct value


#1

Matrix Version:5.3.4

Hello all … I am trying to use Javascript API getLocksInfo() to get information about locks hold on an asset but it doesn’t seem that I get correct return value.

The lock is currently hold by UAT One user but getLocksInfo() returns value saying that no one holds lock on the asset (screenshot below).

Here is the code I use:

js_api.getLocksInfo({
   "asset_id":"1696543",
   "screen_name":"settings",
   "dataCallback":function(data) { console.log(data); }
});

What have I done wrong? cheers.


(Bart Banda) #2

Try grabbing the locks on the details screen instead, because in Edit+ the user never grabs the locks on the settings screen.


#3

Hi Bart thank you for your response.

I have tried that with the same result. In fact I tried to get lock info on the details screen first before I tried other screen.


(Bart Banda) #4

Oh, maybe it’s not the same Asset ID it’s referring to? The Custom Form usually has a couple of dependent assets that the user gets the locks on as well, such as the Form Contents one. Maybe do a simpler check with a Standard Page, view the Details screen of it in Edit+, then call the JS API function to see who has the locks on the same asset ID’s details screen to see what yoy get?


#5

Hi Bart, I tried that and still no joy.


(Bart Banda) #6

Is the asset in the screenshot above the one you are doing the call against?

Looking at the console log in your screenshot, it looks like it might be a different asset?

Can you confirm it’s the same asset ID and also show the full request and response of the JS API call?


#7

Hi Bart, that’s the asset name for another Javascript API. I am playing with this and see what potentially I can use. That’s why I call a number of Javascript API from the same page.

Exactly, here is my code:

var info = js_api.getLineage({
    "asset_url":"https://example.com/pages/pagewithlhs",
    "significant_links_only":0,
    "dataCallback":function(data) { console.log(data[data.length - 1]); }
});

js_api.getLocksInfo({
   "asset_id":"1696543",
   "screen_name":"details",
   "dataCallback":function(data) { console.log(data); }
});

Testing Javascript API asset number is 1696543. That’s the asset that I got lock on but it doesn’t seem that getLocksInfo() return correctly.


(Bart Banda) #8

Ah, just tested it myself, and that parameter name is misleading. It’s not “screen name”, it’s “lock type”.
So the locks that get aquired on the “Details” screen are actually “attributes” and “links”.

Try something like this:

js_api.getLocksInfo({
   "asset_id":"1696543",
   "screen_name":"attributes",
   "dataCallback":function(data) { console.log(data); }
});

Will need to update the manuals to make that clear.


#9

Spot on Bart. It is very exciting to see that works.

One suggestion, I am sure many users will find it more useful if the return value will be just the asset ID of the user hold a lock on that asset and possibly the length in time format when the lock will expire, rather than a sentence that reads like this:

“attributes” locks are held by User “User Name” (#1791) for Asset “Testing Javascript API” (#1696543). This is due to expire in 9 minutes and 24 seconds

Thanks for your help.


(Bart Banda) #10

Yep, definitely. More information about the locks would certainly help. Good to hear it’s working now at least.