Skip to content

Commit 5377b50

Browse files
authored
Add custom 404 page suggestion script
This script retrieves the first three characters of the page_id from the URL and suggests valid related pages based on that.
1 parent 5aacdf6 commit 5377b50

File tree

1 file changed

+20
-0
lines changed
  • Modern Development/Service Portal Widgets/custom404

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
(function() {
2+
/*
3+
This script will get the 3 characters of page_id from url and suggest valid pages.
4+
*/
5+
data.pageArr = []; // array to store related pages
6+
var pageId = $sp.getParameter('id').toString(); // get page id from url
7+
// get 3 letters of page id
8+
if (pageId && pageId.length() > 3)
9+
pageId = pageId.substring(0, 3);
10+
11+
var relatedPages = new GlideRecord('sp_page');
12+
relatedPages.addEncodedQuery('idLIKE' + pageId);
13+
relatedPages.query();
14+
while (relatedPages.next()) {
15+
var tempList = {}; // temporary object.
16+
tempList.name = relatedPages.getValue('title');
17+
tempList.url = '/' + $sp.getValue('url_suffix') + '?id=' + relatedPages.getValue('id');
18+
data.pageArr.push(tempList); // add related suggested pages to array
19+
}
20+
})();

0 commit comments

Comments
 (0)