ObjectsXMLForeign

You can use the ObjectsXMLForeign function to retrieve XML data for objects that are linked or referenced from a base object through foreign key relationships. For example, you can retrieve XML data for items linked to a formula through its ingredient list, referenced objects, or UOM codes.

When to use

You can use this function to:

  • Retrieve XML data for items, references, or other objects linked from a base object.
  • Export complete data, including foreign object details, for integration or reporting purposes.

How foreign XML is built?

The function can build foreign XML when the baseFld argument contains a value in one of the following fields in the FsValidationField table:

Field Description
Key_Check Validates against key fields.
Lookup_Code References lookup table entries.
Enum_Query Works only for entries equal to a symbol name.
Note: 

For the Reference detail object, these rules apply:

  • The symbol code for the referenced object is used.
  • The baseFld setting is ignored.
  • The first column, which contains the key code for the referenced object, in the Reference grid is used.

Syntax

string ObjectsXMLForeign(string baseSymbol, string baseobjKey, string baseDtl, string baseFld, string targetDtls);
string ObjectsXMLForeign(string baseSymbol, int baseobjId, string baseDtl, string baseFld, string targetDtls);

Parameters

Parameter Type Required Description
baseSymbol string Yes The symbol code of the base object that contains links to foreign objects. For example, "FORMULA", "ITEM"
baseobjKey string Yes The key code of the base object. For example,"00033\001"
baseobjId int Yes The ID of the base object that contains the links to the foreign objects
baseDtl string Yes The detail code of the base object to inspect that contains links to foreign objects (e.g., "INGR", "REF", "HEADER")
baseFld string Yes The field in the base object that contains the link to the foreign object. For example, "ITEM_CODE", "OBJECTCODE", "UOM_CODE"
targetDtls string Optional The list of detail codes on the foreign object to retrieve. For example,"HEADER", "INGR".
Note:  You can use empty string "" for all details.

Return Value

The application retruns a value zero (0) if the operation is successfull.

Impact

  • Copies all detail records, such as ingredients, parameters, and references, to the new object.
  • The new object becomes immediately available to authorized users.

Prerequisites

  • The source object must exist and be accessible.
  • The new key must be unique and must not already exist.

Examples

Example 1
Retrieve All XML for Each Ingredient .
string sXn2 = ObjectsXMLForeign("FORMULA", "00033\\001", "INGR", "ITEM_CODE", "");
Description
This example retrieves all of the XML for each ingredient in the formula.
Example 2
Retrieve Only Header XML for Ingredients.
string sXn2 = ObjectsXMLForeign("FORMULA", "00033\\001", "INGR", "ITEM_CODE", "HEADER");
Description
For each ingredient row in the formula, this script retrieves only the XML for the header information.
Example 3
Retrieve Header XML for References.
string sXn2 = ObjectsXMLForeign("FORMULA", "00033\\001", "REF", "OBJECTCODE", "HEADER");
Description
This example retrieves the header XML for all of the references in the formula.
Example 4
Retrieve UOM Header XML .
string sXn2 = ObjectsXMLForeign("FORMULA", "00033\\001", "HEADER", "UOM_CODE", "HEADER");
Description
This example retrieves the XML from the header of the Unit of Measure object. This information is used forthe formula yield.
Example 5
Retrieve Specification References.
string sXn2 = ObjectsXMLForeign("FORMULA", "00033\\001", "REF.V\\REFFORMULA02", "OBJECTCODE", "HEADER");
Description
This example gets the header XML for all of the specification references for this formula. It uses the Lookup_Codefrom the FsLookup table that corresponds to the desired object type.