SharePoint 2010: SPUtility.GetFullUrl(properties.Site, properties.ListUrl) in Custom Workflow and Alternate Access Mappings
While testing a custom SharePoint workflow that automatically sends out emails I stumbled over a small issue that bugged me and our customer a lot.
The email sends out some text with an url link to a list item. The problem was that the external url to the server was used only at the beginning of the workflow and later when the workflow continued through some internal trigger the internal server host name was used.
E.g.:
External Url: http://ext.alegri.eu
Internal Url: http://stgalegri
I found out the in the alternate access mapping settings the default url was the internal url.
I changed the settings to the following:
When the workflow is started and the following code is used:
SPUtility.GetFullUrl(properties.Site, properties.ListUrl)
The Site.HostName property will be instanciated with the context of the calling user that open the web site via the external url. This causes the email text with the hyperlink to be send out with the correct external address.
Later through some other modifications on the workflow via onchange event in the workflow another email will be sent out. As this event is triggered by the system itself and not by a user the Site.HostName property will be instantiated with the default zone url/address.
So I had to make sure the correct Default Zone Url was configured to be used as internal and external address.
Comments
Post a Comment