Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

ArgumentTypeDescription
cache keyExpressionAny valid Expression
expressionNExpressionAny valid Expression

Examples

Example Setup

Code Block
$result = cache("accountRef", _cacheValue + 1)

...

Return the cache value for key value "accountRef".

Code Block
$result = cache("accountRef", _cacheValue + 1)


Example Generating UIDs

This example is for the case where a user wants to generate UIDs in a specific way.

In this example, the table receives both updates for existing records and new records. This table is used to correctly set/lookup the various ID fields.

If 3 records came into this table that had the same value for a specific attribute (e.g. another ID field such as "BarcodeNumber"), then we do not want to generate a new ID for each record, instead, we want to generate a single ID and use this value for all three records. The configuration is as follows:


Code Block
do(
	if($newRecord,
	// then
		do(
            $recordID = cache(_out.BarcodeNumber,
				if( _cacheValue == _NULL,
				// then	
					$recordID = nextValue('RecordID'),
				// else
					_cacheValue
                )
            )
                
		),
	// else
		$recordID = in.RecordID
    ),
    $recordID
)


This expression above uses the cache function to hold a newly generated ID (nextValue('RecordID') in memory for each unique _out.BarcodeNumber field. So the 1st record that is processed gets the new ID generated by the sequence, and then any subsequent records that are processed will find a match for their BarcodeNumber in the cache, and take that ID that was generated for the 1st BarcodeNumber.


See Also