0

Link a subtable to a phantom table

I've been stuck on this script since last night. I want to create a phantom table from the Quotes table and the Prices sub-table. Everything works fine, except that I can't connect the main table and the sub-table in my phantom table, despite having tried everything except, obviously, the correct method. All I can do is create rows in my sub-table, but with no link to my main table.

 

let i := null;

let xcurrRec := Id;

let xNoCom := 'Order reference';

let xAgent := Work.Agent;

let xAgentTel := Work.'Tel agent';

let xAgentEmail := Work.'Email agent';

let xClient := Work.Client 'Company name or First name Last name' + ".

"

" +

Work.Client.'Full address';

let xClientTel := Work.Client.'# main Phone'.'Phones'.'Phone number';

let xClientEmail := Work.Client.'Main email'.'Email address';

let xPrest := Provider;

let xRef := 'References' + ". Variant: " + Variant;

let xInstructions := Description;

let xDsteConf := 'Confirmation date';

let i := (create 'PRINT order');

let xiID := i.Id;

i.(OrderNo := xNoCom);

i.(Agent := xAgent);

i.(AgentTel := xAgentTel);

i.(AgentEmail := xAgentEmail);

i.(ClientFullAddress := xClient);

i.(ClientTel := xClientTel);

i.(EmailClient := xEmailClient);

i.('DataProvider' := xPrest);

i.(Ref := xRef);

i.(DateConf := xDsteConf);

i.(WorkInfo := xInstructions);

          for j in select Price where Quotation.Id = xcurrRec do

                    let k := (create 'PRINT order price');

                    k.('Data' := j.'Data');

                    k.('Quantity' := j.'Quantity');

                    k.('Unit price' := j.'Unit price');

                    k.('Total excluding tax' := j.'Total excluding tax');

                    k.('# Quotation' := j.'Quotation # (Prest.)')

          end;

printRecord(record('Order PRINT',number(i)), "Your order");

delete (select 'Order PRINT')

2 replies

null
    • Fred
    • 1 mth ago
    • Reported - view

    Whenever you use the create() command it is like going into that table and clicking the new record button. Everything is blank. So you need to tell Ninox how you want to link the tables. I don't know you schema so I can't say exactly what field names you need to use, but check after each create().

    Your first one is:

    let i := (create 'PRINT order');
    

    What is the reference field name in 'PRINT order' that you need to link to the xcurrRec variable?

    Then in:

    let k := (create 'PRINT order price');
    

    You need to create a link to both Price and Quote? You have Price in the variable j and Quote in xcurrRec.

      • pascalp
      • 1 mth ago
      • Reported - view

        What a dummy I am. I just discovered that I was already using this formula in another table. I copied it and now it works. I should think about getting some rest. I've lost an evening and a whole night.
      Thanks Fred. 

Content aside

  • Status Answered
  • 1 mth agoLast active
  • 2Replies
  • 21Views
  • 2 Following