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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2022 03:11 AM
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.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2022 12:10 AM
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 *

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2022 01:29 AM
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);