Stock Level by Scanning Barcode

No thats correct the lowercase is from the script, the only bits ive capitalised are the Program setting names, which are still captialsed in the SETTING:X parts

ive checked it with my test product that works with the other script i was using but doesnt with your bit for inventory level

Turns out the Inventory Item and Recipe did not exist. I created them and now it reports a Level of -7.

Confirm your Product Tag for Inventory Name matches an existing Inventory Item and that there is a Recipe for the Product.

Solved it by integrating the GQL script you showed me for stock level, heres what ive changed it to in the ask question:

[='<size 19>' + '{SETTING:PRI Product Data}' + '<br/><br/>StockLevel: ' + '{REPORT INVENTORY:{CALL:GQL - Product Name.getProductDataByBarcode('{SETTING:PRI Product Barcode}')}:Local Warehouse}' + '</size>']

This now produces this ask question with all the details for the product:

Just a bit of formatting to work on now :slight_smile:

Thanks for you help with this

1 Like

Just checked and inventory name product tag matches inventory item and there is a recipe for it, strange that the GQL script worked tho?

The “new” script is virtually the same as the old script; it just has more functionality, so I don’t see why it would not work.

Put a Show Message action in after setting {SETTING:PRI Inventory Name} to see what is in there.

This is probably why it does not work for you:

  if (product.tags[t].name == whatToReturn) {
    return product.tags[t].value;
  }

If your Tag Name is “Inventory Name” but you send to the function 'inventoryName' as the whatToReturn parameter (parm 2 in the function), then that “if” condition will never be true, so that return will never happen, and the script will then return the full productData, because it falls all the way through to the bottom.

So if your Tag Name is “Inventory Name”, then you need to change your CALL to:

{CALL:prd.getData('{SETTING:PRD_productBarcode}','Inventory Name')}

Works now thanks, Apologies Kendash i think this is what you were referring to before?

Thanks to both :slight_smile:

Another question, is there anyway to amend the script on only display the portions and prices if the product has more than one portion? so if there is just the normal portion it wouldnt display that?

Wrap an if around the Portion section …

if (product.portions.length > 1) {
  productData += '<br/>' + 'Portions:';
  for (var p=0; p<product.portions.length; p++) {
    productData += '<br/>   ' + product.portions[p].name + ': ' + Helper.Format(product.portions[p].price);
  }
}
2 Likes

ive now made a couple of screens like this

Product Info

More Details

Product Image
Need your help again with this one @QMcKay, for this one i need to amend the script to ONLY display if product tag equals Product Image. I had a try but no success, i even tried simply putting {ITEM TAG:Product Tag} in the ask question but it doesnt read it. It does however read it an display the image when included in the script for displaying the tag, i just need to amend the script to only show Product Image, any idea?

It wouldn’t be any different than the Tag for Inventory Name. And the Script would not need modification; it should just work auto-magically using the correct CALL …

{CALL:prd.getData('{SETTING:PRD_productBarcode}','Product Image')}

If “Product Image” is your Tag Name, then the script would return just that Tag Value when it finds it in the loop.

Ok, so I made a small modification to the very bottom of the script:


if (whatToReturn == 'productData') {
  //dlg.AskQuestion(productData,"Ok");
  return productData;
}

if (typeof product[whatToReturn] === 'undefined') {
  return 'PROPNOTFOUND';
} else {
  return product[whatToReturn];
}

}

That is needed when you are searching for a Tag Name that has no Value. If the Tag is empty, then a match doesn’t occur, and it falls to the bottom of the script. So you end up like this:

return product["Some Property that does not exist"]

… so that Object Property would be 'undefined' so instead we return a “known value”, like “PROPNOTFOUND”.

Then we can do this…

('{SETTING:PRD_productImage}'!='PROPNOTFOUND' ? '<img>{SETTING:PRD_productImage}</img>' : '(no image)')

Brill i got that working now! Another question if i only want to display some of the product tags and not all is that possible? looking at what we did by changing productData to Product Image to only display the Product Image tag i thought maybe we could comma separate other product tag values ti display if i dont want them all displayed so i tried this

{CALL:PRIMD.getData('{SETTING:PRI Product Barcode}','Barcode','Age Verification'.'Alcohol','Currently Stocked')}

Which didnt work, am i on the right lines or is it not possible to select certain product tags like that?

One way i can see is to create individual program settings for each product like i have for the product image tag, but thought theres probably a quicker way to somehow just list the ones i want to show

Also I tried that ternary expression for if there is no product image (copy and pasted your example and changed to my tag names) but it doesnt quite work. This is the outcome when there IS a picture:

This is when there is NO picture

LOL, that will not work. You are just making stuff up now. The function getData() only accepts 2 parameters, because that is how we designed it, not some arbitrary number of parameters. If you want to be able to do that, then the script needs to be rewritten almost entirely to accommodate that.

Very likely that isn’t working because your image path has single backslashes ( \ ) in it. You either need to change them all to forward-slashes ( / ) (recommended) or double-backslashes ( \\ )

Yea i was haha just trying to work things out for myself lol

so instead what i did was just create a program setting for each product tag i want to include instead, so in my more details screen i have got 3 product tags displayed

then used the ask question to format the output
<color black><size 50><bold>Product:</bold> {SETTING:PRI Inventory Name}\r<bold>Barcode:</bold> {SETTING:PRI Product Data - Barcode}\r<bold>Currently Stocked:</bold> {SETTING:PRI Product Data - Currently Stocked}</size></color>

So when i click my product information button i have 3 “screens” that i can display:

  1. Main Screen - Product, Price and Stock Level
  2. More Details - To include any of the product tags
  3. Product Image

Heres how they look:
Main Screen

More Details

Product Image

thanks again for your help with this :slight_smile:

3 Likes

@RickH is there a way to fetch stock level without using the product tag inventory name?

Hi, i dont think there is, I think the tag was a work around to be able to get inventory level but was advised not to have it displayed on buttons etc as its a massive drained of resource as it is constantly checking the database

as far as i know it wasnt developed past how it is currently setup

what is it your wntinf to do?