get

To return a value of a given field

This function retrieves the value of a field. You can use get to access fields by their name or ID, making it easy to extract data for use in scripts and calculations.

Syntax

get(nid, string)

Return

text

number

boolean

void

Benefits of get

  • Easy to use: It makes it easy to get data from fields in a consistent way, no matter what type of data it is.

  • Integration: You can easily use get with other functions like set to update and manage data dynamically in your scripts.

  • More flexibility: The get function can fetch data using either the field's name or ID, making it easy to work with different field naming styles and database setups.

Using get can make it easier to access and work with data in Ninox, allowing for efficient data management and easy integration with other functions.

Examples

Here are some simple examples to show how the function works with different inputs.

get(this, "Name")

Return: Vania

get(this, "Yes/No")

Return: true

get(this, "B")

Return: 42

get(this, "")

Return: void

Traditional method

In a typical scenario, in checklist forms field names are often numbered. For example:

  • Object name 1, Value 1, Date 1

  • Object name 2, Value 2, Date 2

  • Object name 3, Value 3, Date 3

To collect all this data and place it into a subtable, you might traditionally use:

let me := this;
let myReport := Report;
let newSubRecord := (create Subtable);
newSubRecord.(
	Report := myReport;
	'Object name' := me.'Object name 1';
	Date := me.'Date 1';
	Value := me.'Value 1'
);
newSubRecord := (create Subtable);
newSubRecord.(
	Report := myReport;
	'Object name' := me.'Object name 2';
	Date := me.'Date 2';
	Value := me.'Value 2'
);
newSubRecord := (create Subtable);
newSubRecord.(
	Report := myReport;
	'Object name' := me.'Object name 3';
	Date := me.'Date 3';
	Value := me.'Value 3'
)
end

The traditional method requires you to specify each object individually. As the number of objects increases, your script grows and becomes more complex. With get and set, your script stays concise and manageable, regardless of how many objects you have.

Dynamic data collection with get and set

The get and set functions simplify this process. get pulls the value from the main record by building the field name dynamically based on the current index. Then, set pulls that value into the matching field in the new subtable record. Here's how you can use it:

let me := this;
let nameSpace := ["Object name", "Date", "Value"];
let myReport := Report;
for i in range(3) do
	let newSubRecord := (create Subtable);
	newSubRecord.(Report := me.Report);
	for name in nameSpace do
		set(newSubRecord, name, get(me, name + " " + (i + 1)))
	end
end

See also

set which updates the value of a given field.

Last updated