Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
minLevel1
maxLevel6
outlinetrue
typelist
separatorbrackets
printabletrue

For reference on all non-PCR-360 Functions, please refer to the PHP Documentation.

Allowed Functions

Array

explode , implode , is_array , in_array , array_diff , array_diff_keycountarray_column, array_chunk, array_combine, array_count_values, array_diff, array_diff_assoc, array_diff_key, array_fill, array_fill_keys, array_flip, array_intersect, array_intersect_assoc, array_intersect_key, array_intersect, array_is_list, array_key_exists, array_keys, array_merge, array_merge_recursive, array_multisort, array_pad, array_pop, array_product, array_push, array_rand, array_reduce, array_replace, array_replace_recursive, array_reverse, array_search, array_shift, array_slice, array_splice, array_sum, array_unique, array_unshift, array_values, compact, count, current, end, extract, in_array, key_exists, krsort, ksort, list, next, pos, prev, range, reset, rsort, shuffle, sort

Class/Object

get_called_class, get_class, is_a, is_subclass_of

Class/Interface Access

DateInterval, DateTime, Exception, PCR_Event, PCR_Exception, throwable

JSON

json_decode ,   json_encode, json_last_error, json_last_error_msg, json_validate

cURL

curl_init , curl_setopt , curl_exec , curl_errno , curl_error , curl_getinfo , curl_close , http_build_query

Date/Time

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

Debug

error_log, debug

Debug Function
Code Block
languagephp
$this->debug();

Note: The debug command outputs to a cache which is then displayed in the Debug tab/grid for the Custom Logic you are debugging.

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_convertcurl_close, curl_copy_handle, curl_errno, curl_error, curl_escape, curl_exec, curl_getinfo, curl_init, curl_pause, curl_reset, curl_setopt, curl_setopt_array, curl_strerror, curl_unescape

Date/Time

add, diff, date_add, date_create, date_create_from_format, date_diff, date_format, date_get_last_errors, date_interval_create_from_string, date_interval_format, date_parse, date_parse_from_format, date_sub, date_time_set, date_timestamp_get, date_timestamp_set, date_timezone_get, date_timezone_set, date, format, mktime, microtime, setDate, setTime, setTimestamp, strtotime, sub, time

Exception Handling

getPrevious, getCode, getLine

Logical

as, if, break, case, catch, continue, default, do, else, elseif, finally, for, foreach, function, match, new, return, switch, try, while

Mathematical

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

PCR-360 Data

call, query listFindCode, listFindValue, listGetByCode, listFindValue , listFindCode query

...

call Function: Calling API Logic
Code Block
languagephp
// $apiFunction Examples: saveService, saveServiceDesk, saveContact, saveCable, saveGla, saveEquipment, etc.
array $this->call(string $apiFunctionToCall, array $params, bool $commitOnSuccess);

...

query Function: Querying Data
Code Block
languagephp
array $this->query ( string $sql, array $bind_parameters );
listGetByCode Function: Retrieving List Values
Code Block
languagephp
mixed $this->listGetByCode ( string $list_type, mixed $list_code );
listFindValue Function: Retrieving List Values
Code Block
languagephp
string $this->listGetByCode >listFindValue( int $recid );
listFindCode Function: Retrieving List Values
Code Block
languagephp
string $this->listGetByCode >listFindCode( int $recid);

PCR-360 Debug

debug, error_log

debug Function: Debugging Custom Logic
Code Block
languagephp
$this->debug(mixed $debug);

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

Additional Functions

Contact PCR if you find a function that is not allowed, but would like to use. 

Validation functions

setError

PCR-360 Events

attach, attachDb, callCustomEvent, detach, detachDb, trigger

PCR-360 Reports

addError, assign, barcode, loadReport

PCR-360 Utility

arrayToCsv, createFile, sendSystemMessage

arrayToCsv Function: Building CSV Data
Code Block
languagephp
string $this->arrayToCsv(array $data, string $delimiter = ',', string $enclosure = '"')
createFile Function: Creating Inbound/Outbound Files
Code Block
languagephp
int|false $this->createFile(string $filename, string|array $content, string $location = 'OUTBOUND', bool $overwrite = false);
sendSystemMessage Function: Sending a System Message
Code Block
languagephp
bool $this->sendSystemMessage(string $subject, string $body, int $contactRecid, string $identifier);

PCR-360 Validation

setError, setMessage, setWarning

setError Function: Errors and Warning in Validation

Sets a validation error message. This messages output in the UI if the validation logic returns false. If this function is called multiple times, only the message from the last calls is displayed.

...

