Service Portal Form Widget Clickable Link

Elyse Eckert1
Giga Contributor

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.

28 REPLIES 28

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. 

find_real_file.png

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

find_real_file.png

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... 

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? 

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()
  }
...

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;
	}
	
	
}

 

find_real_file.png

Thank you for your patience with a noob of a beginner in the portal. 

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.