Is it possible to link automatically (via a function) fields in two tables that contain the same text?
68 replies
-
I'm a bit mystified. This code compiles with no errors but doesn't work:
let ShipsLogRecordID := Id;
let StartDate := 'Log Start Date';
let EndDate := 'Log End Date';
for DeckLogRec in (select DeckLog)["Log Date" >= StartDate and "Log Date" <= EndDate] do
DeckLogRec.(ShipsLogRef := ShipsLogRecordID)
endThe code is on a record level button in a table called ShipsLog. The ShipsLog record has fields to specify a date range. For every record in the DeckLog that falls within the date range specified by the fields in the ShipsLog, the code should set the ShipsLogRef (a reference field in the DeckLog) to link to the ShipsLog. It doesn't seem to do anything. What am I doing wrong?
-
greetings from cologne (germany),
Sean may I ask since the initial post is around 3 years old, if the database structure may have been changed since that?
It is, that when I try to use your code example which begins with
let myTable1Id := (select Table1).Id;
I directly get an errormessage showing the field "Id" is unknown. I was expecting this might be a systems field, like "Nr", is it?
thx -
I am having a similar problem, I am trying to program a button on a record in my Transactions table to automatically select the appropriate record from my Tax Table (N:1) .
This is what I have but I am still learning, it doesn't do anything when I click the button.
-
Hi there
I used the code from Ben and changed "parent" in
do j.(parent := item(parentId,i))
into "child" and this has worked very well for some time. Here is the full code:
let parentId := (select parent).Id; let parentField := (select parent).field; let parentCt := count(parentId); for i in range(0, parentCt) do for j in (select child)[field = item(parentField, i)] do j.(child := item(parentId, i)) end end
However, now that the data is expanding (+/- 1000 rows in both parent and child table); it takes considerably longer to retrieve the data. Any idea as to what the problem might be? Would it be a solution to limit the range, so instead of "0", which is the oldest row, Ninox should only look in the last 50 odd rows, for example?
-
May the value of “field” in either table be changed? To say it otherwise, once a child is linked to a parent, can it become necessary to link it to another parent?
-
Actually Alain, the field value is a formula:
creation date + person Id
So, one person can have several rows in the subtable (child) , whereas in the parent table it has to match the results based on the the same unique field value (also identical formula). The results in child table are pulled in from an external source. Since the formula is /creation date + person ID/, the value does not change after it is created. Now it can take to up to one minute before all the results in the parent have been matched with the child, and it feels like this time is increasing as the number of rows increases.
-
So, if if the children that have been linked to a parent stay linked with the same parent forever, one only needs to take care of the orphans, which should take less time than processing the whole tables again and again.
for c in select child where child = null do c.( let f := field; child := first(select parent where f = field) ) end
-
Thank you Alain; I'm using the cloud version. I've tried the "do as server" in front of the formula but it still takes around 60 seconds to match the results.
Content aside
-
1
Likes
- 1 yr agoLast active
- 68Replies
- 15918Views
-
7
Following