14. Mail Template

22 июня 2021 г.

19:00

DialogScript  Called in mail-template with

Public Function CCC_HtmlMailText(obj As IEntity) As String

  Return "<h1 style='color:red'>" & obj.Display & "</h1>"

End Function

$SCRIPT(CCC_HtmlMailText):HTML$

From \<https://www.oneidentity.com/community/identity-manager/f/forum/30123/how-to-present-a-table-with-dynamic-data-in-email-templates>

Build Links

Script: VI_BuildITShopLinks


Using scripts in mail templates

For more information about using scripts, see the One Identity Manager Configuration Guide.

In mail templates, any parameters can be used when calling a script.

Syntax

\$SCRIPT(ScriptName, "Options")\$

The Options parameter is optional and is passed as a string. Custom parameters can be coded in any way in this string. Quotes ("") are masked by doubling. In the script, the parameter is passed as the second parameter after the base object. The base object can be either IEntity or ISingleDbObject.

Script example

Public Function CCC_Script(baseEntity as IEntity, options as String) as String

Dim arr = options.Split("|"c)

Dim p1 = arr(0)

Dim p2 = arr(1)

End Function

Example of use in mail templates

\$SCRIPT(CCC_Script, "Param1|Param2")\$

Support for dynamically generated HTML code in mail templates

For detailed information about using dollar (\$) notation, see the One Identity Manager Configuration Guide.

In dollar notation, you can select the HTML type. The HTML code is accepted in scripts and columns but not masked. There is no security check.

Example script with HTML code:

Public Function CCC_HtmlMailText(obj As IEntity) As String

Return "\<h1 style='color:red'>" & obj.Display & "\</h1>"

End Function

Call in mail template:

\$SCRIPT(CCC_HtmlMailText):HTML\$

From \<https://support.oneidentity.com/technical-documents/identity-manager/8.1.3/operational-guide/13#TOPIC-1481199>


Для того, чтобы передать из процесса данные в шаблон нужно в параметрах шага процесса по отправке почты указать параметр и его значение

В шаблоне указываем

\$PC(Roles)\$

Чтобы получить из скрипта результат:


Select the category IT Shop | Basic configuration data | Mail templates | Predefined.

Email notifications are generated through default processes during process handling. To use email notifications based on mail templates for other business procedures, for example creating user accounts, you have to create custom mail templates and processes. The process task "SendRichMail" is provided for this through the process component "MailComponent".

https://support.oneidentity.com/technical-documents/identity-manager/8.0/configuration-guide/93

Не дает менять предустановленные шаблоны.

Надо скопировать его в новый и там уже править.


Вставка параметров в шаблон

Надо в процессе задействовать ParamName и ParamValue

В шаблоне обращаемся так

\$PC(ParamName)\$

Результат выполнения скрипта можно отобразить так:

\$Script(VI_GetRichMailSignature_Caption)\$

---

Чтобы корректно отображался Mail Definition - надо в параметрах процесса передавать Culture (Value = "ru")

----

Чтобы получить результат выполнения скрипта с параметром, можно в параметрах шага процесса указать

Value = CCC_Department_Get_XDateInserted(\$DepartmentName\$)

И затем вызвать в шаблоне этот параметр

\$PC(Date1)\$

Сам скрипт:

Public Function CCC_Department_Get_XDateInserted(ByVal department As String) As String

' Get the SQL formatter for our connection

Dim f As ISqlFormatter = Session.SqlFormatter

' Build the WHERE clause for our request

Dim where As String = f.Comparison("DepartmentName", department, ValType.String)

Dim Date1 As DateTime

Date1 = Session.Source.GetSingleValue(Of DateTime)("Department", "XDateInserted", where)

Return Date1.ToString()

End Function

------

Получение адреса руководителя департамента

Поместить в pre-script generating

values("ContactEmail") = \$FK(UID_Department).FK(UID_PersonHead).ContactEmail\$

В значении параметра писать

Value = values("ContactEmail")


Передача параметров

Указать BaseObject параметрах процесса XObjectKey

Value = \$FK(UID_Person).XObjectKey\$