On incident form, when a user post a work note or comment containing url's, the url's should be clickable from the activity section.

Community Alums
Not applicable

Im Working on a task on incident form. The goal is, When a customer post a work note or comment containing url’s, the url’s should be clickable from the activity section.  I succeeded in writing an onsubmit client script that adds href to the urls. The problem is, this script only get triggered when the user clicks submit UI button. The script is not triggered When you click on “Post” UI button.

2 REPLIES 2

Gabor10
Mega Guru

Could you please post your script so that we are more aware what have you implemented so far?

You'll most likely have to move your logic from Client to Server side and utilize a Business Rule to achieve your requirement.

Table: Incident

When: Before

Update: Checked

Condition: Work Notes changes

Script:

* your logic *

 

Community Alums
Not applicable

The objective is, when a a user adds url to worknotes or comment field then a clickable hyperlink will be added to the url. I managed to use a business rule to add hyperlink to url's. However, the problem is, when a user post a worknote or comment, its been shown twice on the activity section. One activity is added a hyperlink and there other is returned as a plain text. 

here is my code: 

(function executeRule(current, previous /*null when async*/ ) {

    try {
        //looping through comment field and adding href to url 
        var user_comment = current.comments;

        if (user_comment != '') {
            current.comments = findUrl(user_comment);

        }

        //looping through work_notes field and adding href to url 
        var user_work_notes = current.work_notes;

        if (user_work_notes != '') {
            current.work_notes = findUrl(user_work_notes);
        }

    } catch (err) {
        gs.addErrorMessage("A runtime error occurred:" + err.message);
    }


    //This function adds link to the url.
    function findUrl(text) {
        var urlReg = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=|!:,.;]*[-A-Z0-9+&@#\/%=|])/ig;
        return text.replace(urlReg, function(url) {
            return '[code]<p><a class="web" target="_blank" href="' + url + '">' + url + '</a></p>[/code]';
        });
    }

})(current, previous);