cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Add/Subtract TextInput value

 

Hello everyone!

 

I'm trying to make an inventory app that automatically reduces the taken amount by the user from the database:

 

 

 

UpdateContext({NewRecord:Patch(Hardwaew,First(Filter(Products,HardwareId=inventory.HardwareId)),
{Available:Text(If(Value(inventory.Available)>0,Value(inventory.Available)-1,inventory.Available))})});
Navigate(EndScreen,ScreenTransition.Fade,{inventory:inventory})

Is it possible to set the "-X" with the value the user specifies via TextInput on a DataCard.

 

Appreciate any insight you guys might have!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Hi @LordsBH,

 

Could you please share a bit more about your scenario?

Does the inventory.Available formula represents the inventory amount?

Further, do you want to reduce the taken amount based on the value the user specifies within the TextInput control (on a DataCard)?

 

I assume that the inventory.Available formula represents the inventory amount, if you want to reduce the taken amount based on the value the user specifies within the TextInput control, please modify your formula as below:

UpdateContext({
NewRecord:Patch(Hardwaew,
First(Filter(Products,HardwareId=inventory.HardwareId)),
{
Available:Text(If(Value(inventory.Available)>0,Value(inventory.Available)-Value(DataCardValue1.Text),inventory.Available))
})
});
Navigate(EndScreen,ScreenTransition.Fade,{inventory:inventory})

Note: The DataCardValue1 represents the TextInput control within the Data Card control.

 

More details about the Value function in PowerApps, please check the following article:

Value function

 

Best regards,

Kris

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Community Support
Community Support

Hi @LordsBH,

 

Could you please share a bit more about your scenario?

Does the inventory.Available formula represents the inventory amount?

Further, do you want to reduce the taken amount based on the value the user specifies within the TextInput control (on a DataCard)?

 

I assume that the inventory.Available formula represents the inventory amount, if you want to reduce the taken amount based on the value the user specifies within the TextInput control, please modify your formula as below:

UpdateContext({
NewRecord:Patch(Hardwaew,
First(Filter(Products,HardwareId=inventory.HardwareId)),
{
Available:Text(If(Value(inventory.Available)>0,Value(inventory.Available)-Value(DataCardValue1.Text),inventory.Available))
})
});
Navigate(EndScreen,ScreenTransition.Fade,{inventory:inventory})

Note: The DataCardValue1 represents the TextInput control within the Data Card control.

 

More details about the Value function in PowerApps, please check the following article:

Value function

 

Best regards,

Kris

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

 

Hi!

 

Yes, inventory.Available was formula for the remaining stock

I didn't work. For some reason it refuses to gather the info from that TextInput field in particular, even though other Labels can.

 

Nonetheless I manage to work around it by setting the TextInput OnChange property to:

 

Set(InvAmount, 0 + TextInput5_1.Text)

 

Then preventing the user from taking more than available:

 

If(
Value(inventory.Available)<InvAmount, Navigate(TroubleScreen,ScreenTransition.None)); 
If(
Value(inventory.Available)>=InvAmount,
 SubmitForm(InventoryForm)
) 

And then deducting the given value at the press of a "Confirm" button:

 

UpdateContext(
{NewRecord: Patch(Products,First(Filter(Products,HardwareId=inventory.HardwareId)),
{Available: Text(If(Value(inventory.Available)>0,
Value(inventory.Available)-Value(Amount),inventory.Available))})})
;
Navigate(HomeScreen,ScreenTransition.None);ResetForm(ReserveForm);
Office365.SendEmail(User().Email,"Email Notification - Inventory Used",InvAmount & " " & checkedout.ProductName & " taken.", {Cc:"email@domain.com"})
;
Set(InvAmount,0)

Not the fanciest workaround, but it worked 😛

Thank you for your help, bud!

Anonymous
Not applicable

@v-xida-msft 

I could use some help with a very similar problem, I am trying to create a daily inventory shipped form, once the form is submitted I would like it to subtract from the inventory box. However, this inventory box can be updated to change the starting inventory. Hopefully these screenshots will make more sense. 

 

Inventory at suppliers shows the starting inventories and will be updated as we buy product or convert bags into totes 

Starting InventoryStarting Inventory

This is where we edit the starting inventory, added supply, and changes- the patch equation updates the excel the above screen pulls from

Edit starting inventory, updates the inventory at suppliers pageEdit starting inventory, updates the inventory at suppliers page

This is the form I would like to have to record the daily inventory being shipped- once the save button is selected it would update the running total of inventory remaining at the supplier shown in the next picture. The starting inventory for the running total could be changed based off the above steps, but all inventory previously shipped still needs to be subtracted from those totals 

editable gallery to enter the daily qty shippededitable gallery to enter the daily qty shipped

This page would show the running totals of remaining inventory. 

when daily form save button is selected, i would like it to subtract from these galleries like a running totalwhen daily form save button is selected, i would like it to subtract from these galleries like a running total

 

Am I crazy thinking that these can all work together, or is there a way to make this happen? Very open to any other ideas that would allow me to do a similar process. I would not mind adding a date picker and sending the form to a running excel table or sharepoint list to keep track of the daily shipments if that would be helpful for this solution. 

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (101,464)