- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2017 03:23 AM
Hi SNC,
I have a requirement where I want to add additional widgets to the Form page (id=form) but, they should only be present if I am accessing this Form page through my XXXXX Portal, since this is a page used in many other Portals.
Any ideas on how to set a restriction like this for the additional widgets to be exhibited only on the XXXX Portal?
Thanks in advance.
Fábio Gonçalves
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2017 04:29 AM
Yup. Thanks!
& Just to let you know that in the above suggestion we used validation in client side only.
In Order to validate in server side + client side + HTML - you can use below example :
Server script:
(function() {
data.portal_visible = false;
var portalGr = $sp.getPortalRecord();
if(portalGr.url_suffix == 'sp') {
data.portal_visible = true;
}
})();
Please let me know if you are looking for anything else.
If your query is Resolved, would you mind marking my answer as correct and close the thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2017 03:38 AM
Hi Fabio,
you can try below.
In clientb controller check the URL of portal and place it in a variable
var url = $location.url();
url = url.toString().split('?');
$scope.portalC = url[0];
And now in widget script you can put ng-if="portalC == '/original'"
<div ng-if="portalC != '/sp'">
<!--- widget script inside div -->
</div>
Regards
Swamy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2017 03:55 AM
Hi AMARADI,
Thanks for you help.
Are you sure the split should be done by the '?'? Because the url of the portal is something like "https://xxxxxxxx.service-now.com/xxxx?id=form. Shouldn't the split to validate the Portal be made by the 'xxxxxxxx.service-now.com/' instead? Since what follows "xxxxxxxx.service-now.com/" is in fact the Portal id; on the other hand, what comes after the '?' is the id of the page, not the id of the Portal.
Thanks,
Fábio Gonçalves
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2017 04:36 AM
$location.url() will give link after https://instnacename.service-now.com. so if my instance url is dev24013.service-now.com/sp?id=test_page
then it will give /sp?id=test_page.
For testing purpose, you can place the below code in client controller
alert($location.url());
var url = $location.url().toString().split('?');
alert(url[0]);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2017 04:47 AM
It is now fully working.
Thanks for all the help.
Best regards,
Fábio Gonçalves