Is it possible to link automatically (via a function) fields in two tables that contain the same text?

Ninox Profile

@Ben, I didn't have a problem creating a Reference from the "child" or "many" table. I did find that if I created the Reference from the "parent" or "one" table it would reverse the (1 : N) and that's not how you want it to work. If you have multiple "child" table that you want to link to the "parent" table you can modify the code to do that.

 

for oneRec in select OneTable do
for manyRec1 in select ManyTable1 where Text = oneRec.Text do
manyRec1.(OneTableRef := oneRec.Id)
end;
for manyRec2 in select ManyTable2 where Text = oneRec.Text do
manyRec2.(OneTableRef := oneRec.Id)
end
end

 

Hope that helps.

M

Hi Sean

Like otherd above I need to do this and have tried various examples from the above but am also getting the same field not found error.

I’m using the cloud version and dearly would like to get my imported table linked as have over 7000 records to link.

Would you mind clarifying from the above what script was successful.

As one of the options gave m no error and run but did nothing !

So to be clear..

My Parent table is called ‘Customers’ (the ONE Table)

My Child table (import) is called ‘OldDocs’ ( the many Table)

‘Olddocs’ (ONE) is related to main table ‘Customers’ (Many)

and both tables have a ‘CustID’ field (text field) and all records are populated

ie ‘customers’ record has CustID (eg “MEL501”)

‘OldDocs’ has many forms that have a unique sequence number job1 , job 2 etc but also have common field CustID with “MEL501”)

So there could be say 35 Olddoc that need to link to 1 main customer form/table

 

I’ve tried it with the script on the main and or child table and in buttons but alsa geeting soemthing wrong

If you could give me a definitive script fro cloud version that will do the job and confirm where to put the script

that would be a great help.

Kind regards

 

Mel

 

 

Ninox Profile

Hi Mel, Here is the code I would use...

 

for oneRec in select OneTable do
for manyRec in select ManyTable where Text = oneRec.Text do
manyRec.(OneTableReference := oneRec.Id)
end
end

 

There is a LinkTables database in the Webinar EN 2020 team where you can see how it works. The code goes in a button. Also, you might need to put it inside do as server.

M

Hi Sean

Okay thats vrillinat will give this a go

After I“ve finished wtahcing the Trump/Biden election affair (Even us Brits do look at whats going on :-)

Kind regards

Mel

Ninox Profile

I“m afraid our politics have lost its entertainment value for me. 😏

 

Best regards,

Sean

M

Appologies to all for the terrible typing !!!!

Had a massive motorbike accident recently and whilst still on the mend am having to type with just one finger and using the wrong hand !

Mel.

M

sorry but what is do as server all about? 

Ninox Profile

You can find information about do as server here...

 

https://ninox.com/en/manual/api/http-calls

 

M

Sean

i think the links as well as piccture uploading are now broken

Ninox Profile

Mel, yeah, it“s definitely looking like amateur hour here at Ninox. I guess they”re incapable of being motivated by either pride or embarrassment.

Reply