Assigns a value to a variable or a variable property.
&var | &var.property operator expression
Where:
&var | &var.property
Is the variable or variable property to be assigned.
operator
One of the following assignment operators: = , +=, -=, *=, /=.
expression
Is any valid expression that can involve constants, functions, methods, procedures, variables, attributes, arithmetic calculations, Inline Formulas. The result must match the variable data type definition.
Description
You may want to assign a value to a variable or a variable property, within the definition of an object.
The object section where the assignment may be defined depends on the object (Rules and Events in Transaction objects, Rules and Source in Procedure objects, etc.).
The value type to be assigned must match the variable or variable property type. Otherwise, the navigation report will display a warning message.
Consider the following Transaction objects:
Customer
{
CustomerId*
CustomerName
CustomerAddress
CustomerPhone
}
Invoice
{
InvoiceId* (Autonumber property = Yes)
InvoiceDate
CustomerId
CustomerName
InvoiceAmount
}
1) The following example assigns, to a variable, the result of all invoice total amounts (this code may be included, for example, in a Procedure Source or Web Panel Event):
&InvoicesTotalAmount = Sum(InvoiceAmount)
2) The following example assigns the True or False value to a variable, depending on whether a specific customer has invoices or not (this code may be included in a Procedure source or Web Panel event, upon considering if the context of the Web Panel has base table or not):
For each Customer
where CustomerId=15
&CustomerHasInvoice=True
when none
&CustomerHasInvoice=False
EndFor
Note: Instead of filtering by a fixed value of CustomerId, the object may receive a variable as a parameter (for example &CustomerId in the
Parm rule) and use it in the where clause.
3) Suppose you have configured the Invoice Transaction Business Component property = True, and you define in a Web Panel the &Invoice variable based on the Invoice BC data type.
The following code assigns a value to each &Invoice variable property. Following such assignments, it inserts the customer record:
&Invoice.InvoiceDate=&today
&Invoice.CustomerId=10
&Invoice.InvoiceAmount=100
&Invoice.save()
Commit
Assignment command for attributes
Assignment rule