force:createRecord:
To create a new record:
1
2
3
4
5
6
7
| createRecord : function (component, event, helper) { var createRecordEvent = $A.get("e.force:createRecord"); createRecordEvent.setParams({ "entityApiName": "Contact" }); createRecordEvent.fire(); } |
force:editRecord
To Edit a existing record:
1
2
3
4
5
6
7
| editRecord : function(component, event, helper) var editRecordEvent = $A.get("e.force:editRecord"); editRecordEvent.setParams({ "recordId": component.get("v.contact.Id") }); editRecordEvent.fire(); } |
force:navigateToList
To navigate to a list view, set the list view ID on the listViewId attribute and fire the event.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| gotoList : function (component, event, helper) { var action = component.get("c.getListViews"); action.setCallback(this, function(response){ var state = response.getState(); if (state === "SUCCESS") { var listviews = response.getReturnValue(); var navEvent = $A.get("e.force:navigateToList"); navEvent.setParams({ "listViewId": listviews.Id, "listViewName": null, "scope": "Contact"; }); navEvent.fire(); } }); $A.enqueueAction(action); } |
1
2
3
4
5
6
7
| @AuraEnabled public static List<ListView> getListViews() { List<ListView> listviews = [SELECT Id, Name FROM ListView WHERE SobjectType = 'Contact']; // Perform isAccessible() check here return listviews; } |
force:navigateToObjectHome
Navigates to the object home specified by the scope attribute.
1
2
3
4
5
6
7
| navHome : function (component, event, helper) { var homeEvent = $A.get("e.force:navigateToObjectHome"); homeEvent.setParams({ "scope": "myNamespace__myObject__c" }); homeEvent.fire(); } |
force:navigateToRelatedList
Navigates to the related list specified by parentRecordId.
1
2
3
4
5
6
7
8
| gotoRelatedList : function (component, event, helper) { var relatedListEvent = $A.get("e.force:navigateToRelatedList"); relatedListEvent.setParams({ "relatedListId": "Cases", "parentRecordId": component.get("v.contact.Id") }); relatedListEvent.fire(); } |
force:navigateToSObject
Navigates to an sObject record specified by recordId.
1
2
3
4
5
6
7
8
| createRecord : function (component, event, helper) { var navEvt = $A.get("e.force:navigateToSObject"); navEvt.setParams({ "recordId": "00QB0000000ybNX", "slideDevName": "related" }); navEvt.fire(); } |
force:navigateToURL
Navigates to the specified URL.
1) Using a relative URL.
1
2
3
4
5
6
7
| gotoURL : function (component, event, helper) { var urlEvent = $A.get("e.force:navigateToURL"); urlEvent.setParams({ "url": "/006/o" }); urlEvent.fire(); } |
2) Using external website when the link is clicked.
1
2
3
4
5
6
7
8
9
10
| navigate : function(component, event, helper) { //Find the text value of the component with aura:id set to "address" var address = component.find("address").get("v.value"); var urlEvent = $A.get("e.force:navigateToURL"); urlEvent.setParams({ "url": 'https://www.google.com/maps/place/' + address }); urlEvent.fire(); } |
No comments:
Post a Comment