Answers Posted February 24, 2009 Posted February 24, 2009 (edited) I have done many scripts with loops but today I am having a brain freeze I believe. I am working on a payment screen for our database. There is a field for check amount and amount remaining. Then a portal which lists outstanding invoices for a specific customer. I want to click an 'Auto Apply" button that loops through the portal rows and applies the payments, Apply the full amount of the balance if the amount remaining is > or = the balance or apply the amount remaining if the balance is > than the amount remaining. For some reason it's not working correctly. The last portal row does not apply correctly. Here's the script, I'm sure it's something stupid that I'm missing. Set Error Capture [ On ] If [ Payments::Outofbalance ≤ 0 ] Show Custom Dialog [ Message: "No payments to apply."; Buttons: “OK” ] Halt Script End If Go to Portal Row [ Select; First ] Loop Exit Loop If [ Payments::Outofbalance = 0 ] Go to Portal Row [ Select; Next; Exit after last ] If [ Payments Inv Client::Balance ≤ Payments::Outofbalance ] Set Field [ Payments Inv Client::Amounttoapply; Payments Inv Client::Balance ] Else If [ Payments Inv Client::Balance > Payments::Outofbalance ] Set Field [ Payments Inv Client::Amounttoapply; Payments::Outofbalance ] End If End If End Loop Edited February 24, 2009 by Guest
stefangs Posted March 2, 2009 Posted March 2, 2009 would it work if you freeze the window, then script a GTRR (show only related records), do your loop there, and return to the last layout?
Chappy.Cole Posted March 6, 2009 Posted March 6, 2009 The most obvious thing - which I think is in error - is that you have the "Go To Portal Row: Select: Next: Exit after last" in the loop *before* any processing steps. Unless you intend to skip the 1st portal row, the "go to next" step ought to be immediately before the "End Loop" step. The other things that "appear" to be in error is the absence of any step which adjusts the amounts remaining after applying a payment. If I'm right about this, then your script would apply the lessor of the client's check amount or the invoice balance, to every row in the portal except the 1st. Since you are ranked "Advanced", I doubt that I have debugged your problem, but you never know. Chappy
Recommended Posts
This topic is 5742 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