• Daniel Barry 9
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi All,

Let me preface this with a disclaimer. I am fairly new to SalesForce development. But I have 11 years experience as a developer.

I am working on a LWC that calls an Apex controller.

The Apex controller runs a fairly simple SOQL query against a custom object Move_Type__c. It has a master detail relationship with another Custom object Move_Goal_Type__c (see below)

Move_Type & Move_Goal_Type

Here is the query: 
[SELECT Name, Id
FROM pursue02__Move_Type__c
WHERE pursue02__Move_Goal_Type__r.Id = :movegoalTypeId ]
The variable comes into the controller (MoveTypeController) as an Id through a method getMoveTypesByMoveGoalTypeId which is decorated with @AuraEnabled(cacheable=true)

When I execute anonynmous, it works as expected, I get a list of Move_Type__c records with the Name and Id.

When the LWC calls it, it returns an empty array. Now I have debugged the method System.debug(movegoalTypeId) and it shows the correct value. And I assigned the SOQL results to a variable and output that as well, it shows values in the debug logs.

I have also checked the network traffic via chrome developer tools and it's sending the value as expected:
message: {
    "actions": [
        {
            "id": "815;a",
            "descriptor": "aura://ApexActionController/ACTION$execute",
            "callingDescriptor": "UNKNOWN",
            "params": {
                "namespace": "pursue02",
                "classname": "MoveTypeController",
                "method": "getMoveTypesByMoveGoalTypeId",
                "params": {
                    "goalTypeId": "a013k00000aWHa6AAG"
                },
                "cacheable": true,
                "isContinuation": false
            }
        }
    ]
}
But as I said it returns an empty array:
"actions": [
        {
            "id": "815;a",
            "state": "SUCCESS",
            "returnValue": {
                "returnValue": [],
                "cacheable": true
            },
            "error": []
        }
    ],
We have checked the permissions on both Move_Type__c and Move_Goal_Type__c, and they all appear to be correct.

Any one know what we are doing wrong? I'm scratching my head on this one.

Any help would be greatly appreciated!