1

I am creating a workflow using SP Designer. I'm not at Visual Studio level. An email gets sent out when a new doc is added to a library with many different folders and levels.

It's easy to link the document url in the email using EncodeAbsoluteUrl property of the item so that they can open it from the link, but,

How do I give them a link to the containing folder in case they don't want to actually launch the doc, they just want to see where it went?

Again there are many folders and levels of folders in this library, so I can't just link the library url itself and dump them off there.

This has proven to be a little tricky for me and if anyone has had to do this before and pulled it off in SP Designer, any advice would be greatly appreciated. Thanks.

0

First of all I would make sure this functionality is actually needed... you might be over-engineering when the users don't actually need it (it is a good idea though, my point is just don't make something overly complex if it's not required by the users, who as we all know often have much simpler expectations than IT pros).

For the actual code, you need to do the below bit of messy string work:

enter image description here

  1. First we replace the %20 occurrences with spaces, because otherwise we won't get a match between the Name value and Encoded URL (because the former doesn't include encoded spaces, but the latter does)

  2. Next we find the index position of Name within our un-encoded URL value

  3. Finally we get the number of characters from the start of the string equal to the index position (or you could extract it from the Encoded URL if you need the URL encoded in the email, but it shouldn't matter as if you access an SP URL with spaces in it auto-encodes them anyway)

Hope that helps, I've tested it and it brings back the expected data.

  • over engineering comment well received and I totally agree, but they asked for it. I was thinking along the same lines of what you are suggesting, but it seems like even if I get filename and concatenate with file type (ext) and use that in a string replace operation it seems as though there is a version number in the url as well when using encodedAbsoluteURL – Bobh Jul 13 '17 at 13:49
  • if I could just find a way to get to first / when going from end to front, I would be all set, but I can't see how to do that in SP Designer's string operations – Bobh Jul 13 '17 at 13:53
  • I'm working on a solution at the moment, think I've cracked it with some sneaky string replace ops... will post a screenshot shortly. – Thomas Gass Jul 13 '17 at 13:53
  • Answer updated, you should be good to go now. – Thomas Gass Jul 13 '17 at 14:02
  • looks like it will work, let me try it. thx – Bobh Jul 13 '17 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.