3 Replies Latest reply on Jun 6, 2011 12:55 PM by philmodjunk

    Linkage does not work when first time fail

    RedL

      Title

      Linkage does not work when first time fail

      Post

      Please refer to the attached linkage for problem description.

      InvoiceLine is portal row of invoice layout.  I use the linkage between InvoiceLine and Product to check the SKU existing or not.  The validation is in SKU field OnObjectValidate script.

      If Inv_Invoiceline::SKU <> Inv_Product::SKU

      Exit false

      else

      Exit true

      endif

      The validation works fine on the first entry of invalid SKU.  And it always exit with false when the invalid SKU is changed to valid SKU.

      1.jpg

        • 1. Re: Linkage does not work when first time fail
          philmodjunk

          Just use this test to see if a matchign SKU exists in Inv_Product:

          IsEmpty ( Inv_Product::SKU )  // True means SKU does not exist in Product table

          If SKU is of type number, it can be simplified to (note that logic of expression is reversed):

          Inv_Product::SKU   // True means SKU exists in Product table.

           

          Note that in many cases, you an eliminate the need for such a test by using a value list of SKUs drawn from Inv_Product when entering said SKUs in the first place.

          • 2. Re: Linkage does not work when first time fail
            RedL

            Here is some info I found.

            The validation script is below.

            Show customer dialog(Inv_InvoiceLine::SKU & " " & Inv_Product::SKU]
            If [isempty(Inv_Product::SKU)]
            Exit script [false]
            Else
            Exit script [true]
            Endif
            If current SKU on the portal row is AAA.  When I change SKU to BBB which is valid SKU. It shows BBB on Inv_InvoiceLine::SKU and AAA on Inv_Product::SKU by Show customer dialog script.  I suppose it is because OnObjectValidate is pre-script.  The linkage between Inv_InvoiceLine and Inv_Product will be updated only after OnObjectValidate return true.  If this statement is correct, I cannot use linkage of Inv_InvoiceLine and Inv_Product to validate SKU.  Is it correct?  How should I do to validate SKU, if the statement is correct?

            • 3. Re: Linkage does not work when first time fail
              philmodjunk

              That issue occurred to me after I posted my last post.

              The OnObjectValidate is pre-commit so the relationship won't update until you commit the record.

              You may want to use a different script trigger to check for this issue later in the event sequence. You can even use:

              Not isempty(Inv_Product::SKU)

              As a validation rule on the Inv_InvoiceLine::SKU field.

              Are you sure that you really need this test?

              A two column value list of SKUs and product descriptions is often set up as a pop up menu or drop down list on the SKU field with the SKU's being a list drawn from the SKU field in products. This can keep the user from entering a SKU that doesn't exist in the first place. With such a defined value list you can even set up a validation rule that requires that the SKU be a member of that value list.