2

I am building a workflow inside SharePoint designer 2013. And inside the workflow I define to send an email and the email will contain the current item url, as follow:-

enter image description here

Currently the item url inside the email will be using the actual server name as follow "http://sharepointserver001/...", but I need to a way to show the alternative access mapping url, which is a more user friendly "www.ourcompanyname.intra/....". Now inside the central admin I define an alternative access mapping as follow:-

enter image description here

So can anyone advice if I can do any of the following for the “current item url”:-

  • To force the current item url to use the alternative access mapping url, instead of the actual servername ?
  • Explicitly replace the servername with the alternative access mapping url, by doing a String.Replace inside the workflow designer ?

now i tried defining the following inside the String builder,,to use String Replace :- enter image description here

but when i save the value , the workflow designer truncate the values i entered after the .Replace (, as follow:-

enter image description here

  • can anyone advice on this please? – john Gu May 25 '16 at 14:54
  • 1
    So this is a SharePoint 2010 workflow being built in SharePoint 2013, correct? – Submits May 27 '16 at 15:55
  • @Submits yes i am working on sharepoint enterprise server 2013. and i am using sharepoint designer 2013, and inside the sharepoint designer 2013 , i am using workflow 2010... – john Gu May 27 '16 at 16:05
1

How about creating a workflow variable and store the value of %Workflow_Context:Current Item URL% and then create another variable and set it to equal your replace function and use the later variable in the Address?

  • i already know about this workaround ,,, but my question is if i can force the workflow to use the alternative access mapping url directly, without having to use workflow variables and replace . – john Gu May 31 '16 at 11:49
10
+50

SharePoint uses the default URL for links in alerts and workflows that are automatically kicked off.

The workflow system doesn't have any way of knowing which alternate access mapping any given user would use when logging into SharePoint, so it just builds the link using the Default zone since it has no other info to go on. Without diving into fully customized workflows,

Our best bet will be to swap the URLs in the zone boxes, so that the default zone contains the URL http://www.ourcompanyname.intra (using your example).

  • so can you explain exactly what di you mean by "your best bet will be to swap the URLs in the zone boxes, so that the default zone contains the URL "ourcompanyname.intra" (using your example)."?? – john Gu May 31 '16 at 11:50
  • Swap means you need to put the "ourcompanyname.intra" in the default zone under alternate access mapping & move default URL (sharepointserver001) to internet zone. So after doing it when you try to get current item URL, you will get default zone value in workflow. – Hardik May 31 '16 at 12:06
  • Is my answer helps you to get it resolved? – Hardik Jun 1 '16 at 12:31
  • Hello John ... Did you get it working or not? – Hardik Jun 15 '16 at 9:12
0

Could you not just create the link in the formula builder using the current item ID rather than the item url:

http://www.ourcompanyname.intra/Lists/YOURLIST/DisplayForm.aspx?ID=[Add current item id here]
  • this will not work,, as the workflow is defined on the content type level.. so "YourList" value in your example will not be the same for all the lists which use the content type ..so i canot not hard code the url ,the way you mentioned – john Gu May 31 '16 at 11:48
  • I don't quite understand what you mean by "content type level", apologies. Surely there would be a way to modify the query to then build the string in a similar way using filter values? If you forget about the 'yourlist' element and think about the form of the url's you need... is this possible? Just a suggestion. – GrantMcW Jun 1 '16 at 1:51
-1

You should be able to achieve this with a calculated column and an additional activity in your workflow.

What we're going to do is create a calculated column in your document library, which is where the replace will take place. Calculated columns can't reference a file's URL, so we'll have to first set the value of the Title field and use this field in the calculated column. Then you can simply take the value of the calculated column in your workflow and send your email.

Step 1 - Set Title column

  • In your workflow add an activity that updates the item in your document library. You want to set the value of the Title field to the value of Workflow Context: Current Item URL (the same as you've shown in your question).

Step 2 - Create calculated column

  • Create a calculated column in your document library, call it anything, e.g. CalcDocURL.
  • The formula of the calculated column should be a REPLACE function. What you're doing in this formula is taking the value of the (newly updated) Title field and replacing the host name to what you want. You can find out more about this function here. Your formula might look something like =REPLACE([Title],FIND("sharepointserver001",[Title]),19,"www.ourcompanyname.intra")

Step 3 - Get the new value

  • The CalcDocURL column now contains the correct URL, so read the value of it with another activity in your workflow
  • You can now send your email with the updated URL
  • but if i follow your approach, then my list items will have their titles = the item url ... that should a bit strange ... – john Gu May 31 '16 at 11:53
  • Are you even using the Title field in your document library? People often don't use it. But if you are, just create another field, call it Title2, and don't show it in your views. Then just assign the value of Workflow Context: Current Item URL to Title2 in Step 1. – Submits May 31 '16 at 12:46
  • this is this first time i hear that people do not use "Tile". now i have Issue tracking lists , not document libraries. but even inside document libraries Title still provide a business value and it have different use compared to name.. in all ways my question was if i can force the workflow to use the access mapping url... and if i want to implement a workaround, then i will follow the steps mentioned in Ahmad Mahmoud reply as it is easier to implement... so still my question is how i can force workflow 2010 to use alternative access mapping urls – john Gu May 31 '16 at 13:14
  • You asked two questions in your original question. The answer to the first is no - you cannot force the workflow to use the access mapping URL - unless you use the workaround provided by Hardik, but this would be out of the question for many people. The answer to the second is yes there is a workaround, but doing a Replace is not it. You cannot use Replace function in your SharePoint 2010 platform workflow. The only workaround that I can think of that will work and that doesn't involve writing code is what I suggested. – Submits May 31 '16 at 14:20

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.