# Custom Functions

### Helpers

The next helpers are available in any custom function

```javascript

const helpers = {
    displayMessage //displayMessage("msg", "title", duration)
    displayError //displayError("msg", "title", duration)
    getCurrentUser,
    moment,
    get,
    set,
    form,
    options,
    jsPDF,
    dayjs,
    sendLog,
    getCurrentLocationAsync,
    generateIdv4 //generates a new Guid value
    sendEmailAsync,
    setUserLogo,
    clearUserLogo,
    setUserMenu,
    clearUserMenu,
    closeModal, //close feature modal container
  };
```

#### Set Field Value

Allows to set a value into the context

```javascript
helpers.form.setFieldValue("fieldNamePath", value)
```

#### Get current user

Allows to get the current logged user

#### Get current location

```javascript
//async call
helpers.getCurrentLocationAsync()
    .then(result => helpers.options.setFieldValue("fieldName", result));
    
//result object structure
// {
//    latitude: 9.161733, 
//    longitude: -74.6406, 
//    mapUrl: "https://www.openstreetmap.org/#map=18/6.161733080440801/-75.64064618359605"
// }
```

{% hint style="info" %}
The user should provide permissions to allow this function to work, otherwise, this will return null
{% endhint %}

{% hint style="warning" %}
Available in version 2.2.19 and above
{% endhint %}

#### Dayjs

Date utils library: <https://day.js.org/>

#### jsPDF

Pdf Library <https://github.com/parallax/jsPDF>

#### Send Log

Allows to send custom logs remotely.

More details here: [Debugging](/dev/configurations/debugging.md#how-to-send-custom-logs)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://codenull.gitbook.io/dev/configurations/components/forms/custom-functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
