5 Replies Latest reply on Feb 22, 2016 4:32 AM by lcot17

    Scripting Assistance Requested

    lcot17

      Hi,

      I have spent a good while trying a number of ways to make this work but don't seem to be coming up with the right answer right now.

       

      I am trying to assign a barcode to a product. A barcode has to be globally unique and are purchased from GS1. I for example will register 10,000 barcodes and add these barcodes into a 'Barcode Pool' table. This will consist of a barcode ID, EAN Barcode number.. and then the productOption ID (of that product) that the barcode is assigned to.

       

      (By productOptionID, I mean that a product has a number of size variations each with a unique SKU and Barcode).

       

      I need to make sure that I can assign a barcode to only one product SKU. I also need to make sure that if I disassociate a product SKU from a barcode, the barcode becomes available for use again.

       

      I have set up a product option portal table in my products with a button to create an option.

      I have also set up a portal in the product layout to list out all of the barcodes that do not have a product option ID assigned.

       

      Problems

      1) I cannot seem to add the portal to the popover?? Because of this, it is my understanding that when I click a barcode to assign, the portal row to assign it to may not be active so it may not work.

       

      2) An alternative method to add a barcode to a portal record by turning the EAN field (this is the barcode field) into a button and activating a script that could maybe auto-assign an available barcode (or present an error if no barcode available)?

       

      3) How to un-assign a SKU from a barcode to make it available for selection again. This was no barcodes are being wasted.

       

      4) Making sure no productOptionID can be assigned to 2 different barcodes.

       

      4) It seems for some reason, the 'Add Option' button breaks the portal sort order when around 3 or 4 entries are added? Its looks as if the order is going 12, 13, 14, 7, 8, 9.... It is seeing 12 as a lower number as 7 because the first character is a 1. How do I avoid this?

       

      I've attached my database so far to take a look at.

        • 1. Re: Scripting Assistance Required
          BruceRobertson

          Try:

          Scripting Assistance Requested

          • 3. Re: Scripting Assistance Requested
            BruceRobertson

            field_definition.png

            1 of 1 people found this helpful
            • 4. Re: Scripting Assistance Requested
              lcot17

              BruceRobertson

              Got it! Can't believe I missed that...

               

              So that is problem 5 - SOLVED

               

              Now just the issues of how to link barcodes to a product option, validate not more than one barcode assigned to a product option, delete the product option from the barcode when barcode is unassigned (simple with button) and why a portal will not go in a popover button from the products layout portal.

              • 5. Re: Scripting Assistance Requested
                lcot17

                Can I possibly re-bump this for some assistance? BruceRobertson I have been in a trial and error stage for an entire day now

                I have updated my progress in an attachment...

                I think the best way to do this is by clicking a button on the portal row and either

                - auto-assigning a record from the barcode pool based on a criteria (if available field = 1 and productoptionid is empty) or

                - selecting a barcode record from a popup portal listing all available barcodes and then assigning it to that product option.

                 

                Based on the above - I need to make a script to do the following:

                • Click the barcode field button - this sets the 'ProductOptionID' variable globally (is this correct to do so) - [$$productOptionID]
                • The script then opens the object 'Barcodes'. This is a popover button with a portal inside filtering all barcodes from the pool that do NOT have a productOptionID value in the foreign key field
                  • The script must then pause whilst I manually select a barcode and set a $BarcodeID variable
                  • Or should I script it to pick a barcode at random from the pool of available barcodes (i've already set a script to give available a figure of 1 and unavailable a figure of 0)
                • Then the script must put the BarcodeID variable in the product option record

                 

                Screen Shot 2016-02-22 at 11.51.44.png

                One final question - based on this relationship above - if I add a barcode ID to _barcodeIDfk in the Product Options table, should the _productOptionIDfk update as well in the Barcode Pool table? It isn't at the moment and can't decide if it should or shouldn't do this based on my setup.