Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The Action Type option in SWAT supports the 'INVOKE' setting. This exists as an option in menuFunctions and offers an easier and standardized method of calling back-end logic. The actual BusinessTask call is done automatically by the framework, and the BusinessTask parameters can be set from the menuFunction. Furthermore, any other checks, validations or parameter settings are supported (before and after the backend call) by defining two JavaScript events: eventPre and eventPost.

Sample of a menuFunction: 

  • Action Target - the BusinessTask class name

  • Action Parameter - the method name to be called from the BusinessTask

  • Action Options - list of options/settings for the invokeServerTask method, as a list in a valid JSON format

  • Event pre - client logic method which is called before the BusinessTask call to the backend. Receives two parameters: eventSource (the context) and params (the menuFunction options)

  • Event post - client logic method which is called after the BusinessTask call to the backend. Receives two parameters: eventSource (the context) and params (the backend response)


Sample for Event pre, if it would be called from a Toolbar button:

...

The method receives two parameters: Toolbar and Options. Toolbar would be the controller from where the action was triggered and Options contains the menuFunction options. 


Sample of the Options parameter:

Code Block
eventPost: "$ akioma.eventPost(eventSource, params);"
eventPre: "$ akioma.eventPre(eventSource, params);"
methodName: "MethodBT"
name: "Akioma.Swat.BT"
options: "{'showWaitCursor': true}"
optionsJSON: {showWaitCursor: true}
params: {plcParameter: {}}

...

After the backend call is done, the Event post will be called. 

Sample for Event post: 

Code Block
export function eventPost( Toolbar : akioma.swat.Toolbar, Result: any) {

	if (Result.error) {
		// client logic for error handling 
	} else {
		// client logic for success handling
	}

}

...