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.
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]ElseExit script [true]EndifIf 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?
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:
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.