Office Add-in, using Node JS, and Graph with SSO, how do I actually make a new call? - node.js

I have been looking into connecting a Word Add-in to SharePoint list data using a task pane.
I have completed the following two tutorials that guide you through creating an add in that uses SSO to access user data and then update the add-in to get data from one drive instead.
https://learn.microsoft.com/en-us/office/dev/add-ins/quickstarts/sso-quickstart
https://learn.microsoft.com/en-us/office/dev/add-ins/quickstarts/sso-quickstart-customize
However, these tutorials have you edit the .ENV file with a new GRAPH_URL_SEGMENT and SCOPE etc, however I see no reference to how editing the ENV would actually effect anything, no code that makes use of this information and no details of when the call using the Graph api is actually made and what configuration it uses.
I have been able to get a call working to SharePoint in the graph explorer but cannot move that over to the word add-in.
Could someone please help me understand where the calls endpoint is used to make the Graph call and how someone would go about to change this to make a call to SharePoint.

The call to get Microsoft Graph data is in the library office-addin-sso. Specifically, the files \node_modules\office-addin-sso\src\app.ts and \node_modules\office-addin-sso\src\authRoute.ts
You will see in those files where the ENV variables are read.
To get your SharePoint data, use the URL you constructed in the Graph Explorer to set the GRAPH_URL_SEGMENT and the QUERY_PARAM_SEGMENT in the ENV file. Also, update the SCOPE variable in that file as needed. See the section https://learn.microsoft.com/en-us/office/dev/add-ins/quickstarts/sso-quickstart-customize#changes-required-for-any-type-of-add-in for an example.
You will also need to update the permissions you request in the Azure portal as described in this section: https://learn.microsoft.com/en-us/office/dev/add-ins/quickstarts/sso-quickstart-customize#update-app-permissions-in-azure

Related

Excel Script + Power Automate - Script not found. It may have been unshared or deleted

I have a PowerApp that:
takes a SharePoint file,
filters the data,
and calls a PowerApps/Flow to:
execute an Excel script,
get the file contents,
and create a file with it.
The script is shared to all PowerApps users, same for the source file, everyone can read, edit and delete the file.
When anyone but I run the flow either from the PowerApp or from the flow itself, they get an error "Script not found. It may have been unshared or deleted." This happens when anyone other than me tries to run the app/flow.
The weird thing is that if I run the PowerApps / Flow, everything works fine.
Do you know how can I get other users than me to run it either from the PowerApps or PowerAutomate ?
This issue is 'kinda' similar to this one but it's different in the source file.
Found out how this one is working. Sharing the solution here :
Firstly, you'll need to create all your flows and PowerApps apps within a "Solution". You can create a new solution from "Solutions/New solution".
Within this new solution, create a button-triggered flow that runs Office Scripts. Let's call it "Child flow". Please note this flow requires to have a last action to respond to a PowerApp or flow.
Configure this child flow with run-only users settings as described in my previous response. Make sure to choose "Use this connection ...".
Within the same solution, create another flow with the PowerApps trigger. This flow will be triggered by your PowerApps app. In this flow, add a step to run the child flow you've just created above.
Within the same solution, create your PowerApps app. Configure your PowerApps button to run the second flow (the parent flow).
Now share the PowerApps app with another user, ask them to try it out, and see if the Run script action in the child flow can work properly.
Thanks to Yutao from MS for the solution !

Documentation for "Export Project" Quire API

I want to automate the backup of quire.io data. Essentially functionality offered via Export project data from the web browser.
I think it calls https://quire.io/r/export/project API.
Where can I find the documentation ? I assume it just requires some Auth header
Without that I need to jump thru the hoops to create JSON that is equivalent of the JSON created by Export JSON functionality already present
There is currently no api call available to do a full project export.
Feel free to post a feature request on the project page.

Are there more methods for the "application" object?

