Home Analyst Portal

convert string property to clickable hyperlink

Mark_BlokMark_Blok Partner IT Monkey ✭

In our problem management proces we are used to many attachements, some with large sizes and multiple versions. So we decided to put all the attachements in a document management system instead. We added an additional string property with name "Attachment Link" to the problem class and this prop is filled with the URL to the attachements location in the DMS.

We show this new property on the problem records form in the portal. But this is displayed as a string and therefor not clickable. Does anybody know a different datatype than string that creates a clickable link or do we need custom JS code to make this work?

Best Answer

Answers

  • Justin_WorkmanJustin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭
    This will require custom js.  I'd probably leave the new property control in the problem form as a placeholder and just hide it and append the link using the text from that control.  Does that make sense?  I can throw something together if that would help...
  • Matt_MedleyMatt_Medley Member Advanced IT Monkey ✭✭✭
    Mark_Blok said:

    In our problem management proces we are used to many attachements, some with large sizes and multiple versions. So we decided to put all the attachements in a document management system instead. We added an additional string property with name "Attachment Link" to the problem class and this prop is filled with the URL to the attachements location in the DMS.

    We show this new property on the problem records form in the portal. But this is displayed as a string and therefor not clickable. Does anybody know a different datatype than string that creates a clickable link or do we need custom JS code to make this work?

    Hey Mark, did you put the URL in HTML format? <a href="http://URL>Attachments - You may have to end it with a </a>
  • Mark_BlokMark_Blok Partner IT Monkey ✭
    edited November 2018
    Mark_Blok said:

    In our problem management proces we are used to many attachements, some with large sizes and multiple versions. So we decided to put all the attachements in a document management system instead. We added an additional string property with name "Attachment Link" to the problem class and this prop is filled with the URL to the attachements location in the DMS.

    We show this new property on the problem records form in the portal. But this is displayed as a string and therefor not clickable. Does anybody know a different datatype than string that creates a clickable link or do we need custom JS code to make this work?

    Hey Mark, did you put the URL in HTML format? <a href="http://URL>Attachments - You may have to end it with a </a>

    Matt_Medley, I tried it with <a href="http://www.google.com">Google</a> but the problem form will litteraly show the HTML code without translating it to a clickable link.. Would have been nice if this worked.
  • Matt_MedleyMatt_Medley Member Advanced IT Monkey ✭✭✭
    Mark_Blok said:
    Matt_Medley, I tried it with <a href="http://www.google.com">Google</a> but the problem form will litteraly show the HTML code without translating it to a clickable link.. Would have been nice if this worked.
    Was hoping that'd be a simple solution. Justin mentioned above that you'll probably have to use a custom JS solution. 
  • Mark_BlokMark_Blok Partner IT Monkey ✭
    This will require custom js.  I'd probably leave the new property control in the problem form as a placeholder and just hide it and append the link using the text from that control.  Does that make sense?  I can throw something together if that would help...

    That makes sense, if you can provide a bit of sample code it would help me alot, thanks.
  • Justin_WorkmanJustin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭
    This should work provided that the property Name is AttachmentLink.

    app.custom.formTasks.add('Incident', null, function (formObj, viewModel) { 
    	formObj.boundReady(function(){
    		var ac = $('[name="AttachmentLink"]');
    		ac.hide();
    		ac.parent().append("&lt;a href='" + pageForm.viewModel.AttachmentLink + "' target='_blank'&gt;Attachment Link&lt;/a&gt;");
    	});
    	
    		
    });

  • Mark_BlokMark_Blok Partner IT Monkey ✭
    This should work provided that the property Name is AttachmentLink.

    app.custom.formTasks.add('Incident', null, function (formObj, viewModel) { 
    	formObj.boundReady(function(){
    		var ac = $('[name="AttachmentLink"]');
    		ac.hide();
    		ac.parent().append("&lt;a href='" + pageForm.viewModel.AttachmentLink + "' target='_blank'&gt;Attachment Link&lt;/a&gt;");
    	});
    	
    		
    });


    I tried this example and it sets the href to http://Portal/Problem/Edit/PR380693/<a href="http://www.google.com">Google</a>. In other words it appends the link to the base URL of the workitem. Do you know a way of replacing the href instead of append?
  • Justin_WorkmanJustin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭
    That's strange.  It didn't do that in my lab.  If you type pageForm.viewModel.AttachmentLink in the Dev tools console what is the result?
  • Mark_BlokMark_Blok Partner IT Monkey ✭
    That's strange.  It didn't do that in my lab.  If you type pageForm.viewModel.AttachmentLink in the Dev tools console what is the result?

    "<a href="http://www.google.com">Google</a> "
Sign In or Register to comment.