Code Block
languagephp
$this->setError ( string $message );
setWarning Function: Errors and Warning in Validation

Sets the validation warning message. This messages output in the UI only if the logic does not return false. If this function is called multiple times, only the message from the last calls is displayed.

...

Code Block
languagephp
$this->setWarning ( string $message );

Triggering Events

PCR_Event, trigger, attach, attachDb, detach, detachDb

In this example the GLA Replace Event is triggered with specific parameters. For detailed information on which Events can be triggered, and how to trigger those Events, please navigate to the Triggerable Events List page.

PCR_Event Functions
Code Block
languagephp
PCR_Event::attachDb("replace-gla", [
    "Application_Model_Gla_Gla" => "eventReplaceGla"
]);
PCR_Event::trigger("replace-gla", [
	"contact" => 12345,        // Contact RECID
    "users_recid" => 456,      // Users RECID
    "glaRecid" => [1111],      // Old GLA RECID
    "replaceGlaRecid" => 2222, // Replacement GLA RECID
    "setInactiveGla" => true,
    "comment" => "This is a comment",
]);

...

In the Custom Logic tab, the following function will allow the User to call a Custom Event. This enables flexibility in having a single custom process gather data to be used in different pieces of Custom Logic.

$this->callCustomEvent('Event Identifier', $data ?? [])

Sending a System Message

A system message can be sent from Custom Logic using the following format:

Code Block
languagephp
$contactRecid = %YOUR-CONTACTS-RECID%;
$response = $this->sendSystemMessage(
	// Subject
    'Test Message',
	// Body
    'This is a System Message generated from custom logic',
	// The RECID of the contact the message will be sent to
    $contactRecid,
	// The identifier that will be included in the message header ("{$customerName} System Message\n({$logicIdentifier})\n\n";)
	%THE-CUSTOM-IDENTIFIER%
);
return true;
  • For Custom Events “THE-CUSTOM-IDENTIFIER“ is available from $data['custom_identifier'].

  • For the Custom API, “THE-CUSTOM-IDENTIFIER“ is available from $apiLogic['IDENTIFIER'].

  • For Custom Validation, “THE-CUSTOM-IDENTIFIER“ is not found in any of the variables, so we just need to make it match our Description of the Validation

  • For Custom Reports, “THE-CUSTOM-IDENTIFIER“ is available from $params['identifier']

Create a File on the Inbound/Outbound Directory using Custom Logic

Users can use Custom Logic to create files directly onto the Inbound/Outbound directories for processing either by internal processes (Inbound) or external processes (Outbound).

  • Example: arrayToCsv(array $data, string $delimiter=',', string $enclosure='"'): array

$data: An array of values to convert to a single line for a CSV

$delimiter: The character that is used to separate the values

$enclosure: Character used to encapsulate the data when the data contains the delimiter

This is a straight passthrough to PCR_Utility_Csv::array_to_CSV($data, $delimiter, $enclosure);

  • Example: createFile(string $filename, string|array $content, string $location='OUTBOUND', bool $overwrite=false) : int|false

$filename: The name of the file to create. Any path will be ignored; just the basename used

$content: The data to write to the file. String will be written as is, arrays will be written as if implode('', $content)

$location: The location in which to create the file. Supported values are INBOUND and OUTBOUND any other value should cause the function to return false after logging an error

...

If the location is not supported, it will log an error and return false

...

If the overwrite is false and the file exists, it will log an error and return a false

...

If the location does not exist, it will be created

...

Will call file_put_contents and check the result, if the result is false, an error will be logged

...

Regular Expressions (Perl-Compatible)

preg_filter, preg_grep, preg_last_error, preg_match, preg_match_all, preg_quote, preg_replace, preg_split

String

addslashes, bin2hex, chr, explode, html_entity_decode, htmlentities, htmlspecialchars, htmlspecialchars_decode, implode, ltrim, nl2br, number_format, rtrim, sprintf, str_contains, str_ends_with, str_getcsv, str_ireplace, str_pad, str_repeat, str_replace, str_shuffle, str_split, str_starts_with, strcasecmp, strip_tags, stripslashes, strtolower, strtoupper, substr_compare, substr_count, substr_replace, substr, stristr, strlen, stripos, strpos, strripos, strrpos, strstr, trim, wordwrap

URLs

base64_decode, base64_encode, get_headers, http_build_query, parse_url, rawurldecode, rawurlencode, urldecode, urlencode

Variable Handling

gettype, is_array, is_bool, is_float, is_int, is_iterable, is_numeric, is_object, is_string, isset

Additional Functions

Contact PCR if you find a function that is not allowed, but would like to use.