Official Content

Returns a character string with a URL format. 

Syntax

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

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.

Type Returned:
Character

Scope

Objects: Procedure, Transaction, Web Panel Panel, Data Provider
Generators: .NET Framework.NET, Java, Apple, Android, Angular

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.

Samples

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 pattern and Work With object

Note related to the use cases 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 6: 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)

Note: 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 (i.eE 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 for Environments determines how URLs are built when having parameters. Thus, the link function result also takes into account this property. 

See Also

Link command
CreateFromURL function
Call Variable

 


Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant