Salesforce

How Do I Create a Function? (Magic xpa 3.x)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

How Do I Create a Function? (Magic xpa 3.x)

In Magic xpa, a function is just a special type of logic unit. Functions use the same input parameters, local variables, and the same operations that are available for the other logic units. One main difference is that they have a return value, so that when a function is used in an expression or on a form, the value can be used directly in the expression without using a variable to hold a parameter.

For instance, in this example, we have a function that formats a date into a complex formatted string for reports. The formatted string can be used directly on the form, by using the function in an expression.

The other difference is that your functions show up on the Function List right along with all the built-in Magic xpa functions, complete with a list of the expected parameters. This makes them easy to find and to use. This also means that if you name your function the same as a built-in function, you can override the built-in function. So if you want to extend or change a built-in function, you can.

Below is a summary of how to create a function.

Function Scope

The scope of a function depends on where it is located, and on the value of the Scope property of the function.

  • If the function is in a task and the Scope is set to Task, then the function will only be visible for that task.

  • If the function is in a parent task, and the Scope is set to Subtask, then the function will be visible for all subtasks. Therefore, if the function is in the Main Program, it will be visible for the entire application.

  • If the function is part of a component, then it can be shared across many projects.

Creating a Function

  1. Go to the Logic section of your task.

  2. Press Ctrl+H to open up a header line.

  3. Type F to make this a function. The cursor will move to the right, into the Function Name field.

  4. Type in your name for this function. You can use any name, but if you use the name of an existing Magic xpa function, then you will override the function provided by Magic xpa.

  5. Create your input and output parameters, if any (see How Do I Set the Function’s Parameters? for details on how to do this).

  6. Create your return values (see How Do I Set the Return Value of a Function? for details on how to do this).

Now you have created a function! The function will show up on the Function List with all the built-in Magic xpa functions, which makes it easy to use.

See also

The Online and Rich Client Samples projects (program LG01 and RLG01)

Reference
Attachment 
Attachment