Get data of table in same application

Hello, I wonder if there is any way to get data of table A to table B without relation link.

Example:
I have table Numerical series
And table Contracts

I do not want to create link because I do not need any of records data just name of that table.

In table Numerical series I want to save predefined “IDs” like year/xxx or similar and if it’s active then use it in another table (like Contracts).

I’ve tried doo.table.getData(numericalSeries); but it return “numericalSeries is not defined”.

Hello Thomas,

The problem might be that the numericalSeries is not in the quotation marks. Try the following:

let result = await doo.table.getData(‘numericalSeries’);
console.log(result);

Please, let me know if it worked :slight_smile:

Thanks it works. :slight_smile:

Just posting full solution for others:

//Automatic ID function with table NumericalSeries
{
	// get data where [Agenda == Contracts and Active == true]
	let resultNumericalSeries = await doo.table.getData('numericalSeries', 
																{filter: [	
																		{field: "NUMS_agenda", operator: "in", value: "Contracts"},
																		{field: "NUMS_active", operator: "eq", value: true}
																], filterOperator: "and"}
                                                       );

			// if some record exists
			if (resultNumericalSeries.data.length > 0) {
					// save value of field Prefix to variable
					var nsPrefix = resultNumericalSeries.data[0].fields.NUMS_prefix;
					// save value of field Number to variable
					var nsNumber = resultNumericalSeries.data[0].fields.NUMS_number;
					// save Number length (summ of characters) to variable
					var Length = nsNumber.length;
					var Prefix = nsPrefix
			} 
			// else default values
			else {
					var Length = 2;
					var Prefix= "undefined";
			}

	// get the one last record of table Contracts where ContractNo contains Prefix value
	const resultContracts = await doo.table.getData('Contracts',
														{filter: [{field: "CON_contractNo", operator: "contains", value: Prefix}], limit: 1}
												);

			// if some record exists 
			if (resultContracts.data.length > 0) {
					// save value of field ContractNo to variable
					var lastID = resultContracts.data[0].fields.CON_contractNo;
					// save value of Prefix to new variable 
					var lastPrefix = lastID.substr(0, lastID.length -Length);
					// save value of Number to new variable 
					var lastNumber =parseInt(lastID.substr(lastID.length -Length));
			}
			// if records doesn't exist but there is new active record in table Numerical series
			else if (Prefix !="undefined") {
					var lastPrefix = Prefix;
					var lastNumber = 0;
			}
			// else start from 0
			else {
					var lastNumber = 0;
			}

	// adding 1 to last number
	var nextNumber = lastNumber+1;

	// convert Number to String
	var paddingNumber = nextNumber + '';

			// if length of number is less than Length value then add "0"
			while (paddingNumber.length < Length) {
					paddingNumber = "0" + paddingNumber;
			}

	// save new ID to variable
	var newID = lastPrefix + paddingNumber;
	// set value this value into field
	doo.model.<[Contract No (CON_contractNo)]>.setValue(newID);
}
2 Likes

Hi, I want to do something similar. I tried to write something by quoting your code, but I couldn’t get results because I’m a newbie in this business.
The topic is here:
https://faq.tabidoo.cloud/t/pulling-data-from-another-table-based-on-condition/303
I would be glad if you help.
Or if you share the template of your own application with me, I can use it by making changes on it.
Thanks.

Hello,
I have answered the topic in your link.
I hope that helps.
Regards
Michal