December 20, 200520 yr Is there a way to loop through a field in all records to check it it's flaged? Here's what I am wanting to do. I want to be able to flag a certain item as preferred. When I go to flag this item I want it to first check that there is not a product of this type already flaged. I have hundered of products and I am afraid that it will strain the system, but it would be worse if 2 of the same items were flaged preferred. my product is Product::SKU So I would want to loop through all the Product::SKU that are identical to the one that I am entering. something like this..... loop----- if(Entered::SKU = Product::SKU and Product::Flag = 1) "Product already flaged, would you like to change it?") else Product::flag = 1 end if Not sure how to loop it so it reads all the Product::SKU's in exsistance.
December 20, 200520 yr One approach would be: Set field ( globalSKU ; Entered::SKU ) New window ("temp find") # Enter Find Mode Set field (Product::Flag ; 1) Set field (Product::SKU ; globalSKU) Set error capture ON Perform Find # If(Get ( FoundCount ) > 0 ) . Show custom dialog ( "change it...?" ) . If ( Get ( LastMessageChoice ) = 2 ) # default button 1 is YES, button 2 is NO . . Close window ("temp find") . . Exit Script . Else . . Set field (Product::Flag ; "" ) . End If End If # Close window ("temp find") Set field (Product::Flag ; 1)
December 20, 200520 yr I'm not the expert on this, but... look into creating a self-join in the relationship diagram based on the field in question. Then, you can quickly determine whether there is a record on the other side of the link--without scripting, or with minimal scripting, as the case might be. David
Create an account or sign in to comment