Business Component Add method

Official Content

This method can be applied to a variable based on a business component type of a transaction that have 2 or more levels, in order to add an item -in memory- to the collection associated to the lines of a nested level.

Syntax

&VbleBasedOnBCType.NameGivenToNestedLevelInTypeColumn.add(&VbleBasedOnBCLevelType)

Where:

&VbleBasedOnBCType
      Is a -temporary and local- variable defined in a GeneXus object, based on a business component type of a transaction that have 2 levels or more.

NameGivenToNestedLevelInTypeColumn
     Is the name you gave to a subordinated level in a transaction that have 2 levels or more in the "Type" column.

&VbleBasedOnBCLevelType
     Is a variable based on the data type of a line which you want to add in the collection in memory (when the transaction has 2 levels or more, GeneXus creates as many data types in the Knowledge Base as levels in the transaction, and the names of the nested levels data types are the result of the concatenation of the transaction name + dot + the name you gave to the level in the "Type" column in the structure).

Example

Let's take into account the following transaction which was set as Business Component:

InvoiceTrnBC

Now let's suppose in a certain object, like a procedure, we define the following variables and source:

&Invoice - Data type: Invoice
&InvoiceLine - Data type: Invoice.LineType

//we assign values ​​to the properties (attributes) of the 1st level variable
&Invoice.InvoiceId = 12
&Invoice.CustomerId = 50
&Invoice.InvoiceDate = &today

//we assign values ​​to the properties (attributes) of the 2nd level variable + we add the variable to the collection 
&InvoiceLine.ProductId = 1
&InvoiceLine.InvoiceLineQuantity = 10
&Invoice.Line.Add(&InvoiceLine)

//we request memory for a new instance of a 2nd level variable + we assign values ​​to the properties (attributes) of it + we add the variable to the collection
&InvoiceLine = new()           
&InvoiceLine.ProductId = 2
&InvoiceLine.InvoiceLineQuantity = 20
&Invoice.Line.Add(&InvoiceLine)

&Invoice.Save() 
If &Invoice.Success()
   Commit     
else
   Rollback
endif


See also

Business Components Methods




Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.