Groovy language - change staging friendly url

BRODY HIGGS JR, modified 4 Years ago. Junior Member Posts: 61 Join Date: 5/16/14 Recent Posts

I can change ‘Site Friendly URL’ with the Groovy language code below, but I would like to change ‘Staging Friendly URL’.

import com.liferay.portal.service.GroupLocalServiceUtil;

long liveGroupId = siteidhere;

out.println(GroupLocalServiceUtil.updateFriendlyURL(siteidhere,'/sitename1-staging'))

Reference: GroupLocalServiceUtil (Liferay 7.0.10 portal-kernel API)

thumbnail
Russell Bohl, modified 4 Years ago. Expert Posts: 308 Join Date: 2/13/13 Recent Posts

Hi Brody, try getting the stagingGroup from the group with the siteId you have, and changing its friendly URL:

import com.liferay.portal.kernel.service.*;
import com.liferay.portal.kernel.model.*;

Group site = GroupLocalServiceUtil.getGroup(SITEID);

Group stagingSite = site.getStagingGroup();

GroupLocalServiceUtil.updateFriendlyURL(stagingSite.getGroupId(), "/edited-guest-staging");