MnR Posted February 15, 2005 Posted February 15, 2005 Hi, In order to stop bad user entry into my database, I need to stop more than 40 orders in total being placed. A customer can have 5 orders, 5 "active" orders that are not set to cancel. But basically the user enters the orders via a portal relating to the orders table. I need a way that when they click the Weightneeded which is a popmenu of weights, a way to check that there haven't been 40 orders. So far i have tried adding a script to the field but i just get loads of problems like the dialog wouldn't show and it wouldn't count correctly, here is the script i was trying to use: If(OrderCounterSum >=40) beep show dialog("Error" etc) ElseIf goto field WeightNeeded Endif any help would be great
TougToug Posted February 15, 2005 Posted February 15, 2005 Does you "OrderCounterSum" make the difference between active and non-active orders?? (i.e. you only need to count the active orders if i understand well) Try to make your TO graph so that it takes into account the difference....
MnR Posted February 15, 2005 Author Posted February 15, 2005 the orderCounter has a script which is: If(Cancel?="Yes"; 0 ; 1) this then is counted by a summary field to get the total which i need to use in the script to check the number of orders and so on.
bikergeek Posted February 15, 2005 Posted February 15, 2005 You don't need a summary field. A simple calc field = Sum (orderCounter) placed OUTSIDE the portal will suffice. It will total the non-cancelled orders in the portal.
MnR Posted February 16, 2005 Author Posted February 16, 2005 Upon changing to a calculation and trying to make it work, it doesn't work, thats why i have a summary field, now could somebody go back and read my first post and help me with the script for the portal problem!
-Queue- Posted February 16, 2005 Posted February 16, 2005 Commit Records/Requests [ ] If [Count(Orders::serial) = 40] Show Custom Dialog ["No more orders can be entered."] Else Go to Field [Orders::WeightNeeded] End If where Orders is the relationship the portal uses.
MnR Posted February 16, 2005 Author Posted February 16, 2005 Thank You loads, I had only missed of the Commit Records/Requests[], but it would be helpful if you could tell more for the future the importance of that script step?
-Queue- Posted February 16, 2005 Posted February 16, 2005 Commit Records/Requests posts any changes you may have made to the current record or related records via portal. It is the equivalent of clicking on a non-field portion of a layout. If you set a key field, for instance, you need to commit the change to be able to refer to the relationship in calcs or script steps. If you create multiple related records via portal, the records will not exist in the system until you commit them. Overall, it is a good idea to use the commit step at the beginning of any script that does not require referencing a selected related record. In other words, do not use it if you are going to related records from a button in a portal, etc. It should also be used after changing a record via script, if subsequent script steps require the changed information, e.g. a key field for a relationship, be current to process it appropriately. This is most necessary for accurate related information, but may be useful in other areas.
MnR Posted February 17, 2005 Author Posted February 17, 2005 Er there is a problem with the script, it executes fine in the first field of the portal but doesn't in any of the others. The field is a value list and when you try to select a value in say the second row it doesn't enter the value but changes the first value? Help!! -------- EDIT: Not sure if this is the most effective way but inserted a "go to portal row" step before which is set to last. But hey it works!
-Queue- Posted February 17, 2005 Posted February 17, 2005 Very true, relationship::field refers to the first related field according to the portal's sort order, if you are not already in the portal. If you are in the portal, it refers to the current row's field. So you would have to go to the last row before going to the field.
Recommended Posts
This topic is 7219 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