cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

Inventory notification

Greetings all - 

I've modified the the Asset Checkout template to reserve quantities of items based on user input from a Text Input field. What I'd like is to display a warning if if they request an amount greater than what is currently on stock. 

The data is coming from a datafield called "Quantity" in my Excel sheet. I'm brand new to this, so if someone is feeling extra helpful and breakdown the formula for a dunce like me, I'd be very grateful. 

21 REPLIES 21
Highlighted
Continued Contributor
Continued Contributor

Perfect.  So the table you imported from Excel is named Checkedout.  It contains the following fields:

  • Item Detail Card
  • Size Card
  • ProductId
  • Name
  • Email
  • Quantity

Quantity is the one we care about, but we also care about the ProductId (since I'm assuming that's your key for doing a LookUp()).

What's the name of the field in your application where the person inputs the Quantity?

Highlighted

Thanks for your quick responses and patience, @jhall - the quantity field where users input their request for an item is called productquantityfield. It's default value is "ThisItem.Product"

Highlighted
Continued Contributor
Continued Contributor

Ok, so the first part you have is correct:

Value(productquantityfield.Text) > 

The LookUp is what we have to fix and we need to do that by the ProductID (assuming that's your unique identifier in your table).  When the user selects what product they want is that done by a Drop Down box that is tied to your table of Products?  If so, what is that box's name?

Highlighted

They select the product from by clicking on a button that sends them to the next screen (where they input the quantity). The button is connected to a filterable gallery called "ProductsGallery", and uses this as the OnSelect function:
EditForm(ReservedForm);
Set(ItemSelected,ThisItem );
Navigate(ReserveScreen,ScreenTransition.Fade).


The gallery is retrieving data from my "Products" table, which is another tab in my excel sheet. The formula to filter is like so: 

Items = SortByColumns
(Filter(Products,
And(CategoryId =
CategoriesGallery.Selected.CategoryId,SearchBoxText.Text in ProductName)),
If(category = "Qty Used", "Color", "Available"),
If(category = "Available", Ascending, Descending))

 

Highlighted
Continued Contributor
Continued Contributor

Assuming your other Products tab in Excel has a field that matches up to your tab where we're getting the count and has the field ProductId, then...

When you did this step: Set(ItemSelected,ThisItem );

You linked up a global variable to a record of the Item selected by your button.

We should be able to reference the values that ItemSelected contains by hitting the period after it.

This probably means that the correct ending to our statement is:

Value(productquantityfield.Text) > LookUp(Checkedout,ItemSelected.ProductId=ProductId,Quantity)

The blue text is just to clarify that the ProductID on the right-hand side is referencing the one that exists within the Checkedout data source.

Sorry on my original change of the comma there.  My error as you're wanting to return the Quantity if the Product ID's match.

If this doesn't work, then it is possible we'll need to rename ProductId within the function because both Collections (ItemSelected and Checkedout) have a field named ProductId and sometimes the platform can get confused.

Highlighted

Pardon the late reply, @jhall - I've been doing some more tinkering with this, and decided to start over. Now I'm using two Sharepoint lists:

 

1) US Azure SWAG Stock - contains the inventory listings

2) US Azure SWAG Checkout - contains the details of each order, which I'm going to eventually connect a Flow to. 

 

Instead of global variables, I'll be using a collection for each selection. Currently, I have two screens:

 

1) CurrentStock - contains a gallery of items from the "US Azure SWAG Stock" list. The gallery includes a button for each item, directing them to the next screen. The button's onSelect looks like this:

 

Collect(
SwagCollection,
{
ProductTitle: ProductTitleLabel.Text,
ProductID: ProductIDLabel.Text,
CurrentStock: CurrentStockLabel.Text,
ProductImage: ProductImage
}
);
Navigate(CheckoutScreen)

 

2) Checkout - contains a gallery of the items selected from the collection. It has these labels corresponding to my US Azure SWAG Stock list. 


- ProductTitleCheckoutLabel (Text = ThisItem.ProductTitle)

- ProductIDCheckoutLabel (Text = ThisItem.ProductID)
- CurrentStockCheckoutLabel (Text = ThisItem.CurrentStock)

- ProductImageCheckoutLabel (Text = ThisItem.ProductImage)

 

I also have a "Quantity" Text input field, that I'd like to the warning from. It's called RequestedQuantityField. It's Visible property is

Value(
LookUp(
'US Azure SWAG Stock',
ProductID=ThisItem.ProductID,
CurrentStockLabel.Text)) > Value(RequestedQuantityField.Text)

I have no errors in this formula, but it won't work. Any ideas?


Highlighted
Continued Contributor
Continued Contributor

Do note that Collections themselves are still "Global variables" (values retained across Screens), just not the kind you can use the Set() function on.

Let me look closer at this.  At first glance, I'm not liking your OnSelect() code in step 1), but it might be perfectly fine.  Do the items populate properly within 2) and are shown?  Just want to verify.

Highlighted

Good to know, @jhall - so far, everything works. When I submit the form, it's correctly subtracting the value of the quantity field from the "CurrentStock" Sharepoint column for the selected item. Here's that co

ForAll(
SwagCollection,
Patch(
'US Azure SWAG Stock',
First(
Filter(
'US Azure SWAG Stock',
ProductID = ProductIDCheckoutLabel.Text
)
),
{CurrentStock: CurrentStockCheckoutLabel.Text - RequestedQuantityField.Text }
);
Patch(
'US Azure SWAG Checkout',
Defaults('US Azure SWAG Checkout'),
{
ProductID: ProductTitleCheckoutLabel.Text,
ItemID: ProductIDCheckoutLabel.Text,
QuantityRequested: RequestedQuantityField.Text
}
)
)


Mind if I ask why a collection would not be the ideal approach for this?

Highlighted
Continued Contributor
Continued Contributor

Actually, I think it's a fine way to approach it.  You're just clicking an item in one collection and adding/removing it from another.  It's exactly as I would approach it.

(sorry for any delay - big meeting day)

Highlighted

No worries, @jhall - I'm grateful for the help (and a hattip from a fellow pug owner). If you get a chance, I'd be interested in why you think my onvisible warning isn't working. 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (11,862)