---
title: "Functions"
canonical: "https://docs.getxray.app/space/XRAYCLOUD/44566594/Functions"
format: markdown
---
<details>
<summary>Table of Contents</summary>

> Macro (toc)
</details>

# Set

This function allows you to create new variables that will be treated as fields ([mappings](https://getxraydocs.atlassian.net/wiki/spaces/XRAYCLOUD/pages/44570571)), and then use it to change the values of those variables.  
The new value passed to the Set function can be plain text, an existing field (mapping), or a Function field.

**Definition: **`${set(<variable name>,<new value>)}`

##### **Sample Code**

```
Define a variable "count" with value "0" and then use it as a normal field.

${set(count,0)}  
${count} 
 
Define a variable "newKey" with the value of field ${Key} and then use it as a normal field.

${set(newKey,${Key})}  
${newKey}

Define a variable "TodayDate" with the value of the current date calculated with Javascript and then use it as a normal field

${set(TodayDate,%{(new Date()).getDate() + "/" + ((new Date()).getMonth()+1) + "/" + (new Date()).getFullYear()})} 
${TodayDate} 
 
```

> ℹ️ - The function Set can be also used to change the value of existing fields (i.e., existing mappings), but it has a limitation: <u>all</u> occurrences of that field in the document will be replaced with the value of the <u>latest</u> Set that is applied.
> ℹ️ - The values of all the variables (mappings) created with the Set function and used on the header/footer of a Template will correspond to the last value passed to the Set function.

# Prop 

This function allows you to define properties that will be used later by the [Document Generator](https://getxraydocs.atlassian.net/wiki/spaces/XRAYCLOUD/pages/44565169) during document processing.

Usually, integrations require some extra configuration such as security tokens, API keys, and others.

## Specification

| **Function Name** | **Prop** |
| --- | --- |
| First Parameter | Key |
| Second parameter | Value |

## Notation

`${prop(Key,Value)}`

## Example

```
${prop(my.first.property.key,qwerty12345)}
${prop(service.api.key,84f7970c-5f70-47d9-a4f2-c75151820ba0)}
${prop(service.api.username,userAdmin)}
```

# Image Loader

<span style="color: #000000">This function loads an image from a URL and puts that on the document. You can also specify the width and/or height of the images.</span>

**Definition: **`!{<URL>}`

  
Below are two examples: 

![Figure 1 - Example](media://29a6a938-c248-4969-a853-e1f84cc3a501)

or 

![Figure 2 - Examples](media://db734da1-0999-45c3-9db1-8e66e57ca939)


After exporting the document, the generated file is going to see this (Figure 3):

![Figure 3 - Example](media://050c45aa-7aab-4483-aa6a-c65ae418c4ae)

# QRCode 

This function allows you to create a QR code image on the template. It accepts as content other Document Generator mappings.

**Definition: **`${qrcode('<content>',(Optional) <width>, (Optional) <type>)}`

##### **Sample Code**

```
Draws a QR Code image with the content Hello World.
${qrcode(‘Hello World’)}


Draws a QR Code image with the Issue Key as content.
${qrcode(‘${Key}’)}


Draws a QR Code image with a Javascript result as content.
${qrcode(‘%{‘${Key}’.substring(0,2)}’)}

Draws a QR Code image with the content noreply@xpand-it.com and the QR Code type email.
${qrcode(‘noreply@xpand-it.com’,email)}


Draws a QR Code image with the content Hello World and width size 200px.
${qrcode(‘Hello World’,200)}


Draws a QR Code image with the content Hello World, width size 200px and the QR Code type email.
${qrcode(‘hugo.freixo@xpand-it.com’,200,email)}
 
```

## QR Code Content

You can use any mapping on the content of the QR Code function, **but you must be careful because Markups won't generate the expected result.**

If you try to export `${qrcode(‘${wiki:Description}’)}` or `${qrcode(‘${html:Description}’)}` the content of the QR Code won't be correct.

You can apply format mappings such as *dateformat*, *numberformat*, *fullname* or *emailaddress*.

## QR Code Types

> ℹ️ <span style="color: #000000"> You can learn more about QR Code types </span><span style="color: #000000">[here](https://github.com/zxing/zxing/wiki/Barcode-Contents)</span><span style="color: #000000">. These Types may depend on the QR Code reader and the obtained result may be different than expected.</span>

- **Text** - plain text. It's the same as not having a Type defined.
- ** URL** - the content will be read as a URL link.
- ** Phone** - the content will be read as a phone number.
- ** Geolocation** - the content will be read as GPS coordinates. Content example: "41.714316, -8.811993".
- ** Email** - the content will be read as an email.
- ** Wifi** - the content will be read as a WiFi connection. Content example: T:WPA;S:NetworkName;P:NetworkPassword;
- **VCard** - the content as a VCard. Please note that not all devices are prepared to understand [VCard details](https://en.wikipedia.org/wiki/VCard).

## QR Code Width

The width of the QR Code must be a value between 0 and 409 (pixels).  
If you introduce a value outside this interval, the width will be set to its default value (177px).

You must choose a width large enough for the amount of content in the QR Code. Usually, 100px - 200px is enough.


<details>
<summary>Support/Troubleshooting</summary>

If you have questions or technical issues, please [contact the Support team via the Customer Portal (Jira service management)](https://jira.getxray.app/servicedesk/customer/portal/2/user/login?destination=portal%2F2%2Fcreate%2F28) or [send us a message using the in-app chat](https://getxraydocs.atlassian.net/wiki/spaces/XRAYCLOUD/pages/44577312).
</details>