• Paul Grice 20
  • NEWBIE
  • 5 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies
I am calling an SOQL query in an apex server class. It returns 2 records in the Lightning Experience in the browser but an empty list in Salesforce1 on the mobile. If I create and return a list it works, so it seems to be the query which is the problem. The user is the same in both instances. (I'm also not really sure how to generate a debug log for mobile.)

APEX controller
public with sharing class TaskController {
    @AuraEnabled
    public static List<Task> getTasksforContact(String id) {
        List<Task> t = new List <Task>();
        t = [ SELECT Id FROM Task WHERE WhoId = '0035B000008mEwa' ];

// test
/*
         Task t2 = new Task(WhoId = '0035B000008mEwa', Subject = 'Test');
        List<Task> t = new List<Task>();
        t.add(t2);
*/       
        return t;
    }
Client Controller
({
	doInit : function(cmp) {
                      
        var action = cmp.get ("c.getTasksforContact");
        var theId = cmp.get("v.contactId");
        theId = "0035B000008mEwa"; // testing
        
        action.setParams ({ id : theId });
        
        action.setCallback(this, function(response) {
            var state = response.getState();        
       
            if (state === "SUCCESS") {
                var retVal = response.getReturnValue();
                cmp.set ("v.tasks", retVal);
                var t = cmp.get("v.tasks");                
            }
            else
                console.log("State is NOT Success!");
        });
        $A.enqueueAction(action);        
    }
})
Client Component
<aura:component controller="TaskController" 
                implements="flexipage:availableForAllPageTypes" >
    
    <aura:attribute name="contact" type="Contact" />
    <aura:attribute name="contactId" type="String" />
    <aura:attribute name="leadId" type="String" />
    <aura:attribute name="tasks" type="Task[]"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:method name="refresh" action="{!c.doInit}" />
    
    <aura:iteration items="{!v.tasks}" var="task">
        Subitem<br />
        {!task.Id}<br /> {!task.Subject}<br /> 
    </aura:iteration>
    
</aura:component>

 
I am calling an SOQL query in an apex server class. It returns 2 records in the Lightning Experience in the browser but an empty list in Salesforce1 on the mobile. If I create and return a list it works, so it seems to be the query which is the problem. The user is the same in both instances. (I'm also not really sure how to generate a debug log for mobile.)

APEX controller
public with sharing class TaskController {
    @AuraEnabled
    public static List<Task> getTasksforContact(String id) {
        List<Task> t = new List <Task>();
        t = [ SELECT Id FROM Task WHERE WhoId = '0035B000008mEwa' ];

// test
/*
         Task t2 = new Task(WhoId = '0035B000008mEwa', Subject = 'Test');
        List<Task> t = new List<Task>();
        t.add(t2);
*/       
        return t;
    }
Client Controller
({
	doInit : function(cmp) {
                      
        var action = cmp.get ("c.getTasksforContact");
        var theId = cmp.get("v.contactId");
        theId = "0035B000008mEwa"; // testing
        
        action.setParams ({ id : theId });
        
        action.setCallback(this, function(response) {
            var state = response.getState();        
       
            if (state === "SUCCESS") {
                var retVal = response.getReturnValue();
                cmp.set ("v.tasks", retVal);
                var t = cmp.get("v.tasks");                
            }
            else
                console.log("State is NOT Success!");
        });
        $A.enqueueAction(action);        
    }
})
Client Component
<aura:component controller="TaskController" 
                implements="flexipage:availableForAllPageTypes" >
    
    <aura:attribute name="contact" type="Contact" />
    <aura:attribute name="contactId" type="String" />
    <aura:attribute name="leadId" type="String" />
    <aura:attribute name="tasks" type="Task[]"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:method name="refresh" action="{!c.doInit}" />
    
    <aura:iteration items="{!v.tasks}" var="task">
        Subitem<br />
        {!task.Id}<br /> {!task.Subject}<br /> 
    </aura:iteration>
    
</aura:component>

 
<!-- this is the component -->
<lightning:button label="Success" onclick="{!c.handleClick}"/>


//Client side JS


 handleClick : function(component, event, helper) {        
        var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({
            "title": "The toast pops up",
            "message": "Toast event fired",
            "mode": "sticky",
            "type": "other",
        });
        toastEvent.fire();
    }