Ginxy33 Posted December 20, 2005 Share Posted December 20, 2005 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. Link to comment Share on other sites More sharing options...
Fitch Posted December 20, 2005 Share Posted December 20, 2005 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) Link to comment Share on other sites More sharing options...
T-Square Posted December 20, 2005 Share Posted December 20, 2005 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 Link to comment Share on other sites More sharing options...
Recommended Posts
This topic is 6702 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now