Versions Compared

Key

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

...

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

Calling Custom Events

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

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

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

  3. If the location does not exist, it will be created

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

  5. The file_put_contents result will be returned