navigateTo (Client API reference)
Navigates to the specified entity list, entity record, or HTML web resource.
Note
This method is supported only on Unified Interface.
Syntax
Xrm.Navigation.navigateTo(pageInput,navigationOptions).then(successCallback,errorCallback);
Parameters
Name | Type | Required | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
pageInput | Object | Yes | Input about the page to navigate to. The object definition changes depending on the type of page to navigate to: entity list, entity record, dashboard, or HTML web resource. ---------------------------------------------------------------- entity list The object contains the following attributes:
---------------------------------------------------------------- entity record The object contains the following attributes:
---------------------------------------------------------------- HTML web resource The object contains the following attributes:
---------------------------------------------------------------- dashboard The object contains the following attributes:
|
||||||||||||||||||
navigationOptions | Object | No | Options for navigating to a page: whether to open inline or in a dialog. If you don't specify this parameter, page is opened inline by default. The object contains the following attributes:
|
||||||||||||||||||
successCallback | function | No | A function to execute on successful navigation to the page when navigating inline and on closing the dialog when navigating to a dialog. |
||||||||||||||||||
errorCallback | Function | No | A function to execute when the operation fails. |
Return Value
Returns a promise. The value passed when the promise resolves is dependent on the target:
- inline: Promise resolves right away, and does not return any value.
- dialog: Promise resolves when the dialog is closed. An object is passed only if the pageType = entityRecord and you opened the form in create mode. The object has a savedEntityReference array with the following properties to identify the entity record created:
- entityType: The logical name of the entity.
- id: A string representation of a GUID value for the record.
- name: The primary attribute value of the record displayed or created.
Example
Example 1: Open account entity list
var pageInput = {
pageType: "entitylist",
entityName: "account"
};
Xrm.Navigation.navigateTo(pageInput).then(
function success() {
// Run code on success
},
function error() {
// Handle errors
}
);
Example 2: Open an existing account entity record within a dialog
var pageInput = {
pageType: "entityrecord",
entityName: "account",
entityId: "5a57f2c3-5672-ea11-a812-000d3a339706" //replace with actual ID
};
var navigationOptions = {
target: 2,
height: {value: 80, unit:"%"},
width: {value: 70, unit:"%"},
position: 1
};
Xrm.Navigation.navigateTo(pageInput, navigationOptions).then(
function success() {
// Run code on success
},
function error() {
// Handle errors
}
);
Example 3: Open an account form in the create mode within a dialog
var pageInput = {
pageType: "entityrecord",
entityName: "account"
};
var navigationOptions = {
target: 2,
height: {value: 80, unit:"%"},
width: {value: 70, unit:"%"},
position: 1
};
Xrm.Navigation.navigateTo(pageInput, navigationOptions).then(
function success(result) {
console.log("Record created with ID: " + result.savedEntityReference[0].id +
" Name: " + result.savedEntityReference[0].name)
// Handle dialog closed
},
function error() {
// Handle errors
}
);
Example 4: Open an HTML web resource in a dialog
var pageInput = {
pageType: "webresource",
webresourceName: "new_sample_webresource.htm"
};
var navigationOptions = {
target: 2,
width: 500, // value specified in pixel
height: 400, // value specified in pixel
position: 1
};
Xrm.Navigation.navigateTo(pageInput, navigationOptions).then(
function success() {
// Run code on success
},
function error() {
// Handle errors
}
);