Files
help365/platform/script-activity.html
koziavin 00717a92fb
All checks were successful
Deploy Static Site / deploy (push) Successful in 6m6s
update
2025-05-29 16:42:45 +04:00

263 lines
36 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<title>Script activity</title>
<meta name="generator" content="Help+Manual" />
<meta name="keywords" content="" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="This type of business process activity can be used to create integrations, for example, to send requests to an external system. Business process activity settings break into..." />
<meta name="picture" content="" />
<meta property="og:type" content="website" />
<meta property="og:title" content="Full documentation for BRIX365 platform. Low-code developer guide. User guide. Admin guide. Developer guide." />
<meta property="og:url" content="https://brix365.com/en/help" />
<meta property="og:image" content="" />
<link rel="icon" href="favicon.png" type="image/png" />
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="./jquery-ui.min.css" />
<link rel="stylesheet" href="default.css" />
<link rel="stylesheet" href="./search-yandex.css" />
<link rel="stylesheet" href="./article.css" />
<link rel="stylesheet" href="./glossary.css" />
<link rel="stylesheet" href="./theme.css" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="helpman_settings.js"></script>
<script type="text/javascript" src="helpman_topicinit.js"></script>
<script type="text/javascript" src="highlight.js"></script>
<script type="text/javascript">
$(document).ready(function(){highlight();});
</script>
</head>
<body>
<script>!function(e,t,c,n,r,a,m){e.ym=e.ym||function(){(e.ym.a=e.ym.a||[]).push(arguments)},e.ym.l=1*new Date;for(var s=0;s<document.scripts.length;s++)if(document.scripts[s].src===n)return;a=t.createElement(c),m=t.getElementsByTagName(c)[0],a.async=1,a.src=n,m.parentNode.insertBefore(a,m)}(window,document,"script","https://mc.yandex.ru/metrika/tag.js"),ym(83179930,"init",{clickmap:!0,trackLinks:!0,accurateTrackBounce:!0,webvisor:!0})</script><noscript><div><img alt=""src=https://mc.yandex.ru/watch/83179930 style=position:absolute;left:-9999px></div></noscript>
<header class="header elma-365">
<div class="container">
<a class="header__logo" href="https://brix365.com/en/help">
<img src="./logo-en.svg" alt="header logo">
</a>
<!-- <div class="hero__search-form" id="search-panel">
<form class="search-form" onsubmit="ym(83180416,'reachGoal','poisk')">
<label class="search-form__label">
<span id="reset-search" class="search__icon"></span>
<input class="search-form__input" type="text">
</label>
<input class="search-form__submit" type="submit" value="Submit">
</form>
</div> -->
<div class="hero__search-form" id="search-panel"> <form class="search-form"> <label class="search-form__label"> <span id="reset-search" class="search__icon"></span> <input class="search-form__input" type="text"> </label> <input class="search-form__submit" type="submit" value="Submit"> </form> </div>
<div class="hero__search">
<a href="#" id="search-icon" class="hero__search-icon">
<img src="search-icon-white.svg" alt="search string">
</a>
<a href="#" id="side-menu-icon" class="hero__side-icon">
<img src="side_menu.svg" alt="side menu">
</a>
</div>
<div class="header__navi">
<ul class="header__list"><li><span class="solution-select"><span class="solution-select__selected"></span><svg width="7" height="4" viewBox="0 0 7 4" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L3.5 3.5L6 1" stroke="white" stroke-linecap="round" stroke-linejoin="round"/></svg><ul class="solution-select__list"><li><a class="project-link" href="https://brix365.com/en/help/platform/get-trial.html">Platform</a></li><li><a class="project-link" href="https://brix365.com/en/help/ecm/ecm-functions.html">ECM</a></li><li><a class="project-link" href="https://brix365.com/en/help/crm/crm_overview.html">CRM</a></li><li><a class="project-link" href="https://brix365.com/en/help/service/service-functions.html">Service</a></li><li><a class="project-link" href="https://brix365.com/en/help/projects/projects-functions.html">Projects</a></li><li><a class="project-link" href="https://brix365.com/en/help/business_solutions/-elma365-store.html">Business Solutions</a></li></ul></span></li><li><a href="https://api.brix365.com/en/" target="_blank">API</a></li><li><a href="https://tssdk.brix365.com/" target="_blank">SDK</a></li></ul>
</div>
</div>
</header>
<main class="main container">
<aside class="sidebar" id="sidebar">
<div class="sidebar__header">
<a class="header__logo" href="https://brix365.com/en/help">
<img src="./logo-light-en.svg">
</a>
<span class="sidebar__close elma-365-close" id="close"></span>
</div>
<div class="sidebar__wrapper" id="side-menu">
</div>
</aside>
<article class="article" id="article">
<div class="article-inner">
<div class="content">
<header class="article__header">
<div class="article__bread" style="display:flex; gap:10px;">
<span id="subcategory" class="search-res__item-category search-res__item-category_subcategory subcategory article__badge"></span>
<div class="topic__breadcrumbs">
<p><a href="360024498352.html">Modules</a> &gt; <a href="extentions.html">Custom modules</a> &gt; <a href="extention-activities.html">Business process activities</a> / Script activity</p>
</div>
</div>
<div class="topic__title"><h1 class="p_Heading1"><span class="f_Heading1">Script activity</span></h1>
</div>
</header>
<section class="article__content">
<div class="scroll-top-inner">
<a href="#h1-article" class="scroll-top"></a>
</div>
<!-- Placeholder for topic body. -->
<p style="line-height: 1.20; margin: 7px 0 16px 0;"><span style="font-family: Inter;">This type of business process activity can be used to create integrations, for example, to send requests to an external system. Business process activity settings break into three tabs: </span><span style="font-family: Inter; font-weight: bold;">Settings</span><span style="font-family: Inter;">, </span><span style="font-family: Inter; font-weight: bold;">Context</span><span style="font-family: Inter;">, and </span><span style="font-family: Inter; font-weight: bold;">Scripts</span><span style="font-family: Inter;">.</span></p>
<h2 class="p_Heading2"><span class="f_Heading2">Settings tab</span></h2>
<p style="line-height: 1.20; margin: 7px 0 16px 0;"><span style="font-family: Inter;">On the </span><span style="font-family: Inter; font-weight: bold;">Settings</span><span style="font-family: Inter;"> tab, specify:</span></p>
<p style="line-height: 1.20; margin: 7px 0 7px 0;"><img alt="script-activity-1" width="702" height="658" style="margin:0;width:702px;height:658px;border:none" src="script-activity-1.png"/></p>
<ul style="list-style-type:disc">
<li style="line-height: 1.20; margin-top: 7px; margin-right: 0; margin-bottom: 7px;"><span style="font-family: Inter; font-weight: bold;">Name</span><span style="font-family: Inter;">. Name of the business process activity.</span></li><li style="line-height: 1.20; margin-top: 7px; margin-right: 0; margin-bottom: 7px;"><span style="font-family: Inter; font-weight: bold;">Default name.</span><span style="font-family: Inter;"> This name is displayed on the business process activity element when it is added to the business process diagram.</span></li><li style="line-height: 1.20; margin-top: 7px; margin-right: 0; margin-bottom: 7px;"><span style="font-family: Inter; font-weight: bold;">Activity color</span><span style="font-family: Inter;">. The color of the business process activity shape on the process diagram.</span></li><li style="line-height: 1.20; margin-top: 7px; margin-right: 0; margin-bottom: 7px;"><span style="font-family: Inter; font-weight: bold;">Description</span><span style="font-family: Inter;">. The description of the business process activitys functionality and features.</span></li><li style="line-height: 1.20; margin-top: 7px; margin-right: 0; margin-bottom: 7px;"><span style="font-family: Inter; font-weight: bold;">Outdated</span><span style="font-family: Inter;">. This option allows you to hide the element from the business process designer so that users cannot add it to the diagrams of new processes. Outdated actions will continue to work unchanged in already created processes. For example, you can enable the option for an activity after a module update.</span></li><li style="line-height: 1.20; margin-top: 7px; margin-right: 0; margin-bottom: 7px;"><span style="font-family: Inter; font-weight: bold;">Message if the activity is outdated</span><span style="font-family: Inter;">. Text of the alert informing that a process includes outdated activities. This message is shown when a user publishes a process with outdated activities.</span></li><li style="line-height: 1.20; margin-top: 7px; margin-right: 0; margin-bottom: 7px;"><span style="font-family: Inter; font-weight: bold;">Execution model</span><span style="font-family: Inter;">. Specify the way the activity is performed:</span></li></ul>
<ul style="list-style-type:disc"><ul style="list-style-type:circle">
<li style="line-height: 1.20; margin-top: 7px; margin-right: 0; margin-bottom: 7px;"><span style="font-family: Inter; font-weight: bold;">Synchronous</span><span style="font-family: Inter;">. Simple execution of a script specified in the activity, i. e. synchronous execution of the </span><code><b>action()</b></code><span style="font-family: Inter;"> function. An action with synchronous execution can be called as a function from other scripts. For more details, see the <a href="script-activity.html#call-actions-in-scripts" class="topiclink">Call activity in scripts</a> section of the article.</span></li><li style="line-height: 1.20; margin-top: 7px; margin-right: 0; margin-bottom: 7px;"><span style="font-family: Inter; font-weight: bold;">Result Request</span><span style="font-family: Inter;">.The system executes the specified script and sends a status request to an external service. To implement this approach in a business process activity, you need to define the </span><code><b>check()</b></code><span style="font-family: Inter;"> function that checks the result. The business process will continue after the </span><code><b>check()</b></code><span style="font-family: Inter;"> function returns </span><code><b>true()</b></code><span style="font-family: Inter;">.</span></li><li style="line-height: 1.20; margin-top: 7px; margin-right: 0; margin-bottom: 7px;"><span style="font-family: Inter; font-weight: bold;">Callback</span><span style="font-family: Inter;">.In a request to an external service, a URL that the result needs to be returned to is passed. This means that this URL is passed as the call parameter, and this URL will be called when the external service completes the task. Results of the call will be sent to this URL. The response URL is provided as an input argument to the </span><code><b>action()</b></code><span style="font-family: Inter;"> function. Any request for this URL is passed to the </span><code><b>callback()</b></code><span style="font-family: Inter;"> function. After that, the process continues</span></li></ul></li></ul>
<ul style="list-style-type:disc">
<li style="line-height: 1.20; margin-top: 7px; margin-right: 0; margin-bottom: 7px;"><span style="font-family: Inter; font-weight: bold;">Number of retries in case of error</span><span style="font-family: Inter;">. Specifies how many times the system will try to execute the activity.</span></li><li style="line-height: 1.20; margin-top: 7px; margin-right: 0; margin-bottom: 7px;"><span style="font-family: Inter; font-weight: bold;">Retry delay (sec)</span><span style="font-family: Inter; font-weight: bold; color: #ff0000;">*</span><span style="font-family: Inter;">. Defines the frequency of attempts.</span></li></ul>
<h2 class="p_Heading2"><span class="f_Heading2">Context tab</span></h2>
<p style="line-height: 1.20; margin: 7px 0 16px 0;"><span style="font-family: Inter;">On the </span><span style="font-family: Inter; font-weight: bold;">Context</span><span style="font-family: Inter;"> tab, you can add variables to use in the business process activity. To create a new context variable, click </span><span style="font-family: Inter; font-weight: bold;">+Add</span><span style="font-family: Inter;">. Read more about variable types in the <a href="360009707032.html" class="topiclink">System data types</a> article.</span></p>
<p style="line-height: 1.20; margin: 7px 0 16px 0;"><img alt="script_activity_01" width="708" height="272" style="margin:0;width:708px;height:272px;border:none" src="script_activity_01.png"/></p>
<p style="line-height: 1.20; margin: 7px 0 16px 0;">Context variables of an activity can be passed to the business process this activity is added to. An activity, in turn, can get the values of the variables from the business process context. </p>
<p style="line-height: 1.20; margin: 7px 0 16px 0;">To pass variables, you must define which variables are input and output ones. Once you have added the activity to the process diagram, you can map these variables to the process context. Read more about this in the <a href="activities-features.html" class="topiclink">Binding and other aspects of business process activities</a> article.</p>
<h2 class="p_Heading2"><a id="scripts-tab" class="hmanchor"></a><span class="f_Heading2">Scripts tab</span></h2>
<p style="line-height: 1.20; margin: 7px 0 16px 0;"><span style="font-size: 13px; font-family: Inter; color: #394149;">On the </span><span style="font-size: 13px; font-family: Inter; font-weight: bold; color: #394149;">Scripts</span><span style="font-size: 13px; font-family: Inter; color: #394149;"> tab, you can create a business process activity script. Scripts are written in the </span><span style="font-size: 13px; font-family: Inter; color: #0000ff;"><a href="https://www.typescriptlang.org/" target="_blank" class="weblink">TypeScript</a></span><span style="font-size: 13px; font-family: Inter; color: #394149;"> programming language. If you want to know more about the basic principles of script-writing in </span><span style="font-size: 13px; font-family: Inter; color: #394149; background-color: #ffffff;">BRIX</span><span style="font-size: 13px; font-family: Inter; color: #394149;">, please visit <a href="https://tssdk.brix365.com/en/latest/" target="_blank" class="weblink">BRIX TypeScript SDK</a>.</span></p>
<p style="line-height: 1.20; margin: 7px 0 16px 0;"><span style="font-size: 13px; font-family: Inter; color: #394149;">By default, in an activity script, you can only access properties, processes, and API methods from the module where the activity is configured. You can grant access to other system objects in the script using <a href="https://tssdk.brix365.com/en/modules/_03_globals_.html" target="_blank" class="weblink">Global constants</a>. To do this, click </span><span style="font-size: 13px; font-family: Inter; font-weight: bold; color: #394149;">Settings</span><span style="font-size: 13px; font-family: Inter; color: #394149;"> in the menu at the top of the page.</span></p>
<p style="line-height: 1.20; margin: 7px 0 16px 0;"><img alt="script-activity-6" width="710" height="405" style="margin:0;width:710px;height:405px;border:none" src="script-activity-6.png"/></p>
<p style="line-height: 1.20; page-break-after: avoid; background: #ffffff; margin: 14px 0 0 0;"><span style="font-family: Inter;">You can use the following options:</span></p>
<ul style="list-style-type:disc">
<li style="line-height: 1.20; background: #ffffff; margin-top: 14px; margin-right: 0; margin-bottom: 0;"><span style="font-family: Inter; font-weight: bold;">Global constants</span><span style="font-family: Inter;">. Check the Global option to be able to refer to objects from all workspaces in the system and to global parameters. For this purpose, the </span><span style="font-family: Inter; color: #0563c1;"><a href="https://tssdk.brix365.com/en/latest/pages/quick-start/intro_globals.html#global" target="_blank" class="weblink">Global</a></span><span style="font-family: Inter;"> constant is used.</span></li></ul>
<p class="p_CodeExample" style="page-break-inside: avoid;"><span class="f_CodeExample">начало&nbsp;внимание</span></p>
<p style="line-height: 1.20; background: #ffffff; margin: 14px 0 0 0;"><span style="font-size: 15px; font-family: Inter;">When the </span><code><b>Global</b></code><span style="font-size: 15px; font-family: Inter;"> constant is used in a script, the module with this activity cannot be </span><span style="font-size: 15px; font-family: Inter; color: #0563c1;"><a href="export_extention.html" class="topiclink">exported</a></span><span style="font-size: 15px; font-family: Inter;">.</span></p>
<p class="p_CodeExample" style="page-break-inside: avoid;"><span class="f_CodeExample">конец&nbsp;внимание</span></p>
<ul style="list-style-type:disc">
<li style="line-height: 1.20; background: #ffffff; margin-top: 14px; margin-right: 0; margin-bottom: 0;"><span style="font-family: Inter; font-weight: bold;">Optional dependencies (available in the Imports object)</span><span style="font-family: Inter;">. Select workspaces or custom modules to add </span><span style="font-family: Inter; color: #0000ff;"><a href="optional-dependencies.html" class="topiclink">optional dependencies</a> </span><span style="font-family: Inter;">to them. They can then be accessed via the </span><span style="font-family: Inter; color: #0563c1;"><a href="optional-dependencies.html#use-imports" class="topiclink">Imports</a></span><span style="font-family: Inter;"> constant. When using optional dependencies, the module can be exported without restrictions.</span></li></ul>
<p style="line-height: 1.20; background: #ffffff; margin: 14px 0 0 34px;"><span style="font-family: Inter;">To create a dependency, click </span><span style="font-family: Inter; font-weight: bold;">+Add workspace</span><span style="font-family: Inter;"> and select a system component. Then, in the </span><span style="font-family: Inter; font-weight: bold;">Alias</span><span style="font-family: Inter;"> column, give it a unique name to be used in the script. Latin letters and numbers are acceptable, and you can use an underscore to separate words. By default, the workspace code or module ID is used.</span></p>
<p style="line-height: 1.20; margin: 7px 0 7px 0;">After entering the activity details, click <span style="font-weight: bold;">Save</span> and <span style="font-weight: bold;">Publish</span> in the top pane of the settings window.</p>
<p style="line-height: 1.20; margin: 7px 0 7px 0;">With the module enabled, the activity will be available in the <a href="360012265552.html#process-page" class="topiclink">business process designer</a>, on the toolbar to the right of the modeling field, on the <span style="font-weight: bold;">Integrations</span> tab. You can add the graphical element on the process flow chart and <a href="module-action.html" class="topiclink">configure the settings for its execution</a>.</p>
<h2 class="p_Heading2"><a id="tracing" class="hmanchor"></a><span class="f_Heading2">Trace activity scripts</span></h2>
<p style="line-height: 1.20; margin: 7px 0 7px 0;">When an activity is published, you can collect information about the execution of its script. This helps you evaluate the duration of individual requests, optimize the code, and identify the causes of errors.</p>
<p style="line-height: 1.20; margin: 7px 0 7px 0;">To do this, enable tracing by activity in <span style="font-weight: bold;">Administration &gt; Developer Tools</span>. After that, you will be able to view the collected data by selecting the <span style="font-weight: bold;">Tracing</span> option in the activity settings.</p>
<p style="line-height: 1.20; margin: 7px 0 7px 0;">Read more about enabling tracing and trace information in the <a href="server-script-tracing.html" class="topiclink">Trace server scripts</a> article.</p>
<h2 class="p_Heading2"><a id="call-actions-in-scripts" class="hmanchor"></a><span class="f_Heading2">Call activity in scripts</span></h2>
<p style="line-height: 1.20; margin: 7px 0 7px 0;"><span style="font-family: Inter;">In business processes, custom function libraries can be created within modules through the use of actions. Unlike API methods, actions specify input and output variables with defined </span><span style="font-family: Inter; color: #0563c1;"><a href="360009707032.html" class="topiclink">types</a></span><span style="font-family: Inter;">. This helps to clearly understand what types of data need to be passed when calling an action and what the result of its execution will be.</span></p>
<p style="line-height: 1.20; margin: 7px 0 7px 0;"><span style="font-family: Inter;">Activities of the type </span><span style="font-family: Inter; font-weight: bold;">Script</span><span style="font-family: Inter;"> with the </span><span style="font-family: Inter; font-weight: bold;">Synchronous</span><span style="font-family: Inter;"> model can only be called in scripts.</span></p>
<p style="line-height: 1.20; margin: 7px 0 7px 0;"><span style="font-family: Inter;">An activity can be used:</span></p>
<ul style="list-style-type:disc">
<li style="line-height: 1.20; margin-top: 7px; margin-right: 0; margin-bottom: 7px;"><span style="font-family: Inter;">Within the module where it is configured: in scenarios of other actions, API methods, business processes, and event handlers.</span></li><li style="line-height: 1.20; margin-top: 7px; margin-right: 0; margin-bottom: 7px;"><span style="font-family: Inter;">In scripts of other system components that have an </span><span style="font-family: Inter; color: #0563c1;"><a href="optional-dependencies.html" class="topiclink">optional dependency</a> </span><span style="font-family: Inter;">on the module with this action.</span></li></ul>
<p style="line-height: 1.20; margin: 7px 0 7px 0;"><span style="font-family: Inter;">To call the activity, the </span><code><b>action</b></code><span style="font-family: Inter;"> property is used; it is available if an appropriate activity is published in the module. The method </span><code><b>call()</b></code><span style="font-family: Inter;"> is used to call it, and an object with the activitys input variables is passed as a parameter.</span></p>
<p style="line-height: 1.20; margin: 7px 0 7px 0;"><span style="font-family: Inter;">When accessing the </span><code><b>action</b></code><span style="font-family: Inter;"> property and the activity, the </span><code><b>?.</b></code><span style="font-family: Inter;"> operator is used, </span><span style="font-family: Inter; color: #0563c1;"><a href="https://tssdk.brix365.com/en/latest/index.html#elvis-operator-" target="_blank" class="weblink">optional chaining operator</a></span><span style="font-family: Inter;">. This is necessary to handle the scenario correctly in case the action is deleted from the module.</span></p>
<p style="line-height: 1.20; margin: 7px 0 7px 0;"><span style="font-family: Inter;">Note that if an input variable of the activity is mandatory and has a default value, it becomes optional in the input structure of the </span><code><b>call()</b></code><span style="font-size: 13px;"> </span><span style="font-family: Inter;">method. Regardless of the mandatory nature of the output variable, it also becomes optional in the output structure of the method.</span></p>
<p style="line-height: 1.20; margin: 7px 0 7px 0;"><span style="font-family: Inter;">As an example, consider an action that retrieves exchange rates from the Central Bank. The action has input variable: currency code (type </span><span style="font-family: Inter; color: #0563c1;"><a href="https://tssdk.brix365.com/en/latest/modules/_02_types_.html#tstring" target="_blank" class="weblink">String</a></span><span style="font-family: Inter;">) and current date (type </span><span style="font-family: Inter; color: #0563c1;"><a href="https://tssdk.brix365.com/en/latest/interfaces/_02_types_.tdate.html" target="_blank" class="weblink">Date</a></span><span style="font-family: Inter;">). The output variable is the exchange rate (type </span><span style="font-family: Inter; color: #0563c1;"><a href="https://tssdk.brix365.com/en/latest/modules/_02_types_.html#tfloat" target="_blank" class="weblink">Number</a></span><span style="font-family: Inter;">).</span></p>
<p style="line-height: 1.20; margin: 7px 0 7px 0;"><span style="font-family: Inter;">In module scripts, the action can be called as follows:</span></p>
<p class="p_CodeExample" style="white-space: normal; page-break-inside: avoid;"><span class="f_CodeExample">// Create an object for passing activity execution parameters — the currency code and current date</span><br />
<span class="f_CodeExample">let input: {</span><br />
<span class="f_CodeExample"> &nbsp; &nbsp;currency_code: TString;</span><br />
<span class="f_CodeExample"> &nbsp; &nbsp;date: TDate;</span><br />
<span class="f_CodeExample">};</span><br />
<span class="f_CodeExample">&nbsp;</span><br />
<span class="f_CodeExample">// Create an object that will store the result of the activity — currency code</span><br />
<span class="f_CodeExample">let output: {</span><br />
<span class="f_CodeExample"> &nbsp; &nbsp;currency_rate?: TFloat;</span><br />
<span class="f_CodeExample">}</span><br />
<span class="f_CodeExample">&nbsp;</span><br />
<span class="f_CodeExample">// Write currency code from the context, and the current date, in order to pass the date to the input variables of the activity</span><br />
<span class="f_CodeExample">input = {</span><br />
<span class="f_CodeExample"> &nbsp; &nbsp;currency_code: Context.data.currency_code,</span><br />
<span class="f_CodeExample"> &nbsp; &nbsp;date: new TDate(),</span><br />
<span class="f_CodeExample">};</span><br />
<span class="f_CodeExample">&nbsp;</span><br />
<span class="f_CodeExample">// Call the activity for getting the exchange rate set inside the module</span><br />
<span class="f_CodeExample">output = await Namespace.action?.get_currency_rate?.call(input);</span><br />
<span class="f_CodeExample">&nbsp;</span><br />
<span class="f_CodeExample">// Check if the result is received</span><br />
<span class="f_CodeExample">if (output) {</span><br />
<span class="f_CodeExample"> &nbsp; &nbsp;// Get data from the object that stores the result </span><br />
<span class="f_CodeExample"> &nbsp; &nbsp;Context.data.current_currency_rate = output.currency_rate;</span><br />
<span class="f_CodeExample">}</span></p>
<p style="line-height: 1.20; margin: 32px 0 7px 0;"><span style="font-family: Inter;">An activity can also be called from a script of a component that is not part of the module. For example, from a widget that belongs to a workspace or from an event handler of another module. To do this, in the component</span><span style="color: #202122; background-color: #ffffff;"></span><span style="font-family: Inter;">s script settings,set an optional dependency from the module with this activity. After this, the activity can be accessed using the </span><code><b>Imports</b></code><span style="font-family: Inter;"> constant. For more details, see <a href="optional-dependencies.html" class="topiclink">Optional dependencies</a>.</span></p>
<p style="line-height: 1.20; margin: 7px 0 7px 0;"><span style="font-family: Inter;">Suppose in a business process script in a workspace, you set up an optional dependency from the module in which the activity to retrieve exchange rates is configured. In the dependency settings of the module, a unique name </span><code><b>currency_module</b></code><span style="font-family: Inter;"> is set. The activity can be called from the process script in the following way:</span></p>
<p class="p_CodeExample" style="white-space: normal; page-break-inside: avoid;"><span class="f_CodeExample">// Call `get_currency` activity set up in the module</span><br />
<span class="f_CodeExample">// Pass the currency code and current date to the activity input variable</span><br />
<span class="f_CodeExample">const output = await Imports?.currency_module?.action?.get_currency_rate?.call({</span><br />
<span class="f_CodeExample"> &nbsp; &nbsp;currency_code: Context.data.currency_code,</span><br />
<span class="f_CodeExample"> &nbsp; &nbsp;date: new TDate(),</span><br />
<span class="f_CodeExample">});</span><br />
<span class="f_CodeExample">&nbsp;</span><br />
<span class="f_CodeExample">// Chech that the result of the activity is received</span><br />
<span class="f_CodeExample">if (output) {</span><br />
<span class="f_CodeExample"> &nbsp; &nbsp;// Write the exchange rate obtained with the module to the process context variable</span><br />
<span class="f_CodeExample"> &nbsp; &nbsp;Context.data.current_currency_rate = output.currency_rate;</span><br />
<span class="f_CodeExample">}</span></p>
<div class="bottom-nav">
<a id="prev-link" class="topic__navi_prev" href="extention-activities.html">
<span class="bottom-nav__arrow bottom-nav__arrow--prev"></span> <span
class="bottom-nav__link">extention-activities.html</span>
</a>
<a id="next-link" class="topic__navi_next" href="call-process-activity.html">
<span class="bottom-nav__link">call-process-activity.html</span> <span
class="bottom-nav__arrow bottom-nav__arrow--next"></span>
</a>
</div>
<!-- добавляет на страницу строку блок Была ли статья полезной? -->
<div class="feedback" id="feedback"><div class="feedback-help"><span><b>Was this helpful?</b></span><form action="" method="POST" class="feedback-form" id="feedback-form"><div class="feedback__popup feedback__popup-response" id="feedback__popup_thx" style="display: none;">Thanks for your feedback!</div><div class="feedback__popup" id="feedback__popup_why" style="display: none;"><div class="feedback__popup-header">Please specify why:</div><input type="radio" name="category" id="bad_recommendation" value="bad_recommendation"><label for="bad_recommendation">Recommendations did not help me</label><input type="radio" name="category" id="difficult_text" value="difficult_text"><label for="difficult_text">Article is hard to understand</label><input type="radio" name="category" id="no_answer" value="no_answer"><label for="no_answer">Didn`t answer my question</label><input type="radio" name="category" id="bad_header" value="bad_header"><label for="bad_header">Content does not match the topic</label><input type="radio" name="category" id="other_reason" value="other_reason"><label for="other_reason">Other</label></div><div class="feedback__popup" id="feedback__popup-other" style="display: none;"><div class="feedback__popup-header">How we can improve it?</div><textarea class="feedback__textarea" name="other" id=""></textarea><input type="submit" class="feedback__other-btn" value="Submit"></div><div class="feedback-form__btn-group"><input type="radio" name="useful" id="feedback__useful_yes" value="true"><label for="feedback__useful_yes"><img src="like.svg" class="small-img" alt="like"><spanclass="feedback-form__btn-group_yes-btn">Yes</spanclass="feedback-form__btn-group_yes-btn"></label><input type="radio" name="useful" id="feedback__useful_no" value="false"><label for="feedback__useful_no"><img src="dislike.svg" class="small-img" alt="dislike"><spanclass="feedback-form__btn-group_no-btn">No</spanclass="feedback-form__btn-group_no-btn"></label></div><select name="category"><option disabled="">Please specify why</option><option value="bad_recommendation" selected="">Recommendations did not help me</option><option value="difficult_text">Article is hard to understand</option><option value="no_answer">Didn`t answer my question</option><option value="bad_header">Content does not match the topic</option><option value="other_reason">Other</option></select><input type="submit"></form></div><div class="found_typo"><p style="margin: 0px; margin-top: 16px !important;"><span><b>Found a typo?</b></span> Select it and press <i>Ctrl+Enter</i> to send us feedback</p></div></div>
</section>
</div>
<aside class="article__sidebar" style="display:none">
<input type="checkbox" />
<div class="article__arrow"></div>
<div class="table-of-contents elma365-right" id="toc2Content">
<h3 class="h3-toc">In this topic</h3>
<nav id="toc2"></nav>
</div>
</aside>
</div>
</article>
</main>
<footer class="footer">
<div class="footer-container">
<div class="footer-mobile">
<ul class="footer-mobile__list"><li><a href="https://brix365.com/en/" target="_blank">BRIX</a></li><li><a href="https://tssdk.brix365.com/en/latest/" target="_blank">SDK</a></li><li><a href="https://api.brix365.com/en/" target="_blank">API</a></li></ul><ul class="footer-mobile__list"><li><a href="https://brix365.com/en/help/platform/get-trial.html">Platform</a></li><li><a href="https://brix365.com/en/help/ecm/ecm-functions.html">ECM</a></li><li><a href="https://brix365.com/en/help/service/service-functions.html">Service</a></li><li><a href="https://brix365.com/en/help/projects/projects-functions.html">Projects</a></li></ul>
</div>
<div class="footer-wrap">
<div><span class="mobile-question-popup">Send feedback</span><form method="POST" action class="question__popup question-xs" id="question__popup"><div class="question-wrap"><span class="close"></span><span class="title">Ask a question</span><label for="help_question" style="display: none;"></label><textarea name="help_question" id="help_question"></textarea><input type="submit" value="Send"></div></form><div class="hidden fade-in question-success-xs">Sent</div></div>
<div class="footer-flex-b">
<span class="footer-copy">&copy; 2025 BRIX</span>
<ul class="footer-list">
<li class="footer-item">
<a href="#" class="arrow-top" style="display: block;"></a>
</li>
</ul>
</div>
</div>
</div>
</footer>
<iframe name="hmnavigation" style="display:none!important"></iframe>
<script src="./jquery-ui.js"></script>
<!--script src="//cdn.jsdelivr.net/npm/featherlight@1.7.14/release/featherlight.min.js" type="text/javascript" charset="utf-8"></script-->
<script src="./jquery.tocify.min.js"></script>
<script src="./TypoReporter.min.js"></script>
<script src="./google-search.js"></script>
<script src="./main.js"></script>
</body>
</html>