March 28, 200718 yr Hello, I've been trying to figure out how to get my script (which determines whether a customer is within credit limit) to run based on the customer that is presently being selected for a new invoice. Even if it was a separate button that is selected to determine credit limit status, how can I get run determine a certain customer. Right now the way the script works is it always uses the first customer in the customer table, the script seems to work otherwise. Code is below. Any help would be GREATLY appreciated. Thanks Dave Find [Over Credit Limit Invoices] Copy Perform Script [ “Allow User Abort” ] Perform Script [ “Set Error Capture” ] Perform Script [ “Last Layout [store]” ] Set Field [ QUOTES::KF_CUST_ID_q; QUOTES::KF_CUST_ID_q ] Perform Find [ Specified Find Requests: Find Records; Criteria: INVOICES::Status: “Billed” ] [ Restore ] Extend Found Set [ Specified Find Requests: Find Records; Criteria: INVOICES::Status: “Cancel” ] [ Restore ] Set Variable [ $CreditLimit; Value:Sum(INVOICES::Price _Grand_Total) ] Set Field [ QUOTES::testfield; $CreditLimit ] #ABOVE FIELD IS JUST USED TO VIEW THE SUM OF THE INVOICES, USED FOR TESTING ONLY Show All Records If [ $CreditLimit ≥ CUSTOMERS::CreditLimit ] Show Custom Dialog [ Title: "Account over Credit Limit"; Message: " ACCOUNT HAS REACHED IT'S CREDIT LIMIT!"; Buttons: “OK” ] End If Perform Script [ “Last Layout [Restore]” ]
March 29, 200718 yr Forgive me if this is not what you're looking for, but ... I would set up a relationship in your Customer table showing all invoices (from Invoicing) with balance over 0 for that customer and a summary of those invoices. Then, when you go to make an invoice, test to see if that summary is over the CreditLimit.... if so, send back a dialog to halt or make the invoice anyway...or whatever... after the relationship, the script/coding is minimal... Royce
March 29, 200718 yr Author Royce, I will take your advise and try that. Sounds like a good idea to me! Thank you Dave
Create an account or sign in to comment