Introduction
In this section you will learn how to implement a basic typescript function which will triggered by an event in a screen. This example focus on passing data from an overview screen to a called Create-Screen, e. g. if you want to create an offer for a customer and call the offer Create-Screen from the customer detail page. In this case the customer number should be insert automatically to the screen.
Example
- Given the following example:
- You have an customer overview screen with the objects:
custDSOcustFormandribbon - In the ribbon you have included a function to startup the
offerCreateDialog - In the
offerCreateDialogthere’s theofferCreateFromwhich includes beside others the fieldcustomeerNumber
Steps
- In your gitpod environment open Build.One in the Simple Browser (not in a separate tab)
- Open up your screen in designer
offerCreateDialogand launch the actionOpen events filein the top Ribbon - With this a new typescript file should be opened in the correct folder in the gitpod environment
- The file is named like the screen with appendix
.ts - In this file you can implement your typescript function. For that you can use the integrated templates, just type in
b1-eventFunctionand the base structure of such a function will be inserted in your file, namedmyFunction
export function myFunction(eventSource: akioma.swat.SwatObject) {
}- Here you can implement your logic. Afterwards there are some example which can be used
- For checking the object, which calls the
offerCreateDialogyou can useeventSource.callerand assign it - For checking the connected object of the caller use
eventSource.caller.getLink('DATA:SRC')(which gets the source object of the data connection - For getting the field in the
offerCreateDialoguseeventSource.GetObject('NAME') - For more examples see CLAPI documentation https://clapi.build.one/
- To include you function into your screen use the following attributes in the
offerCreateDialog EventNamespace: Defines the Namespace, use#for default namespace- Any event (e.g.
EventOnInitialize): Include here your function using the namespace, e.g.#.myFunction(eventSource); - Hint: When you add a new function, you have to trim the PASOE, if you change a function you have to reload your testing application (without cache) to see the changes