> For the complete documentation index, see [llms.txt](https://docs.ninox.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ninox.com/ninox-scripting/automate-your-workflows/work-with-functions/location-and-devices.md).

# Location and devices

Location and URL functions let your scripts work with location values and URLs.&#x20;

In this chapter, you will learn how to:

* Create location values.
* Hand off actions to the device.
* Encode and decode URL parts safely.

<table><thead><tr><th width="197.16015625">Function (A-Z)</th><th>Task</th></tr></thead><tbody><tr><td><code>latitude()</code></td><td>Return the latitude from a location value</td></tr><tr><td><code>location()</code></td><td>Return a location value from a title and coordinates</td></tr><tr><td><code>longitude()</code></td><td>Return the longitude from a location value</td></tr><tr><td><code>openURL()</code></td><td>Open a website, map, or app link</td></tr><tr><td><code>phone()</code></td><td>Return a phone value with a call action</td></tr><tr><td><code>url()</code></td><td>Return a link value from text or query data</td></tr><tr><td><code>urlDecode()</code></td><td>Decode URL-encoded text</td></tr><tr><td><code>urlEncode()</code></td><td>Encode text for safe URL use</td></tr></tbody></table>

## Work with location values

Use these functions when you want to work with a location value or pass coordinates to another service.

### Work with a location value

Use `location()` when you want to create one location value from a title, latitude, and longitude.

Use it when you want to:

* Store coordinates in a location field.
* Keep a title and coordinates together in one value.
* Pass one location value to another field or function.

`location(string, number, number)`

* `string`: the title for the location&#x20;
* first `number` : the latitude
* second `number` : the longitude

`location()` returns a location value.

Tips:

* Use a clear title so users can recognize the saved location.

#### Let’s take a look at some examples:

```ninox
address := location("Ninox Office", 52.5235175, 13.3989201)
```

Stores the location with the given coordinates in the `address` location field.

## Open links and start device actions

Use these functions when you want a script to hand off work to the device, browser, or another app.

### Return a URL value

Use `url()` when you need a URL as data instead of opening it immediately.

Use it when you want to:

* Store a link in a field or variable.
* Reuse a generated link in a later script step.
* Pass a URL into another function.
* Add URL-encoded query values from a JSON object.

`url(any)`\
`url(any, JSON)`

* `any`: the value you want to convert to a link
* `JSON`: optional query values to append in URL-encoded form

`url()` returns a link value.

#### Let’s take a look at some examples:

```ninox
url("https://ninox.com")
```

Shows the Ninox website as a link value with an internet button.

```ninox
url("https://ninox.com", {Name: "Max Mustermann"})
```

Returns `https://ninox.com?Name=Max%20Mustermann`.

Tips:

* Ninox does not validate whether the passed value is a valid URL.
* Use the JSON argument when you want to append query values safely.
* Use `url()` when you need the link as a value.
* Use `openURL()` when you want to open that link right away.

## Encode and decode URL parts

Use these functions when text needs to travel safely inside a URL.

### Encode text

Use `urlEncode()` to turn text into a URL-safe form.

Use it when you want to:

* Put user input into a query string.
* Build safe search or API URLs.
* Avoid broken links caused by spaces or special characters.
* Convert plain text into URL-compliant text.

`urlEncode(string)`

* `string`: the text you want to encode for safe URL use

`urlEncode()` returns a string.

#### Let’s take a look at some examples:

```ninox
urlEncode("hello world")
```

Returns `hello%20world`.

```ninox
"https://ninox.com?Name=" + urlEncode("Jane Doe")
```

Returns `https://ninox.com?Name=Jane%20Doe`.

Tips:

* Encode dynamic values, not the full URL structure.
* This is especially useful for search terms and API parameters.

### Decode text

Use `urlDecode()` to turn URL-encoded text back into normal text.

Use it when you want to:

* Read encoded query values.
* Show stored URL parts in plain text.
* Reverse earlier encoding.
* Decode URL-compliant text into readable text.

`urlDecode(string)`

* `string`: the encoded URL text you want to decode

`urlDecode()` returns a string.

#### Let’s take a look at some examples:

```ninox
urlDecode("hello%20world")
```

Returns `hello world`.

```ninox
urlDecode("https://ninox.com?Name=Jane%20Doe")
```

Returns `https://ninox.com?Name=Jane Doe`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://docs.ninox.com/ninox-scripting/automate-your-workflows/work-with-functions/location-and-devices.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.
