---
title: "Functions"
canonical: "https://docs.getxporter.app/space/XPORTERCLOUD/526934/Functions"
format: markdown
---
> Macro (rw-ui-expands-macro)
> 
> > Macro (rw-expand)
> 
> > Macro (toc)

## Set Function

This function allows you to create new variables that will be treated as fields ([mappings](https://docs.getxporter.app/space/XPORTERCLOUD/558575)). You can then use these variables to change their values.

The new value passed to the Set function can be plain text, an existing field (mapping), or a Functions field.

In templates with [static sections](https://docs.getxporter.app/space/XPORTERCLOUD/428193/Static+Sections+for+Bulk+Export), you can create new variables outside those sections and use them inside the same static sections.

**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 *Set* function <span style="color: #0d0d0d">can also change the value of existing fields (i.e., existing mappings), but with a </span>**<span style="color: #0d0d0d">limitation</span>**<span style="color: #0d0d0d">: all occurrences of that field in the document will be replaced with the value of the latest Set function applied.</span>
> ℹ️ - The values of all variables (mappings) created with the *Set* function and used in the header/footer of a template will correspond to the last value passed to the *Set* function.

## Prop Function

<span style="color: #0d0d0d">This function allows you to define properties used later by </span>[<span style="color: #0d0d0d">Xporter</span>](https://marketplace.atlassian.com/apps/891368/xporter-export-issues-from-jira?tab=overview&hosting=cloud)<span style="color: #0d0d0d"> during document processing. </span>

### 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 Function

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

**Definition**

|  |
| --- |
| `!{<URL>}` |

  
Below are two examples (Figures 1 and 2). 

![Figure 1 - Image loader](media://47526216-baed-4661-aee6-01a3940df10c)

or 

![Figure 2 - Image loader](media://57a22300-14b8-48cd-a97f-9d651b837ecb)

> ℹ️ <span style="color: #000000"> </span><span style="color: #0d0d0d">To implement the following code snippet, refer to the iteration instructions provided</span><span style="color: #000000"> </span>[<span style="color: #000000">here</span>](http://confluence.getxray.app/display/XPORTER/Xray+for+JIRA#XrayforJIRA-ExportingaTestExecution)<span style="color: #000000">.</span>

Once exported, the resulting document will resemble the example shown in Figure 3.

![Figure 3 - Generated file](media://60450536-2586-407f-b72a-c284600a71c8)

> ℹ️ <span style="color: #000000"> This functionality is available for Excel templates on Xporter V5.3.0 and higher.</span>

## QRCode Function

<span style="color: #0d0d0d">This function enables the creation of a QRCode image within the template. It accepts other Xporter mappings as content.</span>

### 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

While any mapping can be used within the QR Code function, it's important to note that certain markups may not yield the expected result.

For instance, attempting to export `${qrcode('${wiki:Description}')}` or `${qrcode('${html:Description}')}`, the QR Code content may not display correctly.

You can also apply formatting 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</span>](https://github.com/zxing/zxing/wiki/Barcode-Contents)<span style="color: #000000">. T</span><span style="color: #0d0d0d">he interpretation of these types may vary depending on the QR Code reader used, and the resulting output may differ from expectations.</span>

- **Text** - represents plain text, <span style="color: #0d0d0d">similar to not having a type defined.</span>
- ** URL** - the content is read as a URL link.
- ** Phone** - the content is <span style="color: #0d0d0d">interpreted</span> as a phone number.
- ** Geolocation** - the content is <span style="color: #0d0d0d">recognized</span> as GPS coordinates. Content example: "41.714316, -8.811993".
- ** Email** - the content is <span style="color: #0d0d0d">identified</span> as an email <span style="color: #0d0d0d">address</span>.
- ** WiFi** - the content is <span style="color: #0d0d0d">recognized as</span> WiFi connection. Content example: `T:WPA;S:NetworkName;P:NetworkPassword; `
- **VCard** - the content is <span style="color: #0d0d0d">treated </span>as a [VCard](https://en.wikipedia.org/wiki/VCard). Not all devices are prepared to understand VCard details.

### 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 default to 177px.

Ensure you choose a width that accommodates the amount of content in the QR Code. Typically, 100px to 200px is sufficient.


<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://docs.getxporter.app/space/XPORTERCLOUD/18251779/In-App+Chat+Support).
</details>