Return the link from Link to Item field

  • 24 February 2014
  • 2 replies
  • 5 views

Badge +3

Hi,


In a smartform I'm looking to see if there is a good way to return the link from the "Link to Item" field in a Sharepoint list.  I'm retrieving a document record, via a smartobject and would like to manipulate the "Link" returned in the "Link to Item" field.  Thought i was able to do this in Infopath but cant seem to figure out a way to rip it out using an expression. Any ideas? 


thanks.


2 replies

Userlevel 1
Badge +8

Hi Jason,

 

Can you give us a bit more detail about what you are trying to accomplish? I know that you can assign the link to Item to a hyperlink control in Smartforms, but that doesn't seem like what you are wanting to do.

 

You could create a new control (data label for example) that isn't bound to a field and then add an expression to that field to maniplulate the value. The expression would look something like this:

 

13476i1A8D686B91976C63.png

 

I do a mid because I want to find your URL. The starting position I cheat in this example because I know that the Link to Item K2 Service Defined starts with <hyperlink><link>. Beginning < to ending > is 17 characters and I would need to add one to start with the first character of your URL. You have to remember this is zero based, so I used 17 as starting the count from zero I would have had 16.

 

I then use a Find to locate the closing tag for your url </link>. I am assuming that the find is going to give me the starting index location of the </link> string. I subtract the length of the original 17 characters from the index returned by find to give me the total length of the URL I should return.

 

I did something similar to this in InfoPath using Substring-Before with a nested Substring-After to return just the URL.

 

This may be not be the best way to do this, so the more detail you can proivde around your use case we can come up with a more appropriate solution.

Badge +3

Thanks for the reply.  Once I got my head around the fact the URL is not formated as in the table (i.e. <hyperlink><link>....)  It is returned as an actual hyperlink (i.e.  <a href="...) I was able to use the following expression to extract the link to the file.  

 

Replace ( Replace ( Left ( Link to Item, Find ( Link to Item, > ) ) , <a href=", (Empty String) ) , ">, (Empty String) )

 

Gave me back a nice link to play with.

Reply