Friday, March 2, 2018

Javascript Customization in IBM Connections to automatically tick off the checkbox "Files can be shared with people external to my organization".

I finally figured it out!!!! OMG, so very happy.

My customers will be happy as well, and that´s the whole point of doing this, right?

Well, previously I have posted a blog entry about the fact that when uploading files into IBM Connections, the users has to manually tick off the checkbox "Files can be shared with people external to my organization". In that previous blog post, I presented a solution where you had to run a change in the Files SQL database.

I also created a PMR on this where the response was that, yes, this is automatically ticked off in the IBM Connections Cloud, but not on on-prem installations. And there was no way of changing this....  IBM Support then said that doing the SQL change is an ok way of doing it, on my own risk....

If the users forget to tick that checkbox when uploading files, there is no way of changing this after the file has been uploaded! And that´s where the real problem lies. Why can´t IBM provide an option to do this after the file has been uploaded? Come on! :-)

Anyway, I did some real debugging using Firefox debugger and the Chrome development tool to figure this one out. I looked at every javascript in the IBM Connections solution, I´ve searched through .jar files and looked at every possible configuration option. And finally, I found the code which ticks off that darn checkbox. This system is Connections 5.5 CR3 with Docs 2.0 CR 3, btw.

Linux is so much easier when it comes to searching through file content, so I went over to a Linux installation and performed the searches there (even though my test server where I can do the changes is on Windows).

So, I found that the checkbox is called "_setExt". In the html source, it looks like this:
<input id="lconn_files_widget_UploadFile_1_setExt" class="lotusCheckbox IECheckbox" name="_setExt" value="true" checked="" type="checkbox">
So, in Linux, I searched every file possible for this, by running the command in the "AppSrv01\InstalledApps\cellname\Files.ear" folder.
grep -Hrn '_setExt'
This produced no result.

I then went into the Common.ear folder, and search through every .jar file.
find . -name "*.jar" -exec zipgrep "_setExt" '{}' \;
 This also produced no result....

I then went into the data/shared/provision/webresources folder and search through every .jar file.
find . -name "*.jar" -exec zipgrep "_setExt" '{}' \;
And there we go! I found a couple of .jar files where the string "_setExt" was found.
I then opened up the jar file "" in Winrar, and looked at the javascripts which were relevant, and one particular .js file stood out:

Inside the jar file, it´s under the folders "resources\action" and it´s name is "AbstractShareFile.js".

So, after taking a backup of the "" I tested by unzipping the jar file, changed the file "AbstractShareFile.js", and zipped it down again. A restart of the Connections servers was needed, and afterwards, I could actually see that my beautiful checkbox actually was ticked off!!

Here´s the changes I did:

So, I commented out line number 253 and then wrote a new line on line 254 which says:
input.checked = input.defaultChecked = true;
Which gave me the result in the File-upload dialogue box:

But, as we all know, if we later on apply a fixpack to our Connections servers, the .jar files might be overwritten. So I figured out how to use the Customization Directory in order to override this javascript file which is inside the .jar file.
First of all, I put the original file "" back.

I then reached out to the experts in the IBM Connectuons Skype community, and my fellow IBM Champion Michele Buccarello gave me this link:

So, in order for me to extract the javascript file from the .jar file, and put it into the correct folder in the Customization directory, I had to look at the top of the file:
Which meant that under the "data\shared\customization\javascript" directory, I had to create a subfolder structure like this:
"lconn\files\action" and I had to save my modified "AbstractShareFile.js" file there.

I also added at the top of the scriot an alert, which showed me a message box every time the javascript is loaded for the first time:
I then restarted the Common Application in the Websphere Console, and also deleted my browser cache and tried a new file upload.

And this was the response, which shows me that my modified javascript actually gets loaded:

Pressing "OK" gave me the normal file-upload dialogue box, with the checkbox in question actually ticked off!!

And then I naturally removed that alert from the top of the javascript file :-)

I tested doing a file upload by dragging and dropping a file into the browser. This worked fine as well. And also, using the big blue "Share" button in the header also worked.

But hey, hang on. What about when you create documents directly in Connections using the IBM Docs feature? This shows a different dialogue box than the normal "File Upload" one.

Oh, I managed to figure this one out as well!!

The javascript you want is in the "provision\webresources" directory, and is in the "" file.
See under the folder "resources" in the jar file and copy out "global.js"

Save this file into the "data\shared\customization\javascript\concord" folder.
The "concord" folder probably has to be created by you.

Open up global.js and go to line 250 and comment that one out.
Then, on line 251, you can insert this:
inputExt.checked = inputExt.defaultChecked = true;

Save and restart the Common application, and then empty your browsers cache and test it by doing a Document creation by selectin "New" and then select "Document", "Spreadsheet" or "Presentation":
What you then see, is that the box "Files can be shared with people external to your organization" is ticked off for you!

The downside now is that you have to copy the global.js out from the correct jar file every time the IBM Docs gets updated with a new CR fix pack.
And the same goes for the "AbstracShareFile.js" when you do a CR update of IBM Connections.

But using the customization\javascript way is easier maintaining than having to replace a javascript file inside of a .jar file every time you do a CR update, right?

Remember, this is for Connections 5.5 CR3 with Docs 2.0 CR 3.
I have not tested this on Connections 6 yet. The line numbers I refeer to might be different for other versions than the system I did this on if you are on other versions of Connections and Docs.

I will post a blog entry when I try this out on Connections 6.x as well.

No comments: