Location and devices
Learn how to read device location, open links, start calls, encode URLs, and scan barcodes in Ninox scripts.
Location and URL functions let your scripts work with location values and URLs.
In this chapter, you will learn how to:
Create location values.
Hand off actions to the device.
Encode and decode URL parts safely.
latitude()
Return the latitude from a location value
location()
Return a location value from a title and coordinates
longitude()
Return the longitude from a location value
openURL()
Open a website, map, or app link
phone()
Return a phone value with a call action
url()
Return a link value from text or query data
urlDecode()
Decode URL-encoded text
urlEncode()
Encode text for safe URL use
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)
stringthe title for the locationfirst
number: the latitudesecond
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:
Stores the location with the given coordinates in the address location field.
Start a call action with phone()
Use phone() to convert a value into a phone value with a call action where calling is supported.
Use it when you want to:
Reduce copy and paste.
Show a formula field as a callable phone field.
Extract a phone number from text and make it callable.
phone(number), phone(string)
numbernumber value to be used as phone numberstringtext value for phone numbers that start with+, include leading zeros, or contain spaces
phone() returns a phone value.
Let’s take a look at some examples:
Shows the text in a phone number format and lets users start a call on supported clients.
Shows 911 as a phone value with a call action.
Extracts a phone number from message and shows it as a callable phone value.
Tips:
Call support depends on the client and device.
Ninox does not validate whether the passed value is a real phone number.
Keep phone numbers in a clean format. Otherwise, you will receive an error message when you try to call.
This is useful for extracting a phone number from longer text.
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.
Open a website or link with openURL()
Use openURL() to open a URL directly.
Use it when you want to:
Open a website from a button.
Send users to a download link.
Convert a string generated from your data into a valid link and open it.
openURL(string)
stringthe URL you want to open
openURL() returns no value.
Let’s take a look at some examples:
Opens the Ninox website.
Opens Google Maps and shows the location from the current record's "Street", "Zip", and "City" fields.
Tips:
openURL()runs only on the client.Build the full URL before you open it.
The function encodes the string so it becomes a valid link.
Use
urlEncode()for dynamic query values.
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)
anythe value you want to convert to a linkJSONoptional query values to append in URL-encoded form
url() returns a link value.
Let’s take a look at some examples:
Shows the Ninox website as a link value with an internet button.
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)
stringthe text you want to encode for safe URL use
urlEncode() returns a string.
Let’s take a look at some examples:
Returns hello%20world.
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)
stringthe encoded URL text you want to decode
urlDecode() returns a string.
Let’s take a look at some examples:
Returns hello world.
Returns https://ninox.com?Name=Jane Doe.
Last updated
Was this helpful?