Liferay DXP 2026.Q4    |    Release Webinar: 18 November 2026    |    Replay coming soon! 

Blogs

Setting guest permissions with JSON-WS

Allen Ziegenfus
Allen Ziegenfus
阅读少于一分钟

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. 

 

 

 

 

 

 

页面评论

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...

未找到结果

More Blog Entries...

Himanshu Chauhan
十一月 20, 2026
Tony Lim
十一月 19, 2026