Skip to content

Executions

if

Same implementation as commands. Logic expressions are supported. See the Expressions section for more information.

if [VarBusinessObject != null and VarRefId1 != null] {  
   // executions  
}  

set

Similar implementation to commands. Logic expression support has been added to allow operations on values. Expressions must be placed within square brackets [ ].

set VarIssued = 2;  
set VarIssued = [(Material.ToIssue * 2) + Material.Issued];  
set Wo.AddressDetail = NewAddress;  
set Wo.AddressDetail = [WoAdd.Line1 + ", " + WoAdd.Line1];  

When setting individual variables string interpolation should be avoided. Interpolation will change the type of the variable to a string.

set MyVar = "${OtherVariable}"; // Avoid this. OtherVariable is converted to a string  
set MyVar = OtherVariable; // Use this instead  

return

Allows returning a value from a procedure. Logic expressions are supported. Expressions must be placed within square brackets [ ].

return MyVar;  
return [MyVar * 2];  

call

Allows calling into other procedures and getting data from the system.

call UtilityProcedure(WoNo, VarSeqNo) into VarResult;  
call DateTime.Timestamp() into VarNow;  

error

Used for database validation. Stops execution of the procedure and shows the error message to the user. An optional second parameter can be provided to specify which part of the input was invalid and improve UI feedback.

error("All operations on work order must be completed");  
error("Materials to issue must be greater than 0", "Record.ToIssue");  

log

Used to log messages to the client log files.

log("Failed to find work order ${WoNo}");  

trace

Used to log trace messages to the client log files. These messages will only be output if trace logging is enabled for the user’s device in the Aurena client. This allows the log file sizes to be kept to a minimum during normal use.

trace("Failed to find work order ${WoNo}");  

debug

Used to log debug messages to the client log files. Debug messages should be used to help solve problems in procedures during development. These messages are only output to the log files in the developer app (not in the released app).

debug("Failed to find work order ${WoNo}");  

super

Calls into the super layer of the procedure implementation. See the Layers section for more information.

super(Record) into Record;  
super(Param1, Param2);  

save

Saves a structure to the database and optionally sends the changes to the server.

// Save the record in variable ‘Record’ locally  
// Do not send any changes to the server  
saveLocal Record;  

// Save the record in variable ‘Record’ locally  
// and send the changes to the server  
saveAndSend Record;  

delete

Deletes a structure from the database and optionally sends changes to the server

// Delete the record in variable ‘Record’ locally  
// Do not send any changes to the server  
deleteLocal Record;  

// Delete the record in variable ‘Record’ locally   
// and send the delete to the server  
deleteAndSend Record;  

performAction

Adds a transaction to the sync queue to perform the current action procedure. The action we be sent to the server on the next sync.

performAction;  

create

Creates a new record with the default values set for that entity. The name of a structure variable is passed. The entity type of that structure variable is used to create the record. As part of the create the client generated primary keys will be populated and the relevant prepare method will be called to provide the default values.

create Wo;  

fetch

Fetches a single record out of the database into a variable. A where statement can optionally be provided. Selecting on a structure variable reference can be used to simplify the fetch. An alias can be provided to remove ambiguity in the where.

// Fetch the record referenced by the AddressRef from the Wo structure variable.  
fetch Wo.AddressRef into WoAddr;  

// Fetch the first record from the WorkOrder entity set and  
// place it into the Wo structure variable.  
fetch WorkOrder into Wo;  

// Fetch the first record from the WorkOrder entity set that has  
// the Objsetate set to ‘ONSITE’ and place it into the Wo structure variable.  
fetch WorkOrder where [ Objstate = "ONSITE"] into Wo;  

// Fetch the first work order that has the Objstate the same value   
// as a variable called Objstate. Use an alias to remove ambiguity  
fetch WorkOrder i where [ i.Objstate = Objstate] into Wo;  

// Fetch the first on site work order ordered by creation date  
fetch WorkOrder where [ Objstate = "ONSITE" ] orderby [ CreationDate ] into VarA;  

// Fetch latest created work order, if there are multiple return  
// the one with the lowest Wo No  
fetch WorkOrder orderby [ CreationDate desc, WoNo ] into VarA  

for

Fetches local database data and loops over the records to allow executions on them. A where statement can optionally be provided. Selecting on a structure variable array can be used to simplify the for. An alias can be provided to remove ambiguity in the where.

Performance should be considered when using the for loop. Any records read will have all columns read from the database. For a large set of rows with binary data this can take considerable time and device memory. The number of records expected to iterate over should be kept to a minimum. Add a where statement wherever possible.

// Loop over the WorkOrders entity set  
// The Wo variable can be used to access the looped record  
for WorkOrder into Wo {  
   // executions  
}  

// Loop over the WorkOrders entity set that have the Objstate ‘ONSITE’  
for WorkOrder where [ Objstate = "ONSITE" ] into Wo {  
   // executions  
}  

// loop over the work orders that have the Objstate the same value   
// as a variable called Objstate. Use an alias to remove ambiguity  
for WorkOrder i where [ i.Objstate = Objstate ] into Wo {  
   // executions  
}  

// Loop over the addresses a work order has based on the   
// AddressesArray from the Wo structure variable.  
for Wo.AddressesArray into WoAddr {  
   // executions  
}  

// Loop over the addresses a work order has with the city ‘Liverpool’  
for Wo.AddressesArray where [ City = “Liverpool” ] into WoAddr {  
   // executions  
}  

// Loop over the WorkOrders entity set that have the Objstate ‘ONSITE’  
// ordered by Description ascending  
for WorkOrder where [ Objstate = "ONSITE" ] orderby [ Description ] into Wo {  
   // executions  
}  

// Loop over the addresses a work order has ordered by the PostCode  
// and then AppartmentNo descending  
for Wo.AddressesArray orderby [ PostCode, AppartmentNo desc ] into WoAddr {  
   // executions  
}  

The for loop supports the break keyword within an if condition, which can be used to exit the loop.

for WorkOrder into Wo {  
   // executions  

   if [Wo.Objstate = "REJECTED"] {  
      break;  
   }  

   // executions  
}  

while

Executes the while loop body if the expression is true.

// variable StartIndex Integer;  

set StartIndex = 1;  
while [StartIndex < 4] {  
   // executions executed 3 times  
   set StartIndex = [StartIndex + 1];  
}  

In the above example, the while loop will execute its body 3 times before finishing.

The while loop supports the break keyword within an if condition, which can be used to exit the loop.

// variable StartIndex Integer;  

set StartIndex = 1;  
while [StartIndex < 10] {  
   set StartIndex = [StartIndex + 1];  

   if [StartIndex = 5] {  
      break;  
   }  
}  

count

Counts records. A where statement can optionally be provided. Selecting on a structure variable array can be used to simplify the count.

// Count the number of rows in the WorkOrders entity set  
// and put the count into a variable named WoCount;  
count WorkOrder into WoCount;  

// Count the work orders that have the Objstate ‘ONSITE’  
count WorkOrder where [ Objstate = "ONSITE" ] into WoCount;  

// Count the work orders that have the Objstate the same value   
// as a variable called Objstate. Use an alias to remove ambiguity  
count WorkOrder i where [ i.Objstate = Objstate ] into WoCount;  

// Count the number of addresses a work order has based on the   
// AddressesArray from the Wo structure variable.  
count Wo.AddressesArray into WoAddrCount;  

// Count the number of addresses a work order has with the city ‘Liverpool’  
count Wo.AddressesArray i where [ i.City = "Liverpool" ] into WoAddrCount;