Am I right to conclude that I may have to wait for certain objects and methods to appear in order to launch one office App from another?
I'm trying to link a number of Excel lines (customer interactions) one to one with OneNote pages.
I cannot find Office-js methods equivalent to those used in this VBA. I looked in the Office.js documentation and see only a couple of methods.
It is perfectly possible that I'm barking up the wrong tree.
This isn't possible with using Office.js. It's important to remember that each Web Add-in runs within its own sandbox and is essentially just a web app. It simply isn't possible for a Web Add-in to determine what other applications you have and remotely execute code against them (nor would you really want this if you consider the potential security risks that would open up).
What you can do however is leverage Microsoft Graph to interact with OneNote. So rather than having Excel drive OneNote over COM, you have your Web Add-in act as middleware between the current Excel Worksheet and a user's OneNote Notebook. You Add-in uses Office.js to communicate with the Worksheet and make REST calls to Microsoft Graph to interact the Notebook.
The first thing you'll need is an Access Token for the Excel user to use with Microsoft Graph. You can obtain this using the getAccessToken() method in Office.js. The steps for setting this up can be found at Authorize to Microsoft Graph in your Office Add-in (preview).
The second thing you'll need is to call Microsoft Graph. Assuming you want to keep things simple, I would use the Microsoft Graph Client SDK for Javascript for this. You'll also want to take a look at the OneNote API overview
from Microsoft Graph's documentation.
There are also some samples in OneNote's GitHub. Although none of the samples are exactly what you're looking for, they may still provide some valuable insights into how the API works.

comparing sharepoint list and sqlserver table

I have a list in sharepoint which maintains particular month OnCall list,and we are maintaining employee directory in sql server. My requirement is to get complete data from sql server and show it in sharepoint and compare with sharepoint list and show small icon for the employees who are On Call for that particular Month. Can anyone please suggest me the waus of implementing this.
Thanks in advance.
Update: I have finished the part where I have to connect to the sqlserver database and get the employees information. For this we are using 3rd party web part to connect to the sql server and pull the data from the table. Now I have to show some kind of image on the employee name to show that he is on-call for that week. We are going to cretae custom list for maintaing the list of people who are on-Call. Can anyone please advise me on how to accomplish this.
Write a custom webpart which will pull the data from the list using sharepoint object model and SQL server using ADO.NET and do the said comparison.
If you were looking for out of the box, I am afraid there i too little information given here to analyze if its feasible out of the box or not.
If you have the SharePoint Enterprise version, you can look at using the Business Data Catalog. This will let you bind columns to external data sources. This might provide you with the functionality you're looking for.
If you do not have the Enterprise features, do you have access to deploy WSP packages and custom code?
You will have to write your own data access to your external data source. Your options would be to have a job that pulls data from the external data source and populates SharePoint list(s) or create a custom view that pulls the external data on-demand.
You'll have to come up with synchronization strategies. Meaning, is the data in the external SQL data source static, reference information that does not need to be updated depending on what a user does in SharePoint? This seems to be the case based on your question. If you do need to update the external data source, you'll have to hook into the on save event (so probably a custom event handler that listens for ItemAdding) to update the data, validate, and optionally cancel the operation with an error message.
If you can't deploy WSP packages / DLLs, you could take a look at the jQuery SharePoint library. This will let you interact with lists using jQuery. If you also write a WCF or Web Service wrapper around the data you need access to from your external data source that is accessible from the SharePoint environment, you can use hack together a solution.
To accomplish this you'd need to place a Content Editor Web Part on the page you need custom data access. In there you will write the code to reference the jQuery javascript library and jQuery SharePoint library. The code will have to make the calls to your external data service and make any updates you need.
This is the least reliable method to accomplish what you want since it's entirely page-based and can be broken by simply disabling script or someone editing the CEWP or removing it altogether.
If you don't have access to place a CEWP or any of the other solutions, then you have no options at all.
it relatively easy now to pull all the data using the third party webpart and saving it into a custom list. I would recommend you not only creating custom list but also creating the content types for this list. take a look at SharPoint MVP's post about creating a Custom List with Content Types

Permissions problems with Excel Services in SharePoint

I'm trying to implement an Excel Services reporting solution in SharePoint (MOSS). Since the source data is a SharePoint list, this problem is doubly frustrating. I keep bumping up against permissions problems, even though I've enabled virtually everything in sight.
The first error is about refreshing external data - it's not (really) external data, but that's a semantic point.
The second error is a cryptic "Excel Web Access" problem.
Anyone get this to work??
Could be a couple different problems. The first possibility is that Excel Services doesn't support using SharePoint list data (crazy I know)... although this only applies if you try using the type of embedded data source you get if you choose Export to Excel from a list (again, I know crazy).
However an easy way around this problem is to use the SP webservices to get you list data. I had a macro written by someone at MS a while back that automated this conversion, if I canfind a link I'll post it. If you are using Kerberos then you task is probably finished. If using NTLM then you may need to also configure an SSO application so that the right credentials can be passed to the webservice (or any other data source for that matter). There's a pretty good step by step here.
One kind of "hack" to get this to work via UDF's (which if trusted, custom code can be deployed and made available via Excel Services) can be found here.

Resources