Automatically open Office documents on a Sharepoint Server 2013 in Firefox (full Office integration) - sharepoint

I recently switched to Firefox. Unfortunately my company still uses Sharepoint Server 2013 (migration to Sharepoint Online is planned somewhere in the future) which no longer offers a fluid integration with Office.
Every time I want to edit an Office document, it gets downloaded instead of being 'forwarded' to be opened by Word, Excel, etc. Modifications need to be saved locally and than uploaded afterwards. This is hugely annoying.
Is there some way that I can automate this in code, using a Firefox extension? Does Sharepoint expose some kind of hook or metadata containing the document's URL?

(Self-answer originally provided by Dotsoltecti; copied from question body into a proper answer).
Sharepoint 2013 passes the document's URL via the right-click contextual menu.
There exists a very neat add-on for Firefox called "custom right-click menu" by Sander Ronde. After installing this extension I added the script below:
var feedback = crmAPI.getClickInfo();
var url = feedback.linkUrl;
if (url.endsWith("docx") || url.endsWith("doc")) { var uri = "ms-word:ofe|u|" }
if (url.endsWith("xlsx") || url.endsWith("xls")) { var uri = "ms-excel:ofe|u|" }
if (url.endsWith("pptx") || url.endsWith("ppt")) { var uri = "ms-powerpoint:ofe|u|"}
var toOpen = uri.concat(url);
window.open(toOpen);
Et voilĂ : right clicking on a Word/Excel/PowerPoint-document executes the script and correctly forwards the document to the said program (you have to whitelist your SharePoint-site with the pop-up blocker). Modifications are handled directly by the Office-program.
Only drawback so far is that every time a document is opened, a new blank window is generated. I haven't found a solution for that yet, so suggestions are always welcome.

Related

Open document from share point directly in office365

I'm using the graph API to access the documents in SharePoint. The response I'm getting looks like this:
graph api response
I want to let the user open this file (an excel file in this example) using excel desktop app. In other words, I want to resemble in my app the "Open in desktop app" functionality Excel for the web already provides:
excel for the web functionality
Is that possible?
Thanks in advance!
You can try and get the webUrl of the parent folder of the document you want to open. On that webUrl you add:
String documentUrl = parentWebUrl + "/YourDocumentName.docx";
And then you use Office URI scheme to open it localy (read more here)
It should be possible to do it using the webUrl of the document itself, but i have not figured out how to do it.

MS Teams - Task Module not opening SharePoint URL

