I have a collection called 'ItemCollection' with fields like itemid, ItemLabourTime (this is the time required to manufacture an item), Labour(i.e TotalLabour, based on quantity entered) and several other fields.
I'm trying to read in the value for quantity from the user in a gallery(see screenshot below) and auto-generate the field Labour based on the value entered by the user.
So if a item has ItemLabourTime of 10 mins and the user enters 2 for quantity, the labour value (i.e TotalLabour) for that item in the gallery should be 20.
I was trying to use the following formula to patch a default value for Labour to the collection -
Patch(ItemCollection, ThisItem,{Labour: ThisItem.ItemLabourTime*ThisItem.quantity})
but that was giving me an error- 'behavior function in a non behavior property'.
The plan was to set this as default and use an update in the Onchange value if the user wants to reset the auto generated value.
How can I achieve this functionality? Any help is much appreciated.
Hi @ChrisEluva ,
Try
Patch(
ItemCollection,
ThisItem,
{Labour: Value(ItemLabourTime.Text)*ThisItem.quantity}
)
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.
Visit my blog Practical Power Apps
Sorry, that's not working. Still giving the same error.
Where are you running the code from? To use ThisItem it must be from within the gallery. I also assume ItemLabelTime is the Text box.
For labour text box in the Text property
use this formula Value(ThisItem.quantity)*Value(ThisItem.ItemLabourTime)
But, to patch the values to the collection I recommend to add a button to save the data for all gallery or for a single record. Because it doesn’t make sense if u want to patch the values every time when the user change the value
hope this helps u
@WarrenBelz Yes I'm using it within the gallery.
ItemLabelTime is not the text box, it is the predefined time required per item. The user enters the quantity and the app should generate the highlighted "Labour"(TotalLabour) field. i.e Quantity * ItemLabelTime(for that item in the gallery)
The only reason I have the input box (text box) is to read in any changes to the automatically calculated time.
Btw, appreciate you looking into this!
Hi @ChrisEluva ,
If ItemLabelTime is not a control, I assume it is a field in your source data List - what type of field is it?
Yes, it is a field in my source. My source is a SharePoint list and ItemLabelTime is of type number.
Only one thing left then - the quantity is entered by the user?
Patch(
ItemCollection,
ThisItem,
{Labour: ThisItem.ItemLabourTime * Value(QuantityTextBoxName.Text)}
)
Replace with your text box name
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.
Visit my blog Practical Power Apps
Unfortunately still returning the same error!
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
201 | |
71 | |
49 | |
43 | |
30 |
User | Count |
---|---|
253 | |
120 | |
86 | |
84 | |
84 |