+ Start a Discussion
isalewisalew 

force:NavigateToSObject throws "You can't view this page" error

I am building two lightning components, one which iterates inside of a parent component. When I fire the "e.force:navigateToSObject" action based on a record Id contained in the parent component attributes, it successfully opens the record. However, when I fire the "e.force:navigateToSObject" action based on a record Id contained in the child component attributes, I receive the following error:

"You can't view this page, either because you don't have permission or because the page isn't supported on mobile devices."

I tried firing the "navigateToSObject" event directly from the child component, and also tried using a custom event to feed the recordId parameter to the parent component to throw the "navigateToSObject" event (see code sample below). Does anyone have any ideas how to resolve this?

Parent Component
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes">

  <!-- Attributes -->
  <aura:attribute name="account" type="Account" default="{'sobjectType':'Account'}"></aura:attribute>
  <aura:attribute name="products" type="ControllerClass.ProductPrice[]"></aura:attribute>

  <!-- Events -->
  <aura:handler name="openProduct" event="c:OpenProductEvt" action="c.openProduct"></aura:handler>

  <!-- PRODUCT LIST -->
  <aura:iteration items="{!v.products}" var="product">
    <c:CPQ_SSG_ContractPriceLookupItem product="{!product}"></c:CPQ_SSG_ContractPriceLookupItem>
  </aura:iteration>
  <!-- / PRODUCT LIST -->

</aura:component>

Parent Component Controller
({
	openProduct : function(cmp,evt,hlp)
	{
	  console.log('in c.openProduct');
		var recordId = evt.getParam('recordId');
		var slideDevName = evt.getParam('slideDevName');
		var navEvt = $A.get("e.force:navigateToSObject");
		navEvt.setParams({
			"recordId": recordId,
			"slideDevName": slideDevName
		});
		navEvt.fire();
	},
})

Child Component
<aura:component>

  <!-- Attributes -->
  <aura:attribute name="product" type="ControllerClass.ProductPrice" default="{'sObjectType':'ControllerClass.ProductPrice'}" description="ProductPrice container to hold Product2 and External Pricing information"></aura:attribute>

  <!-- Events -->
  <aura:registerEvent name="openProduct" type="c:OpenProductEvt" description="Notifies parent listeners to open record in list"></aura:registerEvent>

  <!-- Markup -->
  <tr class="slds-hint-parent">
    <td data-label="Product Name">
      <ui:outputURL aura:id="theProductLink" value="#" label="{!v.product.productName}" click="{!c.openUrl}"></ui:outputURL>
    </td>
  </tr>

</aura:component>

Child Component Controller
({
	openUrl: function(cmp,evt,hlp)
	{
		var product = cmp.get("v.product");
		var openEvent = cmp.getEvent("openProduct");
		openEvent.setParams({
			"recordId" : product.productId,
			"slideDevName" : "detail"
		}).fire();
	},
})

Event
<aura:event type="COMPONENT" description="Record for navigation">
  <aura:attribute name="recordId" type="String" description="Id of record to navigate to"></aura:attribute>
  <aura:attribute name="slideDevName" type="String" default="detail" description="record layout to open"></aura:attribute>
</aura:event>