The AL developer preview is still evolving with frequent updates. Follow us on the Dynamics NAV Team Blog for the announcements.
Generates a URL for the specified client target that is based on the configuration of the Dynamics 365 for Financials service instance.
If the code runs in a multitenant deployment architecture, the generated URL will automatically apply to the tenant ID of the current user.
[String :=] GETURL(ClientType[, Company][, Object Type][, Object Id][, Record/RecordRef][, UseFilters])
Value: CURRENTCLIENTTYPE (or Current), DEFAULTCLIENTTYPE (or Default), Windows, Web, SOAP, or OData
Specifies the client that you want to generate the URL for. This parameter is required. If you want to generate a URL that depends on the client that the user is accessing the URL from, choose Current. The following table describes the options.
|The URL is generated based on the client that invokes the code, provided that this is one of the client types that are specified in this list. If the URL is requested by another client type, such as a NAS session, Dynamics 365 generates a URL based on the default client that is specified for the relevant Dynamics 365 for Financials service instance. Note: If you specify current as the client type, the URL cannot be consumed by an OData web service.|
|The URL is generated based on the default client that is specified for the relevant Dynamics 365 for Financials service instance.|
|ClientType::Web||The URL is generated based on a request from the Web client.|
|ClientType::Desktop||The URL is generated based on a request from the Dynamics 365 for Finance and Operations, Business edition desktop app.|
|ClientType::Tablet||The URL is generated based on a request from the Tablet client app.|
|ClientType::Phone||The URL is generated based on a request from the Phone client app.|
|ClientType::SOAP||The URL is generated based on a request from a SOAP web service.|
|ClientType::OData||The URL is generated based on a request from an OData web service.|
A runtime error occurs if the ClientType is set to SOAP or OData but the specified object type and ID has not been published as a web service.
Specifies the company that the URL must contain. If you do not specify a company, the URL will run in the user’s current company.
Value: Table, Page, Report, Codeunit, Query, or XMLport
Specifies the object type that the URL must open. If you specify an object type, you must also specify an object ID in the ObjectId parameter. Otherwise, the user will see a runtime error.
If you set the ObjectType parameter to Page, you can also specify a record variable in the Record parameter.
Specifies the ID of the specified object type that the URL must open.
Type: Record or RecordRef variable
The Record or RecordRef variable that specifies which record to open.
Specifies whether to include filters that are defined on the object as a text string in the URL.
Property Value/Return Value
The GETURL method generates a URL to open a specific page, for example, or to read Dynamics 365 data from a web service. The generated URL includes settings from the configuration of the Dynamics 365 for Financials service instance which the code that uses the method runs in. This means that you can use the GETURL method to generate URLs that are generic. The URLs are generated based on the Dynamics 365 for Financials service configuration for the user who is accessing the code that generates the URL. If you specify a company, then the URL applies to that company only. Also, in a multitenant deployment, the URLs are tenant-specific. The URL will only allow access to the requested object if the user has permission to access to the object.
GETURL returns an empty string if the specified parameters result in values that are not valid, and if the URL cannot be generated for other reasons. If the method returns an empty string, you can use the GETLASTERRORTEXT method to troubleshoot. For more information, see GETLASTERRORTEXT Method.
For example, you can write code that will open page 21 in the Web client. In that case, you call the GETURL method that has the relevant parameters, and when the code runs, the name of the Dynamics 365 for Financials service instance and the server name are extracted automatically. The following table describes the basic URLs that you get with the simplest use of the GETURL method by writing
url := GETURL(ClientType::Default), 'demoname';.
|Web client||https://yourfinancialURL/?company='CRONUS International Ltd.|
|Tablet client||ms-financials://server:port/instance?company=’ CRONUS International Ltd.’|
|Phone client||ms-financials://yourfinancialURL?company=’ CRONUS International Ltd.’|
|Dynamics 365 Desktop client||ms-dynamicsnav://yourfinancialURL?company=’ CRONUS International Ltd.’|
|OData||https://yourfinancialURL/OData/Company('CRONUS International Ltd.')/|
|SOAP||https://yourfinancialURL/WS/CRONUS International Ltd.|
In the example, an empty string for the company name is included for clarity. But an even simpler use of GETURL is to only specify the client type as in
url := GETURL(ClientType::Default);.
URLs for opening a page or a report are available from the About this Page windows.
The following code example illustrates how you can use the GETURL method to generate a URL that will open page 21 in the client that the current user is using.
Cust.Get(10000); url := GETURL(CURRENTCLIENTTYPE, 'COMPANYNAME', ObjectType::Page, 21, Cust); // Alternatively, you can use the following code: //Cust.Get(10000); //url := GETURL(ClientType::OData, COMPANYNAME, ObjectType::Page, 21, Cust);
When the code runs, a different URL is generated, depending on the client that is using the URL. If the code is run in the context of a SOAP web service, it has a different syntax than if it runs in the context of the Microsoft Dynamics NAV Windows client. The following table describes the syntax of the generated URL for each client type.
|Microsoft Dynamics NAV Windows client||DynamicsNAV://server:port/instance/company/runpage?page=21&bookmark=bookmark|
|OData||Not applicable because the client type is set to Current, which is not supported for Odata web services.|
|SOAP||Not applicable because the URL for SOAP web services does not support filtering for the record.|
The current version of Dynamics 365 cannot generate a URL for an OData client if the client type is set to Current. However, the following code example illustrates a similar scenario for opening page 21 and specifying the record so that the URL can be consumed by an OData web service:
Cust.Get(10000); url := GETURL(ClientType::OData, COMPANYNAME, ObjectType::Page, 21, Cust);
In this example, the following URL is generated for OData web services:
In this example, it is assumed that page 21 is published as an OData web service with the name Customer.
The following code example illustrates a similar scenario for opening page 21 and not specifying the record so the URL can be consumed by a SOAP web service:
url := GETURL(CURRENTCLIENTTYPE, COMPANYNAME, ObjectType::Page, 21); // Alternatively, you can use the following code: //url := GETURL(ClientType::Current, COMPANYNAME, ObjectType::Page, 21);
In this example, the following URL is generated for SOAP web services: