6

I am going through the documentation found here SF Lightning Guide, and during the portion where they create the Contact List view on page 36 they cover the click event using the built in force namespace action: navigateToURL. No matter what I try - $A is null. I have debug enabled, and can see that the line immediately before that call is working fine, and receives the ID of the record for the component, but $A is always coming back null.

I have tried e.force, e.., e.c., etc and cant imagine that this is normal. Everything else has been pretty smooth - but then this came along and I have spent several hours looking for anyone experiencing the same thing. This is a last resort before I scrap both this component and the one above it and start again from scratch.

Error being thrown is:

Uncaught error in markup://ui:click : Cannot read property 'setParams' of null

I am using the exact code from the document at this time. Any ideas to try appreciated.

The code below is being called when a user clicks on a ui:outputText.

The sObjectEvent variable is always null.

I am wondering why it is always null - I assume the force namespace is always available.

gotoRecord : function(component, event, helper) {
// Fire the event to navigate to the contact record
    var sObjectEvent = $A.get("e.force:navigateToSObject");
    sObjectEvent.setParams({
        "recordId": component.get("v.contact.Id"),
        "slideDevName": 'related'
    })
    sObjectEvent.fire();
}

EDIT:

Not able to comment yet - Tried adding <aura:dependency resource="markup://force:navigateToSObject" type="EVENT"/> to the component and now the error is gone, but nothing happens when you click the text either.

Developer Console is showing that the Event is now being picked up, and that the Params are set properly - $fired$ is true, and the params contains recordId properly now. I will play with moving some controls around and switching it from a ui:outputText to something else. Thank you for the responses.

  • Do you have any namespace registered in your org? – Tushar Sharma Aug 8 '15 at 5:06
  • I did register a namespace but I have also tried using it in this code. e.MyNamespace: also failed with the same error. – Focus Aug 8 '15 at 5:07
  • 2
    Are you firing the events in the context of Salesforce1 or standalone app? All the force events are handled only in Salesforce1. force:navigateToSObject is working for me in Salesforce1 using that code but I'm having some trouble with force:navigateToURL (the click is not registering at all). – Diana Widjaja Myerscough Aug 8 '15 at 6:20
  • force:navigateToURL now works when I changed ui:outputTextArea to ui:outputText. So somehow the click event is not being registered in ui:outputTextArea. – Diana Widjaja Myerscough Aug 8 '15 at 6:31
8

I'm not sure why it's not available, but you can try to make sure it's available.

Try adding an aura:dependency tag.

<aura:dependency resource="markup://force:navigateToSObject" type="EVENT"/>
0

If you are inside CRM app ( one.app ) , you can use the trick provided in the best response of this question

force:navigateToSObject not working when called from a vf page including a ltng:outApp component

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.