I have been trying to open SharePoint's sharing dialog using microsoftTeams.tasks.startTask() in my MS Teams application and it shows an infinite loader in desktop client.
As I have come across certain articles and open threads, MS Teams does support redirecting within an iframe. Opening SharePoint's sharing URL goes through the authentication first (internal redirecting using login.microsoftonline.com)
Things I have tried so far -
var currentTeamsSiteUrl = new URL(currentItem['teamSiteUrl']);
var sharingDialogUrl = `${currentTeamsSiteUrl.href}/_layouts/15/sharedialog.aspx?listId=${currentItem['ListID']}&listItemId=${currentItem['ItemID']}&clientId=sharePoint`;
var src = `${currentTeamsSiteUrl.href}/_layouts/15/teamslogon.aspx?spfx=true&dest=${encodeURIComponent(sharingDialogUrl)}`;
microsoftTeams.tasks.startTask({
title: "Share Item",
height: 560,
width: 350,
url: src,
fallbackUrl: null,
card: null,
completionBotId: null,
});
The issue I am facing in desktop client is in attached screenshot -
Interestingly enough, the code works if I run the application in browser, and not in the MS Teams Desktop Client.
I have added *.sharepoint.com, login.microsoftonline.com as a valid domains in application config json.
I have tried opening the sharing URL using window.open() - opens up browser from desktop client and new tab from browser, and as per Microsoft's scholars using Task Module is far better approach, but that is not working in desktop client. Again, not an elegant solution.
I have been trying to find a workaround for sharing dialog not running in MS Teams desktop app and it all comes down to the error shown in the attached screenshots. I tried allowing third-party cookies for and other different solutions (https://learn.microsoft.com/en-us/microsoftteams/troubleshoot/teams-sign-in/sign-in-loop) to make it work but no luck so far.
Any help would be appreciated.
Cheers!

Save functionality in Excel Addin using OfficeJs and ReactJS

Background: I am developing an excel Add-in using OfficeJS library. The addin is using the ReactJS components and Office Fabric UI. The Add-in is successfully created and using OfficeJS library we can bring the user selection to the Excel sheet.
Problem: The problem is that I want to get the event in OfficeJS to Save the sheet using the Excel Native capability i.e., once user clicks on Save then the Save Dialogue box will appear(as per Native excel behavior)and on that I want to invoke my ReactJS business rules(some functionalities). In order to do that I want to use Save event for the same in OfficeJS which should be triggered automatically.
Code Sample:
Office.initialize = () => {
Excel.run(function (context) {
var sheet = context.workbook.worksheets.getItem("Sheet1");
context.workbook.load(["save"]);
context.sync().then(() => {
context.workbook.save(Excel.SaveBehavior.prompt);
//OR
context.workbook.save(Excel.SaveBehavior.save);
});
}).catch(function(error) {
console.log(error.debugInfo);
});
}
Research: The above two functions which I have tried are from the Microsoft Documentation where it is mentioned as:
Workbook.save saves the workbook to persistent storage. The save method takes a single, optional saveBehavior parameter that can be one
of the following values:
Excel.SaveBehavior.save (default): The file is saved without prompting the user to specify file name and save location. If the file
has not been saved previously, it's saved to the default location. If
the file has been saved previously, it's saved to the same location.
Excel.SaveBehavior.prompt: If file has not been saved previously, the
user will be prompted to specify file name and save location. If the
file has been saved previously, it will be saved to the same location
and the user will not be prompted.
System Configurations: I am using Windows 10, Excel 2016 Desktop and Office 365 Online version. I am using IE-10 and Google Chrome for Online version of Excel. Additionally I have checked the same using Windows-7 and Excel-2016 and same browsers.
Do let me know if the above functionality can be achieved?
Unfortunately, Office JS Excel API currently doesn't support onSaved event. one of the reasons was that Excel has an autosave feature, which triggers save action frequently. So we worry to provide onSaved event may fire too many event notifications to customers.
But I would suggest that you could submit the request and upvote this request at uservoice

Intermittent behavior in xpages application: by pressing the button to save, the document is not redirected and is displayed again

I'm having a problem with a new xpages application that was deployed in production for a few months, but has now only been expanded to the entire enterprise now. The problem that did not happen while the application was in production pilot is intermittent and happens when an action executes a current notesxsppdocument save (currentdocument). The symptom is that by pressing the button you save, the document is not redirected and is displayed again. What can be this problem. session timeout, a bug from xpages? The application basically uses the components of the extension library, there is no external component to the xpages. When the problem occurs, if the user closes the document's xpages opens again and then clicks the button again the code runs successfully.
I have a function that stores a file attached to the doc in a repository. I suspect she's the problem. The function uses the file upload component and a button to execute a java agent that stores the file in a repository. The button code below follows. Its function is basically to create the rich text if it does not exist and call the agent that consumes a web service to transfer the file to a repository and erase it from the document.
I asked the user not to use the function for a few days at the time of the service to verify that the problem will persist.
if(validaArquivo())
{
var url=#ReplaceSubstring(context.getUrl(),"openDocument","editDocument")
url += '&tab=dossie' ;
var fieldItem:NotesItem =
currentDocument.getDocument().getFirstItem("arquivos");
if (fieldItem==null){
// create the field as an RTF
//writeToLog("Creating xxxxx field");
var rtItem:NotesRichTextItem =
currentDocument.getDocument().createRichTextItem("arquivos");
currentDocument.save();
}else if (fieldItem.getType()==1280){
//writeToLog("--> Converting xxxxx to RTF");
currentDocument.replaceItemValue("arquivosTEXT",
fieldItem.getText());
fieldItem.remove();
var rtItem:NotesRichTextItem =
currentDocument.getDocument().createRichTextItem("arquivos");
currentDocument.save();
}
var agente:NotesAgent=database.getAgent("(SalvaAnexos)");
agente.runWithDocumentContext(currentDocument.getDocument(true));
context.redirectToPage(url)
}
else
{
document1.removeAllAttachments("arquivos");
}
When users are using the application, rebuild or to change some code on prod environment can cause this.

SPLimitedWebpartManager resetting custom web part properties on SaveChanges

We are running a SharePoint 2013 publishing site in 2010 mode. A section of the code which used to work fine in 2010 is not working after I installed the SharePoint 2013 CTP update (Configuration database version:
15.0.4815.1000).
I am trying to add a custom webpart with custom properties. The below code adds the webpart to the correct zone but when SPLimitedWebPartManager.SaveChanges(webpart) executes, it resets the custom property values to default values.
var wpManager = web.GetLimitedWebPartManager(page.ListItem.Url, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared)
var dsWebPart = new DocumentSetBridge()
{
Title = "Shared Resource(s)",
ChromeType = System.Web.UI.WebControls.WebParts.PartChromeType.None,
KnowledgeCenterAssetsLibraryItemId = documentSetUniqueGuid,
ID = KnowledgeCenterSettings.DocumentSetBridgeWebPartId,
ShowManageDocLink = true,
IsUserCommunityDS = true
};
wpManager.AddWebPart(dsWebPart, UserGroupSettings.DOCUMENTSET_WEBPART_ZONE_ID, UserGroupSettings.DOCUMENTSET_WEBPART_ZONE_INDEX);
Any help is much appreciated. Thanks in advance.
Senthil S
UPDATE: Found the issue with permissions. It creates a new page with pre-defined webparts and assigns the user manage rights just for the page. Eventhough, the page is updated with proper permissions, it seems like SP is not recognizing it until sometime later. It could be because of some timing issue. If I add the web part impersonating as an admin everything looks fine.
After adding the WebPart to the SPLimitedWebPartManager you should do the following
wpManager.SaveChanges(dsWebPart);
web.Update();
and/or use SetPersonalizationDirty() like
dsWebPart.SetPersonalizationDirty();

Resources