Cross domain issues with Office Online server 2016

Recently while provisioning a huge SharePoint 2016 farm (around 70 server) on MS-Azure with 3 Office Online servers, I came across some cross domain issues with Office Online.

We had provisioned all the four environments (development, test, pre-prod and production) on Azure but on two different domains and here come the real complexity 🙂

Environment Domain URL
Development PPAD http://sharepointsite-dev
Test PPAD http://sharepointsite-test
Pre-Production AD http://sharepointsite-preprod
Production AD http://sharepointsite

The users who would be accessing the site were using laptops which were on the AD domain; for example, AD\anandsharma being their account ID.

Accessing the development and test URL’s with such devices required appending the domain name after the SharePoint site url to resolve the DNS. For example: http://sharepointsite-dev.ppad

Now while setting up Office Online servers in such cases has a big caveat!!

So let’s say my Office Online server’s load balancer (as in our case) has the internal URL as http://sharepointsite-dev-oos and everything is configured according the the following technet article –

In such a scenario, the cross domain dns resolving will not work.

Hence while configuring the Office online server, you must append the domain name to the internal url property when configuring the new farm.

Configuration on the Office Online Server (Development)

Import-Module -Name OfficeWebApps
New-OfficeWebAppsFarm -InternalURL "http://sharepointsite-dev-oos.ppad" -AllowHttp -EditingEnabled
Set-OfficeWebAppsFarm -AllowHttpSecureStoreConnections:$true

Configuration on the SharePoint Web Front End (Development)

Add-PSSnapin Microsoft.SharePoint.Powershell
New-SPWOPIBinding -ServerName "sharepointsite-dev-oos.ppad" -AllowHTTP
Set-SPWOPIZone -zone "internal-http"
$config = (Get-SPSecurityTokenServiceConfig)
$config.AllowOAuthOverHttp = $true
$Farm = Get-SPFarm
$Farm.Properties.Add("WopiLegacySoapSupport", "http://sharepointsite-dev-oos.ppad/x/_vti_bin/ExcelServiceInternal.asmx");

Hope this helps anyone struggling with cross domain configurations.

Override redirect using EditItemWithCheckoutAlert

On an edit item link, you want to perform some operation and redirect to a page of your choice, write a small script on your page and override the EditItemWithCheckoutAlert function.
So when you click on the edit link, the EditForm.aspx opens.

This allows you to modify the fields and delete the list item. Once you perform your desired action, the dialog box is closed and you are redirected to previous view/default view. To override this, use the script below, modify it to suit your URL and put it in a CEWP/Script Editor WP on your page.

if (typeof(EditItemWithCheckoutAlert) != 'undefined')
var changed_EditItemWithCheckoutAlert = EditItemWithCheckoutAlert;
EditItemWithCheckoutAlert = function(evt, Url, bCheckout, bIsCheckedOutToLocal, strDocument, strhttpRoot, strCurrentUser, strCheckoutUser) {
changed_EditItemWithCheckoutAlert(evt, Url+'&Source=yourURL', bCheckout, bIsCheckedOutToLocal, strDocument, strhttpRoot, strCurrentUser, strCheckoutUser);