Struct::merge Method [AX 2012]

Combines two structs to create a new struct.

client server public static Struct merge(Struct struct1, Struct struct2)

Run On

Called

Parameters

struct1
Type: Struct Class
The first struct.
struct2
Type: Struct Class
The struct that will be added to the end of the first struct to create a new struct.

Return Value

Type: Struct Class
The new struct.

struct2 is added to the end of struct1. This means that the order of the items in the new struct will be: all the items in struct1, arranged in alphabetical order of the item names, followed by all the items in struct2, arranged in alphabetical order of the item names. If both structs contain an item with the same name, only the item from the first struct will be included.

The following example creates two structs called person and address, and then merges them into a new struct called allInfo.

{ 
    container packedStruct; 
    Struct person = new Struct ("str name; int age"); 
    Struct address = new Struct ("str street; str city; str country"); 
    Struct allInfo; 
  
    person.value ("name", "Jane Dow"); 
    person.value ("age", 34); 
    address.value ("street", "Downing street 10"); 
    address.value ("country", "Great Britain"); 
    address.value ("city", " London"); 
  
    allInfo = Struct::merge(person, address); 
  
    print allInfo.toString(); 
    pause; 
}
Show: