Event References
These events enable your components to open a record create or edit page, or navigate to a record.
force:createRecord:
To create a new record:
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:
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.
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);
}
This Apex controller returns all list views for the contact object
@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.
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.
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.
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.
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.
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();
}
You can also see on this link click
No comments:
Post a Comment