Salesforce

How Do I Set a Program to Return a Value to the Calling Program? (Magic xpa 3.x)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

How Do I Set a Program to Return a Value to the Calling Program? (Magic xpa 3.x)

There are two ways that a program can return values to a calling program. The first is to use parameters, which are covered in How Do I Synchronize Parameters Between Called Program and Calling Program?. The other way is to use a return value.

The return value is what you need when you call the program from an expression and some other types of calls. Here is how you enter it.

Creating a return value

  1. In your called program, zoom on Task Properties->General->Return Value. Create an expression for the value you want to return.

In this case, we have a batch task that iterates once, and returns today’s date, formatted for printing on certain reports according to our company’s standard. We do this in a program so that if the company standard changes, we only have one routine to change.

Using a return value

  1. Now, you can use your program anywhere you can enter an expression. In this example, we use it in an init field. The function CallProg calls our program, and the value is automatically returned into the string we are creating.

Note that CallProg calls the program by number. What happens if the program moves from position 36? You don’t need to worry about that, as long as you code the literal as shown here, with the letters PROG following the number in single quotes. Magic xpa will keep track of the number if it changes.

However, you can also use CallProg with the public name of the program, which is more readable. The syntax for that would be:

'Today''s date is: ' & CallProg(ProgIdx('DateString','TRUE'LOG))

See the Reference Guide for more information on the CallProg and ProgIdx functions.

Note: Magic xpa gives you a lot of options for standardizing your programs. In this case, we could also have used a model to standardize our date format or a function in the Main Program.

See also

The Online and Rich Client Samples projects (program TS03 and RTS03)

Reference
Attachment 
Attachment