Add/Insert record on button click
Hello,
I am trying to create a new record on button click, however it is not able to find the specified column in the target table. Am I missing something?
Attached are the screenshots of two tables (Accounts Receivables and Orders)
I don't understand why is this happening, but I am not able to create record in the AccountReceivables table for recording a payment received for an Order.
6 replies
-
i’ve found that “this” really only works when in a variable. There are moments that it works inside code but it is too inconsistent to try to remember when.
So put add a new line 1 with:
let t := this;
then use t and it will work.
-
said:
Clarification: What does this signify here? does it refer to the whole table in context or the current record in that table (Orders table)?"this" points to the current record.
said:
Problem: There is a reference to the Customers table in both the tables (Account Receivables and Orders). I am trying to copy the First and Last name of the customer in the new record being created in AccountReceivables from the Orders table, but it does not get copied.I see you made a new record in Account Receivables, but I don't see you making a link to a Customer record. Once you do that then you don't need to copy anything as it will link to the same record.
I'm guessing you want to link to the same Customer that is in the Orders record. If that is true, paste the code update that shows setting Customer in Account Receivables to Customer in Orders.
-
said:
customers is linked to both AccountReceivables and Orders tables separately, so doesn’t that mean that there is an inherent relation between all three tables. Why do I need to link the same customer that is in Orders record.You have to make those links when you create a new record.
When you use the create command it like going to the Account Receivables table and creating a new record. When you do that is the customer reference field linked to anything? It is not, you have to tell it what record in customer you want to link it to.
So you have to explicitly state how the customer field needs to be linked when you create the new record.
let t := this; let newReceipt := (create 'Account Receivables'); newReceipt.( 'Order Number' := t.'Order Number'; 'Receipt Date' := today(); 'Receipt Amount' := t.'Pmt Received'; 'Mode of Receiving' := t.'Mode of Payment'; Customer := t.Customer; );
-
Awesome, I could not remember that just like even though Customer is a reference field in the Orders or AccountReceivables form, we still have to select the customer from the Customers table, same way we have to select the customer here as well in the code.
Thank you dear. There is a lot of learning from me to take and with nice people like you and others it will become an easy journey for me.
Regards,
Content aside
- Status Answered
- 4 mths agoLast active
- 6Replies
- 92Views
-
2
Following