Category Archives: JScript

Getting values from M3 panels with Jscript

Almost every M3 script needs to get values from the panel it is running on at some point and there are quite a few different ways to accomplish this. The script might need the value of a specific TextBox, the value of a cell on the selected list row or it might need to know what the name of the current program is. These are just a few examples and there are many more. This post will show how to get values from M3 panels in the most common scenarios.

Continue reading

Tooltips with MI data in M3 lists

A script requirement we recently heard of was to be able to show tooltips on cells in a M3 list and that the tooltip value should be retrieved using a MI-program. The specific requirement was to get the user name for list columns that contains M3 user IDs. The idea is to use this in M3 lists where the user ID is shown in a column but the user name is not part of the list. Continue reading

Using M3 language constants in JScript

Using M3 language constants in JScript is a requirement that has been received from several sources recently. In Mashups it has been possible to use M3 constants and messages for some time using the markup extension MForms.Mashup.ConstantExtension. JScript developers however have been out of luck and have had to use other means of translating texts in scripts that targets more than one language. Continue reading

Improvements in JScript logging

Introduction

Since there is no way to debug a JScript in LSO developers have to use other means to find errors. This can include writing to the debug console in the Script Tool, writing to the Smart Office log file or the classic, showing dialog boxes.

In many cases you want to write both to the debug console for development purposes and to the log file for troubleshooting deployed scripts. One way to solve this is to create your own wrapper functions that does both these things and some of you have probably done this already. To make logging a bit easier from JScript we have added some new methods and properties to the ScriptDebugConsole class. First I will describe how a log wrapper function might be implemented and then how the new API methods can be used to remove the need for a wrapper function. Continue reading

Pressing KeyDown in a M3 list to load all rows

This post will cover something that you can do in JScript that is actaully on the edge of what you can but shouldn’t do. JScript is a great tool for doing small enhancements to M3 panels and S3 forms. However doning more advanced stuff requires a lot of experience. There are however a few tricks that you pick up along the way. In this post I’ll show you two useful things.

1. How to log to the Lawson Smart Office log file.
2. How to simulate pressing a key, in this case we will use page down.
3. How to run against your own local script instead of the central deployed onces. Continue reading

Using JScript and a Mashup to browse for values on M3 panels

The goal of this post is to show how JScript and Mashups can be used to extend the browse functionality in M3. The idea is simple, instead of using the M3 Browse dialog to find a field value on a panel a custom built Mashup is used instead. The Mashup can use M3 panels with Enterprise Search, data services and all the other Mashup controls to improve the browse experience for the user.

The solution consists of two parts, a generic JScript and one or more browse Mashups. The browse Mashup is started using a button or a keyboard shortcut, the user selects something in the Mashup and then one or more values from the Mashup are used to update fields on the panel. The rest of the post will cover a simple browse Mashup and the important parts of the JScript. Continue reading

Validating M3 panels using JScript and MI programs before a request

The scenario for this post is to be able to verify something on a panel in a M3 program before a request is submitted to the M3 BE server. The validation in the example will be made using a MI program that is called asynchronously. The example is not a realistic case but it is easy to test and can be modified and generalized for real business cases. Note that the script is just an example and not intended for production use. Continue reading

Adding a new column in a M3 List

Every now and then we do get questions about manipulating the M3 List. It is possible to add a column using JScript but there is no supported API for the different manipulations. But that does not stop the creative people out there. Now I would like to give you a heads up becuase the list implementation has changed slightly in Lawson Smart Office 10.

You can no longer access the Items property on the listview directly. Continue reading

Modal task URIs

In Lawson Smart Office (LSO) version 10.0.0 two generic URI parameters were added to support modal tasks. The requirement was to be able to launch any LSO URI in a modal window.

A modal window is a child window that requires users to interact with it before they can return to operating the parent application (http://en.wikipedia.org/wiki/Modal_window). There are many scenarios where this could be useful (if a modal behavior is desired) such as Mashups, personalized links, navigator links, canvas shortcuts etc. Continue reading

Calling M3 APIs in JScript on a Background Thread

In 9.1.3 we introduced a generic support for running any M3 API without having to create WS Stubs. If you are on a previous version you can still call a web service but it requires much more work including the use of Smart Office SDK. All calls to M3 APIs have to be done on a background thread!

There is simply no excuse for doing this the incorrect way. If you call the web service on the UI thread the entire UI will freeze for the time period that the call takes. In normal cases this will not be noticable but that does not matter. No calls to other servers on the UI thread.

Continue reading

Selecting the first row in a M3 list to trigger CurrentItemChanged

When you have a M3 list in a Mashup a common scenario is that you would like to have the first row selected so that any dependant mashup control can react to CurrentItemChanged.

This is for example a scenario when you open the Mashup from a panel with JScript so that you pass in a Customer id, CUNO. You want to load related information right away. This requirement is something that we will consider for future versions to have an option to say, ‘select first line on startup’.

But until then there is a workaround that involves using a JScript to set the selected item in the list. I’ll do an example with a mashup that loads CRS610 and reacts to CurrentItemChanged to load related data in a MIPanel. Continue reading

Calling M3 APIs

For easy access to M3 APIs we have created a few classes that you can use both in your JScripts and in your features. For those of you who don’t know the difference, JScripts are used on a standard M3 and S3 forms to add new functionality. A feature is an application that runs natively within Lawson Smart Office. This is the way we build the UI to our applications such as M3, S3, LBI, Process Server, Document Archive… to mention a few.

I got a question from one of our Solution Consultants, Peter Johansson. He was using MIAccess to get customer data but he was experience delays due to the amount of data.

“Is there a way to specify which fields should be returned by the API?”

Of course there is! Continue reading