1

I'm currently modifying a Lightning Component that someone else created. As such, I'm trying to get the hang of how to work with Aura as I haven't done it before - only Apex and a bit of Visualforce.

Essentially, I have an initial screen which prompts record type selection. In the controller for this screen I have the 'redirect' function, which (after some other code), does the following:

var splitArray = recordTypeID.split("/");
//recordTypeID is the ID of the record type the user selects.
var navService = component.find("navService");
var pageReference = {
    type: 'standard__component',
    attributes: {
        componentName: 'c__PersonWizard'
    },
    state:{
        "c__recordTypeID":splitArray[1]
    }
};

event.preventDefault();
navService.navigate(pageReference);

This will redirect the user to the PersonWizard component. The first page should display a table of Contacts and provides a search box at the top to search for a Contact. At the moment, this table is not filtered based on anything. However, I want to filter it to only Contacts with the record type chosen by the user.

The PersonWizard uses a controller class (Javascript) - whose doInit function runs a helper method called 'getDataTableData' (this is the method that gets all the Contact data to display in the initial table of Contacts shown to the user. The getDataTable function includes this code:

var recordTypeIdVar = component.get("v.pageReference.state.c__recordTypeID");
var action = component.get("c.getDataTableDetails");
console.log('Record Type ID Passed Through to getTableDataDetails(Apex): '+recordTypeIdVar);
action.setParams({
    objectName:'Contact',
    fieldSetName:'Contact_Wizard_List_View',
    recordTypeId:recordTypeIdVar,
    pageNumber:pageNumber,
    pageSize:pageSize,
});

... some more code that's not relevant to the issue...

$A.enqueueAction(action);

Now, when I check the console output, I can see that the 'log' command in line 3 is logging the recordTypeId value correctly:

"Record Type ID Passed Through to getTableDataDetails(Apex): 0126F000000iWXvQAM"

The Apex class (getDataTableDetails) includes the 'recordTypeId' String parameter as one of its arguments, as well as objectName, fieldSetName, pageNumber and pageSize. I have included a System.debug() line at the start of the method which prints the value of the recordTypeId argument. Here is the problem: that argument is null when I run the wizard:

Record Type ID Passed Through to getDataTableDetails: null

So it seems that the Javascript helper class is able to obtain the recordTypeId value from the Pagereference. However, when it tries to set that value as one of the parameters for the action (running the Apex function), it doesn't pass through anything. Can anyone help me as to why this might be happening? Is my syntax on action.setParams() correct?

Thanks a lot in advance.

4
  • What's the Apex being called, specifically? Did you check to make sure the parameter names are case sensitive correct to what's passed in through JS?
    – sfdcfox
    Jun 26 at 4:24
  • It is a method called getDataTableDetails. Here's the header: public static DataTableDetails getDataTableDetails(String objectName,String fieldSetName, String recordTypeId, Integer pageNumber,Integer pageSize) Double checked the parameter name and it's exactly the same: recordTypeId
    – callum202
    Jun 26 at 4:43
  • 1
    Can you change the pageNumber and pageSize params to a String? I have had issues passing integers before. Also, try passing in a single object, which will evaluate to a map in Apex. Last thing - pass only the recordTypeId just to test that it's not something else. Jun 26 at 6:49
  • Check this link- I also faced this problem where setParams is correct and the parameter case also matches but still the same issue. Both the solution worked for me at different times. salesforce.stackexchange.com/questions/169952/… Jun 26 at 7:16
0

So clearing my cookies solved this issue. Thanks everyone for the help.

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.