Skip to main content
Skip table of contents

Custom Events

Custom Events may be created within PCR-360, however, support for these Events will be limited outside of Professional Services.  For specific questions, please send a message to your Account Manager. Any Errors encountered by the Custom Event, such as Error Details from an exterior API, will be added to the Error Log located at Admin > Error Log Explorer, as well as any related logs for Escalations.

Custom Logic: Events Grid example

The Events grid will store custom Event calls for PCR-360 to trigger Events in a particular instance of PCR-360. Using the image-20240820-173358.png button, a User can manually run their Custom Events.

Example Custom Event

Logic tab

The Logic tab is where the Custom Logic can be written and reviewed.

A User can quickly review the code written for the specific event with the image-20240820-181531.png button.

Users will be limited to the white-listed functions for PHP in PCR-360. A list of the functions can be seen in PCR-360 by clicking on the image-20240820-181535.png button.

Allowed Functions

Array

explode , implode , is_array , in_array , array_diff , array_diff_keycount

JSON

json_decode , json_encode

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
PHP
$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_convert

PCR-360 Data

call , query , listGetByCode , listFindValue , listFindCode

Call Function
PHP
// $apiFunction Examples: saveService, saveServiceDesk, saveContact, saveCable, saveGla, saveEquipment, etc.
$this->call(string $apiFunctionToCall, array $params)


Query Function
PHP
array $this->query ( string $sql, array $bind_parameters );


listGetByCode Function
PHP
mixed $this->listGetByCode ( string $list_type, mixed $list_code );


listFindValue Function
PHP
string $this->listGetByCode ( int $recid );


listFindCode Function
PHP
string $this->listGetByCode ( int $recid );

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

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.

setError Function
PHP
$this->setError ( string $message );

setWarning

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.

setWarning Function
PHP
$this->setWarning ( string $message );

Triggering Events

PCR_Event, trigger, attach, attachDb

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
PHP
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",
]);


Schedule tab

Add New Schedule Event form example

Add New Schedule Event form example

Debug tab

Debug Tab Example

Debug Tab Example

The Debug tab shows the results of debug function calls. This debug information is cleared after 24 hours.

Example

This example shows a Custom Event that invoking the call function: How can regular maintenance be scheduled for Equipment?

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.