Service Portal Form Widget Clickable Link
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2017 10:15 AM
Hello,
I am completely baffled on how to make a URL clickable on the Form Widget in the Portal. Our client has a requirement to include multiple clickable URLs on their back-end form, which they also need available on the Portal. This is obviously no problem in the console, but nothing I've tried for Portal has worked.
I've tried read-only HTML fields, which do not work in Portal. It ignores the read-only parameter on the dictionary, client scripts, UI Policies and even outright ACL restrictions. The field is always writable. I've tried HTML Annotations, though I know Annotations do not work in Portal. I've tried URL fields, but those also do not work in Portal. I've tried [code][/code] snippets in Journal fields, etc. Nothing works. I cannot make a URL clickable on the Form Widget.
Am I missing something? Should this functionality be so incredibly difficult to implement? Any help would be greatly appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2018 09:27 PM
ok so I got jack of having the Song Links name for the form, so I cheated and made my form the same name as yours Chris.
When I look at what is happening I can see the objects for the 4 fields that are on the links form. They have data in them. So the server script is definitely collecting all the data as you said it would.
So I do not understand why the client controller is not picking up the data and putting it in the widget.
I get a syntax error below
stating: SyntaxError: Unexpected token
Before it even gets to the controller.
Chris I am so sorry for this, I should have had this running by now...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2018 03:22 AM
I believe there is something wrong with the client controller; like an extra character or something. Could you paste all of the client controller script in here or a good screenshot of the full client controller?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2018 03:32 AM
Yep, I think I found it. And it's my fault. I'm not sure how, but when I copied and pasted my script from my controller an extra closing parenthesis ")" is placed in there.
So, in the client controller after the c.server.update(), the following line has the closing of the else statement which is fine but after the curly brace is an extra closing parenthesis. ")"
...
c.server.update()
})
...
It should be
...
c.server.update()
}
...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2018 04:54 PM
Thanks Chris,
Guess what, I took out the ) and it still didn't work....
I stuffed around for ages and well it drove me nuts, but thanks to your explanation I worked it out. There was an extra } in there too after the ) on the line below.
This now works.
function($rootScope, $scope) {
var c = this;
//setup a variable to hold the url field data
$scope.links = {}
//bring the url field data to the client side
c.urlLinks = c.data.formFields;
//add a lock/unlock state dependent upon the value
angular.forEach(c.urlLinks,function setLinks(item){
if(item.value){
item.lock = true;
}
else{
item.lock = false;
}
$scope.links[item.name] = item.value;
})
// function to set lock/unlock state and update link values
$scope.setLink = function(formfield){
if(!formfield.lock && !$scope.links[formfield.name])
return;
if(formfield.value == $scope.links[formfield.name])
formfield.value = $scope.links[formfield.name];
else{
formfield.value = $scope.links[formfield.name];
c.server.update()
}
formfield.lock = !formfield.lock;
}
}
Thank you for your patience with a noob of a beginner in the portal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2018 06:10 PM
Hi Chris,
This works really well.
Is there a way to code the
target=" _blank"
in the html of this widget so the links actually open in a new window, I cannot see where I can add it. The ability to do it at the dictionary level has been taken away so I can't push the link to open in a new window.
I asked this q here also:
https://community.servicenow.com/community?id=community_question&sys_id=c3990fdbdb89a300a39a0b55ca96191f
There is not an OOTB way to do this obviously, but I thought it would be possible to append or insert the target somewhere in the widget?
I could be way off base here.