Please rate how useful you found this document: 
Average: 2.3 (3 votes)

Case Notes Functions

PMFAddCaseNote()

PMFAddCaseNote() adds a case note to a specified case.

Note: To use this function in the process, you must assign the correct Case Notes Process Permissions. Otherwise the function does not add the desired case note.

int PMFAddCaseNote(string $caseUID, string $processUID, string $taskUID, string $userUID, string $note, int $sendMail = 1)

Parameters:

  • string caseUID: (Required) The unique ID of the case, which can be found in the following ways:
  • string processUID: (Required) The unique ID of the process, which can be found in the following ways:
    • For the current process, use the @@PROCESS system variable.
    • Use executeQuery() to look up the unique ID in the wf_<WORKSPACE>.PROCESS.PRO_UID field.
  • string taskUID: (Required) The unique ID of the task, which can be found in the following ways:
    • Use the @@TASK system variable to get the unique ID of the current task.
    • Use the PMFTaskList() function or taskList() web service.
    • Query the wf_<WORKSPACE>.TASK.TAS_UID field in the database or get the starting task of the current process with the following query:
executeQuery("SELECT TAS_UID FROM TASK WHERE PRO_UID='" . @@PROCESS . "' AND TAS_START='TRUE'");
  • $userUID: (Required) The unique ID of the user who will add the case note. Note that it is NOT possible to include the UID of more than one user.
  • $note: (Required) Note of the case.
  • $sendMail: (Optional) If set to 1, will send an email to all participants in the case.
  • Return Value:
    Returns 1 if the note has been successfully added to the case, otherwise returns 0 if an error has occurred.

    Example:

    @@return = PMFAddCaseNote(@@APPLICATION, @@PROCESS, @@TASK, @@USER_LOGGED, 'Completed with resolution #234',1);

    Note: It is possible to use case or system variables in the text of the case note. The following example inserts the resolution number, which is a value from a Dynaform field, into the text of the case note:

    @@return = PMFAddCaseNote(@@APPLICATION, @@PROCESS, @@TASK, @@USER_LOGGED, 'Completed with resolution #' . @@NumberResolution, 1);

    PMFGetCaseNotes()

    PMFGetCaseNotes() returns a list of the case notes posted to a specified case.

    array PMFGetCaseNotes(string applicationUID, string type = 'array', string userUID = '')

    Parameters:

    • string applicationUID: The unique ID of a case, which can be obtained in the following ways:
      • For the current case, use the system variable @@APPLICATION.
      • Use PMFCaseList(), WSCaseList() or the caseList() web service.
      • Use executeQuery() to query the wf_<WORKSPACE>.APPLICATION.APP_UID or wf_<WORKSPACE>.APP_DELEGATION.APP_UID fields in the database
    • string type: Optional parameter. Set to 'array' if the result will be displayed in a grid. Set to 'string' to return a string, which can be displayed in a textarea field. The default value is 'array'.
    • string userUID: Optional parameter. To return the case notes posted by a single user, set to the unique ID of that user. If no user ID is specified, then it will return the case notes from all users. For the currently logged-in user, use the @@USER_LOGGED system variable.

      Note: It's not possible to define more than one user ID in the last parameter.

    Return Value:
    If the type is set to 'array', then this function returns an array of associative arrays with the following structure:

    [1] array ( string ['FULL_NAME']: First name and last name of the user who created the case note. string ['APP_UID']: Case UID. string ['USR_UID']: User UID. string ['NOTE_DATE']: The datetime when the case note was created in YYYY-MM-DD HH:MM:SS format. string ['NOTE_CONTENT']: The content of the case note. string ['NOTE_TYPE']: The type of the case note. string ['NOTE_AVAILABILITY']: The type of availability of the case note. string ['NOTE_RECIPIENTS']: The users who got the note by notification. string ['USR_USERNAME']: The username of the user who created the case note. ) ...

    Note that the counting of the array starts from 1, not 0.

    If the $type is set to 'string', then this function returns a string that includes the name and username of the user who posted the case note, the content of the case note, and the date-time when posted:

    FIRST-NAME LAST-NAME (USERNAME) NOTE-1-CONTENT (DATE-TIME-POSTED) FIRST-NAME LAST-NAME (USERNAME) NOTE-2-CONTENT (DATE-TIME-POSTED) ...
    Note: The text in NOTE_CONTENT is in HTML format so a string like "¡güéro!" becomes "&iexcl;g&uuml;&eacute;ro!". This text can be displayed without problem inside a panel, but to display this text correctly inside an input field, use the html_entities_decode() function to convert it to the UTF-8 character set. See the examples below.

    Showing Case Notes in a Grid

    Create a Dynaform and inside it add a grid. When dropping the Grid element, create a new variable named gridPMFunction that is associated to the grid.

    Add the following controls inside the grid:

    Save the changes and close the Dynaform. Then, create the following custom trigger:

    @=gridPMFunction = PMFGetCaseNotes(@@APPLICATION, 'array', '');

    for ($i = 1; $i <= count(@=gridPMFunction); $i++) {
       @=gridPMFunction[$i]['NOTE_CONTENT'] = html_entity_decode(@=gridPMFunction[$i]['NOTE_CONTENT'],
           ENT_QUOTES, 'UTF-8');
    }

    In this example, the case notes from all users in the current case are returned in an array which is assigned to the @=gridPMFunction variable which is associated with a grid in the subsequent Dynaform. Note that the last parameter of the PMFGetCaseNotes() function is an empty string, so it will return the case notes created by all users.

    Then, the code loops through each element in the @=gridPMFunction array and calls html_entity_decode() to converts the text in the ['NOTE_CONTENT'] elements from HTML to UTF-8 text.

    Assign the above trigger to be executed before the Dynaform and the results will be shown in the grid:

    In this example, the trigger was executed in the process's second task, so all case notes added in both the first and second tasks will be displayed in the grid.

    Showing Case Notes in a Textbox

    Create a Dynaform that has a Textarea control with a variable called textAreaPMFunction.

    Then create a trigger as follows:

    @@textAreaPMFunction = html_entity_decode( PMFGetCaseNotes(@@APPLICATION, 'string', ''),  ENT_QUOTES, 'UTF-8');

    Where:

    P
    • @@textAreaPMFunction : name of the textarea added to the Dynaform and where the results will be shown.
    • @@APPLICATION: UID of the current process.
    • string: the results. In the example, the results will be shown in a textarea.

    The last parameter is empty, so it will display all the case notes created by the users.

    Assign the trigger before the Dynaform. The result will be: