Note that there are some explanatory texts on larger screens.

plurals
  1. PONo Role exists with the key {companyId=1, name=Owner} error in liferay portlet
    primarykey
    data
    text
    <p>I'm using Service Builder in my portlet. Here is my addProduct method in <code>PRProductLocalServiceBaseImpl</code>:</p> <pre class="lang-java prettyprint-override"><code>public class PRProductLocalServiceImpl extends PRProductLocalServiceBaseImpl { public PRProduct addProduct(long companyID, long groupID, String productName, String serialNumber, long userID) throws SystemException, PortalException{ PRProduct product = prProductPersistence.create(counterLocalService.increment(PRProduct.class.getName())); resourceLocalService.addResources(companyID, groupID, userID, PRProduct.class.getName(), product.getPrimaryKey(), false, true, true); product.setProductName(productName); product.setSerialNumber(serialNumber); product.setCompanyId(companyID); product.setGroupId(groupID); return prProductPersistence.update(product, false); } } </code></pre> <p>When I call this method from my portlet class and pass 1 as companyID it gives "No Role exists with the key {companyId=1, name=Owner}". and here is my portlet class:</p> <pre class="lang-java prettyprint-override"><code>public void addProduct(ActionRequest actionReaquest, ActionResponse actionResponse) { PortletSession session = actionReaquest.getPortletSession(); try { String productName = actionReaquest.getParameter("productName"); String userID = actionReaquest.getParameter("userID"); String companyID = actionReaquest.getParameter("companyID"); String groupID = actionReaquest.getParameter("groupID"); String serialNumber = actionReaquest.getParameter("serialNumber"); PRProduct product = PRProductLocalServiceUtil.addProduct(Long.parseLong(companyID), Long.parseLong(groupID), productName, serialNumber, Long.parseLong(userID)); session.setAttribute("errorMessage", "Product added successfully"); actionResponse.setRenderParameter("jspPage", "/ProductAdded.jsp"); } catch(Exception e) { session.setAttribute("errorMessage", e.getMessage()); actionResponse.setRenderParameter("jspPage", "/ProductAdded.jsp"); } } </code></pre> <p>Can any body help? Any help is appreciated in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload