Link Function

Official Content
This documentation is valid for:
Returns a character string with a URL format. 

Syntax

Link(Object | URL [ , Par1 , ... Parn ] )

Type Returned:
Character

Where:
Object | URL
Is a Transaction, Web Panel, Web Component, Panel, Work with, Image or URL to link.

[ par1 ] ... [ parn ]
The set of parameters to pass to the object or URL.

Description

This function returns a string that is afterward used in different scenarios, generally to afterward add a link to a UI Control, or call an internal or external resource.

Linking Web Objects 

Use case 1: Link a known Web Object on a web layout

&MyLink = Link(MyObject,&Parm1, &Parm2)
Textblock1.Link = &MyLink
&MyObject = 'Module1.MyObject'
&MyLink = Link(&MyObject,&Parm1, &Parm2)
Textblock1.Link = &MyLink

MyObject can be a Web Panel object, Transaction object, Web Component object with URL access, Image object.

Use case 2: Instantiate a Web Component control with a Web Component object

&MyLink = Link(MyObject,&Parm1, &Parm2)
WebComponent.Object = CreateFromURL(&MyLink)
&MyObject = 'Module1.MyObject'
&MyLink = Link(&MyObject,&Parm1, &Parm2)
WebComponent.Object = CreateFromURL(&MyLink)

MyObject can be a Web Component object.

Use case 3: Link or call a known Web Object

&MyLink = Link(MyObject,&Parm1, &Parm2)
link(&MyLink)
&MyObject = 'Module1.MyObject'
&MyLink = Link(&MyObject,&Parm1, &Parm2)
link(&MyLink)

MyObject can be a Web Panel object, Transaction object, Web Component object with URL access.

Linking Panels

Use case 4: Call a known Panel

&MyLink = Link(MyObject,&Parm1, &Parm2)
call(&MyLink)
&MyObject = 'Module1.MyObject' 
&MyLink = Link(&MyObject,&Parm1, &Parm2) 
call(&MyLink)

MyObject can be a Panel objectWork With object

Notes related to the uses case 1 to 4

  • Recommended Coding style: Write  'MyObject.Link(Parm1,Parm2)' instead of  Link(MyObject,Parm1, Parm2) when the linked object is a known at design time

Linking external resources

Use case 5: Linking resources of the same site

You can use the link function to get a link to an external resource of the same site. 

5.1: Document Relative

&MyLink = Link(!'mypath/document',&Parm1, &Parm2) 

Compatibility note specific to Java generator: If the linked URL is a file (e.g. 'mypath/myspreadsheet.xlsx'), the resulting string is server relative.

5.2: Server Relative

&MyLink = Link(!'/mypath/document',&Parm1, &Parm2) 

Use case 7: Linking resources of another site

6.1: Protocol Relative

&MyLink = Link(!'//example.com:80/mypath/folder1',&Parm1, &Parm2) 

6.2: Absolute 

&MyLink1 = Link(!'https://example.c:80/mypath/document',&Parm1, &Parm2) 
&MyLink2 = Link(!'http://user:pwd@example.com:80/mypath/document',&Parm1, &Parm2)
&MyLink3 = Link(!'myscheme://example.com:80/mypath/document',&Parm1, &Parm2)

Notes:

if the URL to be linked is stored in an attribute you can write 

for each
    &MyLink = link(att:CompanyURL)
endfor

Considerations

  • Rewrite rules: When there are rewrite rules in the kb (ie at least one URL Rewrite object) all URLs are handled at runtime as server relative URLs because it is required to avoid potential URLs ambiguity.  Therefore, in that case, the link function applied to a relative URL always returns a server relative URL.
  • Parameter style: The Parameters Style property determines how URLs are built when having parameters, thus, the link function result takes into account this property also. 

Scope

Objects: Procedure object, Transaction object, Web Panel objectPanel object
Platforms: .NET, .NET Core, Java, Apple, Android, Angular

See Also