How to extract url using Business Rule?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2023 11:48 AM
Hello,
I have the following URL in the the RITM description field. How can copy this link to the work note as a clickable link?
This TEST LINK<https://gcc02.safelinks.protection.outlook.com/?url=https%3Add%2F%2Fmwdsocal.sharepoint.com%2Fsites%...> is Approved.
I have tried before insert Business Rule script. However, I screwed up somewhere in the code that make it did not work. Can someone please help. Thank you
var description = '' + current.description;
var myLink = description.match(/(?:http[s]*\:\/\/)*(.*?)\.(?=[^\/]*\..{2,5})/i);
current.work_notes = '[code]<a href=' + myLink + ' target="_blank">My Link</a>[/code]';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2023 12:06 PM - edited 02-09-2023 12:08 PM
Hello @Annie10
try this line
current.work_notes = [code]'<a href='+current.description.toString() + ' target="_blank">My Link</a>'[/code];
Hope this helps
Mark my answer correct if this helps you
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2023 02:00 PM
Hi Mohith,
Thank you for your suggestion. Your code copied the entire text in the description field over to the work note. I would it to search for the URL in the description field an copy only the URL over the work note.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2024 12:00 PM
Hi There Annie10, Did you ever find a solution to this? Im trying to do the exact same thing. I think Mohith was close but needed an inner statement on the current.description.toString() to perform the match
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2024 01:23 PM
I tried below code ->
var text = 'follow this reply https://google.com/ It should help you';
var urlRegex = /(\b(((https?|ftp|file):\/\/)|(ww+))[\-A-Z0-9+&@#\/%?=~_|!:,.;]*[\-A-Z0-9+&@#\/%=~_|])/ig;
var match = text.match(urlRegex);
if (match) {
gs.print(match[0]);
}
Result printed - https://google.com/
Hope it helps.
If it helps you, kindly mark this as Accepted Solution/Helpful and help in closing this thread.
Best Regards,
Shubham