Views: 98
Last Modified: 12.08.2021

Let's examine several examples for calculating expression values System can calculate expressions in action parameters. .

  Using variables in links

Action fields, supporting the tag [url], allows using custom variables for creating links.

	[url=http://{=Variable:Domain}/{=Variable:Path}]link name[/url]
where: {=Variable:Domain} and {=Variable:Path} - variables, containing server address and the required path.

  Creating links

Creating direct links to page with assignment

Use the link, for example, to send user a message about the requirement to complete the assignment within workflow.

	Link to page with assignment: [url=http://[account_URL]/company/personal/bizproc/{=Workflow:ID}/]link to document view page[/url]

Creating link to page of document detailed view

Use the link, for example, to send a message to user to jump directly to document view.

	Link to document detailed page view: [url]{=Document:DETAIL_PAGE_URL}[/url]

Note: Expression {=Document:DETAIL_PAGE_URL} generates a required link on condition that iblock settings has a correctly completed page detail view URL.

Creating direct link to file on server

Such scenario is needed, when sending a file download link to a customer.

For example, an element has a File field. To get an internal link, do the following: insert value Element field > File (name).

Link to file  - {=Document:PROPERTY_FILE_PRINTABLE}

Such link requires authentication at the account. You can get a public link via the src modifier, that must be indicated as follows:

// delete _PRINTABLE and add modifier >src and bb-code [url].
Link to file - [url={=Document:PROPERTY_FILE>src}]link[/url]

Attention! Using such modifier at the Bitrix24 On-premise versions can compromise security. For example, when this file is uploaded by a user: it can be HTML and such link opened in your site page inside the browser, can contain malicious code. However, it can be avoided by using CDN (in Bitrix24 Cloud as well) or by configuring your server (.htaccess rules and etc, that prohibit execution of html/php files from /upload/).

  Time setup

Expression is used for element fields, variables or template parameters.

	=if(and((intval(substr({=Template:Parameter1}, 0, 2)) >= 0), (intval(substr({=Template:Parameter1}, 0, 2)) < 25), (substr({=Template:Parameter1}, 2, 1) = ":"), (intval(substr({=Template:Parameter1}, 3, 2)) >= 0), (intval(substr({=Template:Parameter1}, 3, 2)) < 60)), {=Template:Parameter1}, "incorrect time")

When parameter {=Template:Parameter1} passes the time (24 in the time format HH:MM, for example 21:45), returns its value. Otherwise, returns incorrect time error.



0


Courses developed by Bitrix24