Hi, Readers.
Today I would like to share another mini tip about Business Central, how to quickly check if a Url is secure (Use https) via AL
Hypertext transfer protocol secure (HTTPS) is the secure version of HTTP, which is the primary protocol used to send data between a web browser and a website. HTTPS is encrypted in order to increase security of data transfer. This is particularly important when users transmit sensitive data, such as by logging into a bank account, email service, or health insurance provider.
In Business Central customization, we can directly open external websites, or customize some functions through external services and APIs. For example, Using Hyperlink() Method to open a URL in a current session without opening a new tab in the browser


Before using it, it is important to confirm whether the URL is secure in advance. Here is a standard method that can be used.
In codeunit 1299 “Web Request Helper”: procedure IsSecureHttpUrl(Url: Text)

Let’s do a simple test: When entering the Home Page on the customer card, check if it is secure.


Great.
The URI is not secure.

Test video:
Very simple, give it a try!!!😁
Test code:
tableextension 50112 CustomerExt extends Customer
{
fields
{
modify("Home Page")
{
trigger OnBeforeValidate()
var
WebRequestHelper: Codeunit "Web Request Helper";
begin
if Rec."Home Page" <> '' then
WebRequestHelper.IsSecureHttpUrl(Rec."Home Page");
end;
}
}
}
PS:
1. This method also checks if the URL is valid, so it is very helpful when calling external services or web pages in AL.

The URI is not valid.

2. Dynamics 365 Business Central: How to quickly get host name from URL via AL
END
Hope this will help.
Thanks for your reading.
ZHU
コメント