Salesforce

How Can I Use Magic xpa User Functions in Magic xpi? (Magic xpi 4.13)

« Go Back

Information

 
Created BySalesforce Service User
Approval Process StatusPublished
Objective
Description

How Can I Use Magic xpa User Functions in Magic xpi? (Magic xpi 4.13)

You can bring user-defined Magic xpa functions into your Magic xpi project. To do this, follow these steps.

Magic xpi

In Magic xpi, follow these steps:

  1. From the Project menu, select Settings. The Settings dialog box opens.

  2. In the Settings dialog box's General Environment section, click User Environment Variables.

  3. Make a note of the path set in this setting.

This setting can also be defined in the [MAGIC_LOGICAL_NAMES] section of Magic xpi’s Magic.ini file, which is located in the <Magic xpi installation>\Runtime\Magic xpa folder.

Magic xpa

In Magic xpa, follow these steps:

  1. Create a new project.

  2. Create a user-defined function. The user-defined function should always be defined in the Main Program.

  1. Create a cabinet file of this project making sure that the name is same as the name defined in Magic xpi’s UserFunctionsLocation setting (as described above).

  2. Save the file to the path defined in Magic xpi’s UserFunctionsLocation setting. For example: C:\Magic xpi 4.6\Runtime\User resources\UserFunctions.ecf

Magic xpi

Back in Magic xpi, follow these steps:

  1. Open the <Magic xpi installation>\Studio\FunctionDescription.en.xml file and add your function to the list with the relevant details, including the return type and parameters if required. You do this by copying an existing function, such as the one below, and editing the DisplayName, ReturnValue and Description tags, the <Parameters> section and any other relevant tags:

    <Function>
    <DisplayName>ABS</DisplayName>
    <ReturnValue>N</ReturnValue>
    <HideItem>N</HideItem>
    <MinArgNum></MinArgNum>
    <MaxArgNum></MaxArgNum>
    <Obsolete></Obsolete>
    <HelpID>9032</HelpID>
    <FunctionSignature></FunctionSignature>
    <Description>Returns the absolute value of a real number, without regard to sign.</Description>
    <Parameters>
    <Parameter>
    <Name>number</Name>
    <Type>N</Type>
    <Description>Any number.</Description>
    </Parameter>
    </Parameters>
    </Function>

  2. Open the Studio and verify that your newly created function is available in the Expression Editor.

  3. To be able to use the new function with the Data Mapper, you also need to add your function as an objectid in the comps.exp file. This is located in the <Magic xpi installation>\Runtime\Templates\Mapper folder. You do this by copying the text below to the file and updating the values of the Component name, the MciFile val tag, and the PublicName val tag:

    Component name="UserFunction">
    <CompId val="463816514-25434-19825-92354D96D"/>
    <MciFile val="C:\Magic xpi
    4.6\Runtime\Magic Xpa\Builders\ECI\userfunctions\UserFunction.eci"/>
    <ComponentType val="Magic xpa"/>
    <Type val="U"/>
    <CABINET_FILE val="%UserFunctionsLocation%"/>
    <LoadImmediate val="Y"/>
    <CtlIndex val="6"/>
    <LastISN val="1"/>
    <ComponentFuncs>
    <Object>
    <id val="1"/>
    <ItemIsn val="1"/>
    <PublicName val="userfunctionsTest"/>
    </Object>
    </ComponentFuncs>

Since version:

4.5

Reference
Attachment 
Attachment