Add link to Issue record in Business Rule Message on Remediation Task table

RandiReyna
Tera Contributor

When a Closed state is selected (Closed Complete, Closed Incomplete, Closed Cancelled) and record is saved or updated then a message will appear stating "You have closed your Remediation Task. You may also wish to close the associated Issue <link>."

Screenshot 2024-05-31 at 4.01.04 PM.png

 how do I add a link to the associated issue records on the business rule message that is on the remediation task table?

4 REPLIES 4

James Chun
Kilo Patron

Hi @RandiReyna,

 

You can add a hyperlink with a URL like below:

JamesChun_0-1717196540844.png

 

/sn_grc_issue.do?sys_id=${current.issue.sys_id}

 

Cheers

Hi @James Chun ,

I added the link but it creates a new record instead of going to issue record thats for the remediation task.

Hi @RandiReyna,

 

How are the Remediation Task and Issue records related?

I thought they were related via the Issue field on the Remediation Task record.

 

Vaishnavi Lathk
Mega Sage
Mega Sage

Hello,

 

 Navigate to Business Rules:

  • Go to System Definition > Business Rules.
  1. Create a New Business Rule:

    • Click New to create a new business rule.
  2. Configure the Business Rule:

    • Name: Notify on Closed Remediation Task
    • Table: Remediation Task
    • When: after
    • Insert: true
    • Update: true
  3. Add Conditions and Script:

    In the Advanced tab, check the Advanced checkbox to enable scripting. Then, add the following script:

     

     
    (function executeRule(current, previous /*null when async*/) {
        // Define the closed states
        var closedStates = ['Closed Complete', 'Closed Incomplete', 'Closed Cancelled'];
    
        // Check if the state is changed to one of the closed states
        if (closedStates.indexOf(current.state) !== -1 && current.state !== previous.state) {
            // Get the associated Issue record (assuming it is linked via a reference field 'issue')
            var issueSysId = current.issue;
            if (issueSysId) {
                // Generate the link to the Issue record
                var issueLink = '<a href="/issue.do?sys_id=' + issueSysId + '">Issue</a>';
                
                // Set the message
                gs.addInfoMessage('You have closed your Remediation Task. You may also wish to close the associated ' + issueLink + '.');
            } else {
                // If no issue is associated, just show the message without the link
                gs.addInfoMessage('You have closed your Remediation Task.');
            }
        }
    })(current, previous);​
  4. Save the Business Rule:

    • Click Submit to save the business rule.

This script checks if the state of the Remediation Task has changed to one of the closed states. If it has, it retrieves the associated Issue record (assuming it is stored in a reference field named issue), generates a link to that Issue, and displays a message with the link.

 

Regards,

Vaishnavi Lathkar