Hi! I have a main table which is called requisition header. I also have related tables: Requisition Form, Requisition - Attachments
I store the patch code of the 'Header' table inside a variable. Then from my Requisition form table or my 'lines' table, the value of the lookup column from the header table is the patch code.ID of the main table.
As you can see, the Code column is the lookup column from the header table. There's no problem with this as the value has been passed, however, with the other columns(description, quantity, remarks, unit) it returns blank.
I have also this attachments as this is where the file goes to
Solved! Go to Solution.
Hi @psysn ,
Firstly please post all code in Text, particularly unformatted examples of this size. I OCR'd this so there may be spelling errors. Your problem I believe lies here
ForAll(
colRequisitionForm,
Patch(
'Requisition Form',
Defaults('Requisition Form'),
{
Unit: txtReqUnit.Text,
Description: txtReqDescription.Text,
Remarks: txtReqRemorks.Text,
Quantity : Value(txtReqQuantity.Text),
Code:
{
Value:_ctxHeaderRequisition.AutoGeneratedID,
Id: _ctxHeaderRequisition.ID
}
}
)
);
You are patching a collection, but all the references are to control values on the screen rather than fields in the collection. You also have your ForAll backwards - it is not designed to be a Loop, although it can work this way with considerable performance penalty as it does an individual Patch for each record. ForAll() creates a Table, which can be patched in one action provided its content is correct. For new records, this is simply a Table with field names and field types matching the list. Assuming the names in the collection are the same (change if not), your Patch would be something like the above. I am not sure on the Lookup column - you should avoid these if at all possible as it depends what you have in the collection. If any of these are not in the collection and refer to controls, put the control name back and delete the aPatch.
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
MVP (Business Applications) Visit my blog Practical Power Apps
please help
Hi @psysn ,
Firstly please post all code in Text, particularly unformatted examples of this size. I OCR'd this so there may be spelling errors. Your problem I believe lies here
ForAll(
colRequisitionForm,
Patch(
'Requisition Form',
Defaults('Requisition Form'),
{
Unit: txtReqUnit.Text,
Description: txtReqDescription.Text,
Remarks: txtReqRemorks.Text,
Quantity : Value(txtReqQuantity.Text),
Code:
{
Value:_ctxHeaderRequisition.AutoGeneratedID,
Id: _ctxHeaderRequisition.ID
}
}
)
);
You are patching a collection, but all the references are to control values on the screen rather than fields in the collection. You also have your ForAll backwards - it is not designed to be a Loop, although it can work this way with considerable performance penalty as it does an individual Patch for each record. ForAll() creates a Table, which can be patched in one action provided its content is correct. For new records, this is simply a Table with field names and field types matching the list. Assuming the names in the collection are the same (change if not), your Patch would be something like the above. I am not sure on the Lookup column - you should avoid these if at all possible as it depends what you have in the collection. If any of these are not in the collection and refer to controls, put the control name back and delete the aPatch.
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
MVP (Business Applications) Visit my blog Practical Power Apps
User | Count |
---|---|
254 | |
106 | |
92 | |
47 | |
37 |