Loading...
 

MorphIT direct links

Direct links in MorphIT

189315

MorphIT offers the possibility to trigger a message with parameters in ClassiX via URL parameters before the initial loading of the user interface in order to automatically send commands for initialisation and thus to bring ClassiX into a defined state before the user interface is displayed. This message is triggered at the initial connection establishment as well as at each successful reconnect (in case the connection to ClassiX has been interrupted). A refresh (F5) also ensures that the message is triggered again. If ClassiX is started via the MorphIT-Launcher, it is ensured that each ClassiX instance triggers the message exactly once during the initial loading of the user interface, because after a connection abortion/refresh a new ClassiX instance is assigned to the MorphIT client.

Attention: The message is triggered at the first load_view and thus also before any possible login. The login must nevertheless be executed before each navigation. In this case the InstantView code must therefore remember that a corresponding status has been requested, which is opened after a LOGGED_IN. For this purpose the message LOGIN_EXEC is used, which enables the execution of an action after successful login.

Link structure

A direct link is established as follows:

<morphitURL>/?auto=<eventName>[&<parameter1>=<wert1>]...[&<parameterN>=<wertN>]

The morphitURL is the regular URL under which MorphIT is accessible from the calling client. (Example: http: //localhost:8080/)

eventName is the event which should be triggered in ClassiX. Therefore the event is converted into capital letters and an _AUTO is appended so that ?auto=display_order becomes the message DISPLAY_ORDER_AUTO. The module which receives this message must either already be loaded at this time or the message must be listed in the triggeredBy in the external statement.

For the execution of the message, any query parameters can also be specified, which are on the stack when the message is executed as a JSON object.

Parameters

The Auto-Message is always called up with exactly one parameter. A JSON object is passed as parameter, which has the following structure following the above syntax:

{ "auto":<eventName>, "path":<requestPath> "params": { <parameter1>:<wert1>, ... <parameterN>:<wertN> } }

requestPath is the path of the HTTP call (usually "/" or "/index.html"). This parameter is not important at the moment.

Examples

Call any message

First, a simple example of an auto-handler that simply executes a message specified as a parameter.

Msg(TEST_AUTO) TEST_AUTO: Copy(params.message) String("SendMsg(%s)") Execute

Via the URL /?auto=test&message=MY_MESSAGE, the message MY_MESSAGE can thus be triggered when the connection is established.

Edit order (with login)

The following example schematically shows an auto handler, which jumps to the order mask immediately after login to create a new order or to edit an existing one. The actual auto handler only writes the auto parameters into the variables orderid and orderview, which are then evaluated in the LOGGED_IN and determine whether the order mask is opened (and if so, with which order).

.cxp:

Var(orderid, orderview) //<- to keep track of whether we are opening the order view or not Msg(EDIT_ORDER_AUTO) EDIT_ORDER_AUTO: { LocalVar(json) -> json "params.order" json Call(HasTyped) if { json Copy(params.order) -> orderid } TRUE -> orderview //Activate navigation to order view //Now, we have noted, that we want to open the order view and we have to wait for the user to log in } //User has logged in, check whether a view is set and open it LOGGED_IN: orderview if { //should navigate to order view? orderid if { LocalVar(orders) orderid "uniqueID = %s" Find(CX_SALES_ORDER) Dup -> orders Cardinality if { 0 orders GetElement //Put selected order on stack for EDIT_ORDER } else { //Not found NULL } } else { //No orderid given NULL } PostMsg(EDIT_ORDER) }

With this auto handler a new order can now be created via the URL /?auto=edit_order and the first order (if available) can be edited with the URL /?auto=edit_order&order=000001.

For static MorphIT

If direct links are to be used in static MorphIT mode, the message VALIDATE_AUTO_POST must first be defined as described here.

For direct links to specific static views (no action in ClassiX) there are the alias views.