Struct.add Method [AX 2012]
Adds a new item to the struct and assigns the specified value to it.
public boolean add(str fieldName, anytype value)
Run On
CalledParameters
- fieldName
- Type: str
The name of the new item.
- value
- Type: anytype
The value to assign to the new item. This value defines the type of the item.
Return Value
Type: booleantrue if the value has been added to the struct; false if the value could not be added (if it already existed in the struct).
The following example creates a struct with two items name and age fields and assigns values to those items. The add method is then used to create an additional item the shoeSize variable, with a value of 43. The type of the value determines the type of the new item, int.
{
Struct s = new Struct ("str name; int age");
// Prints number of items (2)
print s.fields();
// Values are assigned to the two items
s.value("name", "John");
s.value("age", 34);
//Another item is added to the struct
s.add("shoeSize", 43);
// Prints number of item (3)
print s.fields();
// Prints a description of the items in the struct
print s.definitionString();
pause;
}
Community Additions
ADD
Show: