imported>Aeric |
imported>Aeric |
Line 1: |
Line 1: |
| {{Deprecated|Old example.}} | | {{Deprecated|Old example.}} |
|
| |
|
| This example gets credit rating data in an account record.
| | {{Deprecated_page|8.0|80}} |
| | |
| <pre>
| |
| // Function: getAccountCreditRating
| |
| // The function takes an account number as a parameter. It creates a search
| |
| // string using the account number and retrieves the value of the
| |
| // credit_rating field.
| |
| | |
| String accountNumber = functionParams.get("number");
| |
| | |
| HashMap data = new HashMap();
| |
| | |
| String searchStr = "number = '" + accountNumber + "'";
| |
| Result result = Functions.searchRecords("ACCOUNT", "credit_rating", searchStr );
| |
| int resultCode = result.getCode();
| |
| if(resultCode < 0)
| |
| { | |
| // Some error happened.
| |
| String msg = "Account could not be retrieved";
| |
| Functions.debug(msg + ":\n" + result.getMessage()); // Log details
| |
| Functions.throwError(msg + "."); // Error dialog
| |
| }
| |
| else if(resultCode == 0)
| |
| {
| |
| // No records found. Take action according to your business logic
| |
| Functions.throwError("Account could not be found");
| |
| }
| |
| else
| |
| {
| |
| //Records retrieved successfully
| |
| ParametersIterator iterator = result.getIterator();
| |
| if (iterator.hasNext())
| |
| {
| |
| Parameters params = iterator.next();
| |
| data.put("credit_rating", params.get("credit_rating"));
| |
| }
| |
| } | |
| | |
| return data;
| |
| </pre>
| |