Hello,
Struggling to get this to work.
I have three sharepoint lists
Personal Detail.
Shopping Cart Orders(as a lookup)
Shopping Cart Order Items
I can get the OrderID from Shopping Cart Orders into Shopping Cart Order Items and Personal Details.
Set(varRecordID,Patch('Shopping Cart Orders',Defaults('Shopping Cart Orders'),{Title:Title1.Text},{Price:Lbl_Price.Text}).ID);
ForAll(Basket,Patch('Shopping Cart Order Items',Defaults('Shopping Cart Order Items'),{Title:Product},{OrderID:varRecordID},{PointsQuantity:PointsQuantity},{SalesQuantity:SalesQuantity},{Price:Price},{PointsPerBottle:PointsPerBottle},{Product:Product},{ProductID:Id}));
ForAll(PDetails,Patch('SBP Shop Order Personal Details',Defaults('SBP Shop Order Personal Details'),{'Name (Title)':'Name (Title)'},{'Employee Number':'Employee Number'},{'Department / Team':'Department / Team'},{'Nominated person to collect':'Nominated person to collect'},{'Nominated Person Email':'Nominated Person Email'},{'Deliver to location':'Deliver to location'},{'Nightshift Worker':'Nightshift Worker'},{Email:Email},{OrderID:varRecordID}))
I then want to add a lookup column in the Shopping Cart Order Items to bring through the employee name from the Personal Details sharepoint list so I can see who's name is against each order.
But the names are there but not auto populated. Is this possible please? Thanks Ross
Hi @rosscortb ,
Two things here before I get to your main question - you have potential ambiguity with identical field names on both sides of the Patches and also you have 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.
I have included the lookup to your employee name as well - just add your field names.
Patch(
'Shopping Cart Order Items',
ForAll(
Basket As aPatch,
{
Title: aPatch.Product,
OrderID: varRecordID,
PointsQuantity: aPatch.PointsQuantity,
SalesQuantity: aPatch.SalesQuantity,
Price: aPatch.Price,
PointsPerBottle: aPatch.PointsPerBottle,
Product: aPatch.Product,
ProductID: aPatch.Id
}
)
);
Patch(
'SBP Shop Order Personal Details',
ForAll(
PDetails As aPatch,
{
'Name (Title)': aPatch.'Name (Title)',
'Employee Number':
LookUp(
'Person Details',
YourEmpNoField = aPatch.'Employee Number'
).YourNameField,
'Department / Team': aPatch.'Department / Team',
'Nominated person to collect': aPatch.'Nominated person to collect',
'Nominated Person Email': aPatch.'Nominated Person Email',
'Deliver to location': aPatch.'Deliver to location',
'Nightshift Worker':aPatch.'Nightshift Worker'
Email: aPatch.Email,
OrderID: varRecordID
}
)
)
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
@WarrenBelz Appreciate the help.
In your code should 'Person Details' be PDetails which is the collection?
Patch(
'Shopping Cart Order Items',
ForAll(
Basket As aPatch,
{
Title: aPatch.Product,
OrderID: varRecordID,
PointsQuantity: aPatch.PointsQuantity,
SalesQuantity: aPatch.SalesQuantity,
Price: aPatch.Price,
PointsPerBottle: aPatch.PointsPerBottle,
Product: aPatch.Product,
ProductID: aPatch.Id
}
)
);
Patch(
'SBP Shop Order Personal Details',
ForAll(
PDetails As aPatch,
{
'Name (Title)': aPatch.'Name (Title)',
'Employee Number': LookUp(
PDetails,
'Employee Number' = aPatch.'Employee Number'
).'Employee Number',
'Department / Team': aPatch.'Department / Team',
'Nominated person to collect': aPatch.'Nominated person to collect',
'Nominated Person Email': aPatch.'Nominated Person Email',
'Deliver to location': aPatch.'Deliver to location',
'Nightshift Worker': aPatch.'Nightshift Worker',
Email: aPatch.Email,
OrderID: varRecordID
}
)
)
I managed to get this to work but it doesn't bring in the OrderID, where do I set that please?
Update: Actually have set it the gallery so not sure why is not pulled through....
Thanks
Ross
PDetails was from your code posted, but yes, it would be a collection.
@WarrenBelz Thanks, any ideas why I can't get the OrderID returned?
As mentioned above, I have the variable set against ThisItemId.
Thanks again.
Ross
You are using varRecord.ID to obtain this - the first place would be to put this on a Label and see if is the correct value before you trigger the Patch. You are setting it here, which should work
Set(
varRecordID,
Patch(
'Shopping Cart Orders',
Defaults('Shopping Cart Orders'),
{
Title: Title1.Text,
Price: Lbl_Price.Text
}
).ID
);
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
@WarrenBelz I can see the varRecordID in the label.
Appreciate the help, got OrderID showing in both list but can't see how the relationship is created by employee and ordered item as when I add a lookup in the list to bring employee name through to ordered items, I get options. Order 95 should be against John.
Thanks Ross
I posted this
'Employee Number':
LookUp(
'Person Details',
YourEmpNoField = aPatch.'Employee Number'
).YourNameField,
which you changed to this
'Employee Number':
LookUp(
PDetails,
'Employee Number' = aPatch.'Employee Number'
).'Employee Number',
What you need to do is match the employee number from your 'Person Detail' list with whatever field in the order matches it and find the name. Please take a moment to understand the logic of this an I am sure you will find the right value.
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 |
---|---|
121 | |
88 | |
88 | |
75 | |
66 |
User | Count |
---|---|
217 | |
180 | |
138 | |
96 | |
73 |