DEVCON 2026    |    2-5 November 2026 – QEII Centre – London, UK    |    Register now! 

Blogs

Setting guest permissions with JSON-WS

Allen Ziegenfus
Allen Ziegenfus
Lesen in unter einer Minute

Through Liferay's JSON-WS interface it is possible to automate tasks that might otherwise take lots of time through Liferay portal's GUI interface. 

For example for my work I often need to create a set of DDL record sets. By using the method "/ddlrecordset/add-record-set" it is possible to create these through JSON-WS from either a website or any other JSON client. 

But what if you also need to set permissions for these created record sets? For this particular use case I would like the DDL recordsets to be publicly accessible without having to click through the permissions settings for each one. 

ServiceContext to the rescue!

Luckily in this particular case it is possible to use ServiceContext settings to modify the default permissions that are set. By adding this extra parameter to the JSON-WS call, guest view permissions are added to any objects created:

serviceContext.addGuestPermissions=true

The source code for how Liferay maps these ServiceContext parameters can be found in com.liferay.portal.service.ServiceContextUtil. It appears as if you can also set custom guest permissions settings by using the guestPermissions parameter, although I have not been able to get an example of this to work yet. 

 

 

 

 

 

 

Seitenkommentare

A JavaScript working example would be really appreciated.

For example, the following does not work:

Liferay.Service(   '/ddlrecord/add-record',   {     p_auth: Liferay.authToken,     groupId: Liferay.ThemeDisplay.getScopeGroupId(),     recordSetId: 123456,     displayIndex: 0,     fieldsMap: {name: 'Alex', surname: 'Green'},     serviceContext: 'serviceContext.addGuestPermissions=true'     },   function(obj) {     console.log(obj);   } );

What is the correct syntax to set the serviceContext?

Thank you.

Related Assets...

Keine Ergebnisse gefunden

More Blog Entries...

Ben Turner
September 02, 2026
David H Nebinger
August 18, 2026
David H Nebinger
August 16, 2026