Infor Applied Innovation

« | Main | »

Scripting Tools in Infor Smart Office for Infor Lawson – Part 3

April 27, 2017

Scripting in Infor Smart Office for Infor Lawson

By Vince McGowan, Senior Principal Software Engineer

This is the third of our 3-part series on Lawson scripting tools available in Infor Smart Office for Infor Lawson Applications. In this post we will look at the API Builder. For links to Parts 1 and 2 check out the Infor Smart Office section of the blog.

Lawson API Builder

With this tool you can develop and test various Infor Lawson System Foundation (LSF) APIs for: the data mining engine (DME – /servlet/Router/Data/Erp), the transaction engine (/servlet/Router/Transaction/Erp), and the DrillAround™ engine (/lawson-ios/action/drill).

For example, there may be a script scenario where you need to validate certain screen values against other data and performing a DME call can retrieve that other data. Another scenario might be combining fields from another application form on the current form and when performing an update to the current form requires performing a transaction against the second application.

Note: It is not recommended that the engine paths be used in your script. Instead, constants are provided that abstract them for you should they ever be changed in the Infor Smart Office application.  The constants are:

  • DataMinePath
  • TransactionPath
  • DrillAroundPath

If you use the ‘Copy as Jscript’ functionality for a DME query, the DataMinePath is not necessary either.

Like the Object Brower we looked at in the previous post, with scripting access the user can open the tool from the Navigator widget – Infor Lawson -> Other -> Lawson API Builder – or from the Help menu in the Lawson Script Tool.

Building a Data Query API

When you create a Data Query through API Builder, you are creating a call to the Infor Lawson Data servlet. The query you create can be pasted into a VB or other application.

Building a Data call

Start the API Builder. On the API Builder window, choose Data Query for the API Type, and then select Data Area, System Code, and Table.

On the next panel that appears, make selections for the following items:

  • Table Elements
  • Indices (indexes)
  • Index Elements (key fields)
  • Related Tables (if any)
  • Related Elements (if any)

You can add criteria by making selections for the Select Criteria fields, or by selecting an Index and specifying the corresponding value in the Index Element.

You can specify the maximum number of records and what type of data to return. When you are finished specifying the query, first click Build Query. The Build Query option creates the data query and displays it in a text area. The Test Query option tests the API and if the result is what you expected, you can copy the Query to the clipboard either as is or as Jscript that could be pasted into the Script Tool editor.

As an example, let’s build a query of employees of Company 1104. First, I select the Data Area and then the HR System Code and the Table list is populated with the related Tables. The list defaults to sorted by description. If you are more familiar with Table names, you can choose to sort on that by clicking the Name radio button. Or there is also a search feature for finding Tables.

For my query, I want to retrieve Company number, Employee number and Employee First and Last name. I selected the first Index and specified that I want to filter on company 1104. Then I clicked the Build Query to populate the query text area and clicked Test Query to see the data returned.

Once you have built and tested your query and want to add it to a script being developed, simply click the ‘Copy as Jscript’ button and the script which can be pasted into the Script tool is placed on the Windows clipboard. The script for the above query looks like this:

Notice that instead of hard-coding the selected Data Area, the script is made more portable by using the GetUserAttribute method to retrieve the current user’s Data Area.

Building an Application API

Choose Application for the API Type, and then select Data Area, System Code, and Application Form.

On the next panel that appears, make selections for the following items:

  • Form Properties. These are the form fields. You can select the Sorted check box to have the fields display in alphabetical order instead of form order. If you clear the Show Hidden check box, only fields that are visible to the user will be available to your query. If your query is looking only for data that a user might have updated, you can de-select hidden fields to minimize the number of fields your query must access. This can be a performance advantage when your query processes.
  • Methods. The actions that can be applied to this form, such as Add, Change, or Delete.
  • Selected Elements (if any). Type key fields as needed for any selected fields. Click Build Query when you are finished making selections.

The Build Query option creates the data query string and displays it at the bottom of the panel. Click the Test Query button to test the API. The query generated displays in a text area and if the code is what you expected, you can copy it to the clipboard either as is or as Jscript that could be pasted into the Script Tool editor.

The script to Inquire on Currency Code ‘USD’:

Building an DrillAround™ API

When you create a query for Drill Around data in Lawson applications, you are creating a call to the Lawson Drill servlet.

Specifying a Drill call

Start the API Builder. On the API Builder window, choose Drill-Around for the API Type, and then select Data Area, System Code, and Form.

On the next panel that appears, make selections for Drill-Around Paths (KNB) and Required Drill Keys. When you are finished specifying the query, first click Build Query. The Build Query option creates the data query and displays it in a text area. The Test Query option tests the API and if the result is what you expected, you can copy the Query to the clipboard either as is or as Jscript that could be pasted into the Script Tool editor.

Example of Drill-Around Jscript:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *



About this Blog

The latest innovations using Infor Technology