- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2024 05:35 AM
We have multiple knowledge articles which contain embedded links to other knowledge articles. These links point to our custom service portal. Now that we are migrating to the Employee Center, is there a way to fix those embedded links within each article to point to the ESC portal? We can actually go into each of the KB articles and modify the embedded links in the source code. But that is too cumbersome as there are a lot of KB articles (including translated versions) which contain embedded links in them.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2024 05:08 AM
ServiceNow has set up Fix Scripts to be used as part of deploying scoped applications, so I suggest using a scheduled job (to run a script) and on that you would set it to run "on demand" so that you can run at when needed in each environment. I do not have a sample script, but you could look at using .replaceAll on the HTML field with the first parameter being the old url and the second being the new one. That should work, if not, you could look at doing a while loop on the field to do say until indexOf('old url') == -1, and then use substring from the position to the length of your old url and still use replace. So something like field.replace(field.substring(field.indexOf('old url'),20),'new url'); Hopefully that gives you enough to go on.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2024 05:54 AM
You could write an on demand scheduled script execution that iterates through the articles, determines if there are links in the article, parse the content to get the full url, update the details, and then replace that url with the new one. You're most likely looking at using regex to do the find/replace.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2024 05:39 AM
Hey @Kristen Ankeny ,
Thankyou for the response. So this will be a one-time Fix script that we need to run?
Do you have like a sample script for this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2024 05:08 AM
ServiceNow has set up Fix Scripts to be used as part of deploying scoped applications, so I suggest using a scheduled job (to run a script) and on that you would set it to run "on demand" so that you can run at when needed in each environment. I do not have a sample script, but you could look at using .replaceAll on the HTML field with the first parameter being the old url and the second being the new one. That should work, if not, you could look at doing a while loop on the field to do say until indexOf('old url') == -1, and then use substring from the position to the length of your old url and still use replace. So something like field.replace(field.substring(field.indexOf('old url'),20),'new url'); Hopefully that gives you enough to go on.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2024 09:25 AM
Thanks @Kristen Ankeny for pointing me in the right direction. I was able to write a script to replace the url in the html content of the embedded Knowledge articles to point to the ESC portal in our Sandbox environment. I will need to test it out in Dev and QA.