The CreatorCon Call for Content is officially open! Get started here.

Create Follow-Up when there are Additional Comments on Closed RITMs

Beth19
Tera Contributor

Hello,

I've been tasked with creating an incident ticket when a closed RITM receives an additional comment.

 

I created a flow to help satisfy this request as follows:

Trigger - Updated

Table - sc_request (sc_request_item was not available)

condition: additional comments changes

run trigger: once

 

Actions:

If state is closed complete

create incident (and specified all fields)

 

Is there a better way to accomplish this?

 

During testing my flow runs to create an incident even when a additional comments does not change.

 

Thank you for your time and review.

1 ACCEPTED SOLUTION

Rafael Batistot
Kilo Patron

Hi @Beth19 

May you try via Business Rule After > Updated

  1. Navigate to System Definition > Business Rules.
  2. Click New.
  3. Fill out the form:
    • Name: Create Incident for Closed RITM Comments
    • Table: sc_req_item
    • Advanced: Check this box.
  4. In the When to run tab, set the following options:
    • When: after
    • Update: Check this box.
    • Order: 100 (or a value that ensures it runs after other relevant business rules)
  5. In the Filter Conditions section, set the conditions to check for a closed RITM and an additional comment update:
    • State is Closed Complete (or your equivalent closed state)
    • Additional comments changes
  6. In the Advanced tab, paste the following script into the Script field: 
 
Code

    // Exit if the additional comments field has not been updated by a user
    if (current.comments.changes() && current.comments.toString() == previous.comments.toString()) {
        return;
    }
    
    // Create new incident
    var inc = new GlideRecord('incident');
    inc.initialize();
    
    // Set incident fields from RITM and new comment    inc.short_description = 'Follow-up comment on closed RITM: ' + current.number;
    inc.caller_id = current.requested_for;
    inc.description = 'A follow-up comment has been added to a closed Requested Item. \n\n' + current.comments.getJournalEntry( 1 ); // remove spaces
    inc.comments = 'Original RITM: ' + current.number;
    inc.parent = current.sys_id; // Link the incident to the RITM
    
    // Optional: map other fields as needed
    // inc.assignment_group = current.assignment_group;    
    inc.insert();
If you found this response helpful, please mark it as Helpful. If it fully answered your question, consider marking it as Correct. Doing so helps other users find accurate and useful information more easily.

View solution in original post

1 REPLY 1

Rafael Batistot
Kilo Patron

Hi @Beth19 

May you try via Business Rule After > Updated

  1. Navigate to System Definition > Business Rules.
  2. Click New.
  3. Fill out the form:
    • Name: Create Incident for Closed RITM Comments
    • Table: sc_req_item
    • Advanced: Check this box.
  4. In the When to run tab, set the following options:
    • When: after
    • Update: Check this box.
    • Order: 100 (or a value that ensures it runs after other relevant business rules)
  5. In the Filter Conditions section, set the conditions to check for a closed RITM and an additional comment update:
    • State is Closed Complete (or your equivalent closed state)
    • Additional comments changes
  6. In the Advanced tab, paste the following script into the Script field: 
 
Code

    // Exit if the additional comments field has not been updated by a user
    if (current.comments.changes() && current.comments.toString() == previous.comments.toString()) {
        return;
    }
    
    // Create new incident
    var inc = new GlideRecord('incident');
    inc.initialize();
    
    // Set incident fields from RITM and new comment    inc.short_description = 'Follow-up comment on closed RITM: ' + current.number;
    inc.caller_id = current.requested_for;
    inc.description = 'A follow-up comment has been added to a closed Requested Item. \n\n' + current.comments.getJournalEntry( 1 ); // remove spaces
    inc.comments = 'Original RITM: ' + current.number;
    inc.parent = current.sys_id; // Link the incident to the RITM
    
    // Optional: map other fields as needed
    // inc.assignment_group = current.assignment_group;    
    inc.insert();
If you found this response helpful, please mark it as Helpful. If it fully answered your question, consider marking it as Correct. Doing so helps other users find accurate and useful information more easily.