1

I have a simple Product2 details component.

Component

<aura:component implements="lightning:isUrlAddressable, flexipage:availableForAllPageTypes">

    <aura:handler name="init" value="{!this}" action="{!c.init}" />
    <aura:attribute name="productId" type="String" />

    <aura:if isTrue="{!not(empty(v.productId))}">

        <lightning:recordViewForm recordId="{!v.productId }" objectApiName="Product2">
            <lightning:outputField fieldName="Name" />
        </lightning:recordViewForm>

    </aura:if>
</aura:component>

JavaScript Controller

init: function (cmp, event, helper) {
    let pageReference = cmp.get("v.pageReference");
    let productId = pageReference.state.c__productId;
    cmp.set("v.productId", productId);
}

It works when viewed via desktop, but does not load via mobile.

The <lightning:recordViewForm component support mobile and I've tested using the Account object and it worked:

<lightning:recordViewForm recordId="0010w000002HsJOAA0" objectApiName="Account">
    <lightning:outputField fieldName="Name" />
</lightning:recordViewForm>

I also tried with a hardcoded Product2 Id and it didn't work on mobile, but did work when viewed on desktop.

<lightning:recordViewForm recordId="XXXXXXXXXXXXX" objectApiName="Product2">
    <lightning:outputField fieldName="Name" />
</lightning:recordViewForm>

Why does it fail to work for Product2 on mobile?

Is it possible to get it to work, or should I just use a Apex Controller?

9
  • Do you have the right FLS on the required field?
    – Jayant Das
    Jan 17, 2019 at 22:41
  • @JayantDas I assume so, because it works when viewed using a desktop browser. Or am I miss understanding something?
    – Robs
    Jan 17, 2019 at 22:58
  • Oh yes, missed that part.
    – Jayant Das
    Jan 17, 2019 at 23:00
  • I cannot see v.pageReference attribute on component markup. From where you are getting it? Jan 18, 2019 at 3:36
  • @sanketkumar it comes from implements="lightning:isUrlAddressable
    – Robs
    Jan 18, 2019 at 9:55

1 Answer 1

2

The problem is not with lightning component, it's with Salesforce 1 mobile App.

As I can see from these 2 Ideas, Product Object is not available in Salesforce 1 Mobile App, so your lightning:recordViewForm would respect that and won't load it on mobile.

Please upvote these 2 ideas for support

https://success.salesforce.com/ideaView?id=08730000000Dn0YAAS

https://success.salesforce.com/ideaView?id=08730000000kxxfAAA

On digging deeper, it seems like the object who support quick action can only be supported on Mobile App

https://help.salesforce.com/articleView?id=actions_overview_global.htm&type=5

Workaround: Don't use Lightning Data services and use old lightning:input to show your data from product doing SOQL query in Apex.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.