Salesforce

How Do I Set the Return Value of a Function? (Magic xpa 4.x)

« Go Back

Information

 
Created BySalesforce Service User
Approval Process StatusPublished
Objective
Description

How Do I Set the Return Value of a Function? (Magic xpa 4.x)

One of the main advantages of functions is that they can have a return value. This value can be used directly on a form or as a parameter, or be nested inside other functions, without the use of intermediate variables. This makes coding very efficient.

Also, because functions are always called in an expression, the input parameters are purely input. Any changes you make to parameters in the function are not passed back to the caller. So if you want to pass back any data, you will need to do that in the return value.

Still, the use of a return value is purely optional. You are not required to send back any value.

Note that you can send back any data type for your function. It is up to you to use the function correctly. However, if you use, say, a function that returns a string in a numeric field, the syntax checker will report it as an error (Attribute mismatch).

Setting a return value for a function


  1. Go to your function.

  2. Move to the Returns: field, by clicking on it or tabbing to it.

  3. Zoom (F5 or double-click) on the Returns: field. This will bring you to the Expression Rules.

  4. Enter an expression that will evaluate to the value you want to return. In this case, we used Trim() and Dstr() to format the date into a string.

Now, when the function is executed, it will return what you specified in the expression.

See also

The Online and Rich Client Samples projects (program LG03 and RLG03)

Reference
Attachment 
Attachment