Using @DbLookup in Lotus Domino to update a document

@DbLookup in Lotus' Domino allows you to query a table and return values from a specific record

From "Wakefield on Domino and DB2," by Matt Wakefield, AS/400 Experts Journal, Vol. 3. No.3, May/June 2000. Provided courtesy of The 400 Group.

@DbLookup in Lotus' Domino allows you to query a table and return values from a specific record.

Go to Domino Designer and open the form you want to update. To begin this example, we'll create another button named "Update Customer Information" using the Create > Hotspot > Button Menu. In the Action pane for the Button, enter the following formula:

FIELD Customer_Number := @DbLookup("ODBC":"NOCACHE" ; "MYAS400" ; "DEMOUSER" ; "demo21" ; "DEMOLIB.DEMO_CUST"; "CUSTNO" ; "CUSTDE" ; Customer_Name); All

These fields need to be changed to match your environment:

"MYAS400" - your ODBC data Source Name
"DEMOUSER" - a valid AS/400 profile
"demo21" - the password for that profile
"DEMOLIB" - the library containing your file
"DEMO_CUST" - the name of the file
"CUSTDE" - customer field (AS/400)
"CUSTNO" - customer number field (AS/400)
"Customer_Name" - customer field (Domino)
"Customer_Number" - customer field (Domino)

Now let's test this formula. Save this form and switch to the Domino Client. Create a new document based on your form and use the Select Customer Button to place a name in the customer field. Next, click the Update Customer Information Button to query the AS/400 for the Customer Number. If the update completes successfully, return to Domino Designer and update the formula for the Update Customer Information Button with the following formula additions. These additional statements will update the remaining fields in the document. Be sure to match the field parameters in the statements with the correct field names in the Domino form and the AS/400 table.

FIELD Customer_Number := @DbLookup("ODBC":"NOCACHE" ; "MYAS400" ; "DEMOUSER" ; "demo21" ; "DEMOLIB.DEMO_CUST"; "CUSTNO" ; "CUSTDE" ; Customer_Name);

FIELD Customer_Phone := @DbLookup("ODBC":"NOCACHE" ; "MYAS400" ; "DEMOUSER" ; "demo21" ; "DEMOLIB.DEMO_CUST"; "PHONE" ; "CUSTDE" ; Customer_Name);

FIELD Customer_City := @DbLookup("ODBC":"NOCACHE" ; "MYAS400" ; "DEMOUSER" ; "demo21" ; "DEMOLIB.DEMO_CUST"; "CITY" ; "CUSTDE" ; Customer_Name);

FIELD Customer_State := @DbLookup("ODBC":"NOCACHE" ; "MYAS400" ; "DEMOUSER" ; "demo21" ; "DEMOLIB.DEMO_CUST"; "STATE" ; "CUSTDE" ; Customer_Name); All

Each of the four FIELD statements in the above formula executes a @DbLookup function to query the AS/400 and update a field on the document.

Now we'll test the complete application by saving the form and switching to the Domino Client. Create a new document based on your form and select a customer with the Select Customer Button. Finally, use the Update Customer Information Button to get values for the remaining fields on the document. If everything has worked correctly, your document should be updated. Finally, if you save several documents created this way, your view should show complete information for each document.


This was first published in May 2000

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchEnterpriseLinux

SearchDataCenter

Close