Dynamic Content Documentation
GetAndDeleteRow method returns a single row from the data table and then deletes it. If more than one row is found, only first is returned (SELECT TOP(1)...) and deleted.
This method is suitable to work with single-use, disposable data, such as promo codes or coupons. For example: each subscriber can receive an unique value from data table. The value cannot be used again, because it is immediately deleted after use.
The method has similar parameters to GetRows method - returned columns and filters can be specified.
row = GetAndDeleteRow(table, columns, filters, filterOperator)
Parameter definition
Filter object parameter definition
NOTE: Typically, Filter objects are created using constructors, which is more convenient - see examples for more information.
Values returned by GetAndDeleteRow are arrays of column values (key-value pairs). To access them, they need to be enumerated or accessed using indexes.
This method is suitable when we want to e.g. display all columns returned by the method. We simply treat the returned value as an array and use "each" attribute to browse it.
<table>
<tr>
<td each="var column in GetAndDeleteRow('MyCouponsTable')">
${column.Value}
</td>
</tr>
</table>
Since returned value is an array, we may access individual columns directly, using array indexing. In this case, column names are used as index, so we are required to know what columns can be expected. Using wrong column name will result in an error.
<var row="GetAndDeleteRows('MyCouponsTable')"/>
<div>Column no 1: ${row['MyFirstColumn']}</div>
<div>Column no 2: ${row['MySecondColumn']}</div>
<div>Column no 3: ${row['MyThirdColumn']}</div>
Below are several examples of using GetAndDeleteRow method parameters to create different requests to data tables.
Example 1 - The most simple call
First found record from the table is returned and deleted. All columns are returned.
GetAndDeleteRow('MyCouponsTable')
Example 2 - Returning only specific columns
First found records from the table is returned and deleted. Only columns specified in the request are returned.
GetAndDeleteRow('MyCouponsTable', new [] {'Coupon', 'ExpirationDate'})
Example 3 - Filtering records
First row matching specified criteria is returned and deleted. All columns are returned.
GetAndDeleteRow('MyCouponsTable', null, new [] {new Filter('PromoName', EQ, 'XMas Promo')})