Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
outlinetrue
stylenone

Summary

The Import Conditional Logic is similar to PHP code, except in how some of the variables are named and referenced, and the very limited white list of available functions. Whenever the SaveImage Modified button on the Conditional Logic form is pressed, a validator will run to check the logic for errors. If errors are detected, the form will not be saved. At any time, the User can press the Validate button, and it will run the check and report any existing errors.

Help Button

A HelpImage Modified button is displayed on the form where the User can enter Conditional Logic. When that button is pressed, a complete list of the PHP constructs and functions that are available will be displayed.

Allowed Functions

Array

explode , implode , is_array , in_array , array_diff , array_diff_key , count

JSON

json_decode , json_encode

Date/Time

date , time , mktime , strtotime , DateTime , DateInterval , add , sub, diff, format , setTimestamp , setTime , setDate

Logical

if , elseif , else , switch , case , default , break , for , foreach , as , while , do-while , return , new

Mathematical

round , trunc ,ceil , floor , rand , srand , pow , exp , abs , max , min , bindec , hexdec , octdec , base_convert

PCR-360 Utility

PCR_Utility_Logger, getInstance, notice

String

is_numeric , strtolower , strtoupper , substr , stristr , strstr , stripos , strpos , strripos , strrpos , addslashes , chr , trim , ltrim , rtrim , str_replace , preg_match , preg_replace , preg_splitstr_pad , sprintf , substr_replace , strlen


Referencing a Value from the Import File

To reference a value from the Import File, square brackets surrounding numbers to specify the csv index (column) must be used, or the position and size, we  we use 0 based counting from the start of the line, the first column or first character position is actually 0. For  For example, with a delimited file, to reference the index (column) 5, [4] would be used. For a fixed-width file, to reference a string starting at character 10 and spanning 4 characters, [9,4] would be used. 

To assign a value to one of the index (column) being assigned by the Import, the name of the table and name of the index (column) surrounded by square brackets would be referenced. For example, for a Contact Import, the User may want to set the first name. The reference would be [CONTACTS.FIRST_NAME]. On the Conditional Logic form, there is a helper button to help build these references. Click in the Conditional Logic window to position the Caret, then use the Record Column drop-down to select which index (column) to be referenced, then press the Insert Record ColumnImage Modified button. This will insert the correct reference into the Conditional Logic window. 

...

You can also set the ignore flag to a string, using an array syntax, like this:

<code block>
[FLAGS.IGNORE][] = "The reason for the ignore";
<end code block>

This will let the reason get counted in the Import Files report totals. This can be useful if your Conditional Logic has several different rules that can cause a record to be ignored. It will let you see totals of how many records are ignored for each reason.

[FLAGS.FILENAME]

This is a read only field that contains the filename of the Import File being imported.

[FLAGS.FILELINE]

This is a read only field that contains the line number from the Import File of the record currently being imported.

...

Code Block
if ([CONTACTS.FIRST_NAME] == 'Joe') {
 [FLAG.IGNORE] = true;
}

This is a special assignment that will cause this input line to not get processed.

Note: The above example assumes [CONTACTS.FIRST_NAME] had been assigned prior to that code.

...