Skip to content

Commit

Permalink
Added a check for ensuring the flow instance was found.
Browse files Browse the repository at this point in the history
  • Loading branch information
gunjandatta committed Feb 23, 2024
1 parent e3eedd1 commit 2bf3e42
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 37 deletions.
2 changes: 1 addition & 1 deletion dist/gd-sprest.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/gd-sprest.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gd-sprest",
"version": "7.8.6",
"version": "7.8.7",
"description": "An easy way to develop against the SharePoint REST API.",
"author": "Gunjan Datta <[email protected]> (https://gunjandatta.github.io)",
"license": "MIT",
Expand Down
74 changes: 41 additions & 33 deletions src/lib/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,40 +164,48 @@ List.runFlow = (props: IRunFlow): PromiseLike<IRunFlowResult> => {
flow => {
// Get the flow information
let flowInfo = JSON.parse(flow.SynchronizationData);
if (flowInfo) {
// Get the flow token
getFlowToken(flowInfo).then(token => {
// Trigger the flow
new Base({
accessToken: token,
requestType: RequestType.GraphPost,
endpoint: flowInfo.properties.flowTriggerUri,
data: {
rows: [{
entity: props.data
}]
}
}).execute(
// Success
() => {
// Resolve the request
resolve({
executed: true,
flowToken: token
});
},

// Get the flow token
getFlowToken(flowInfo).then(token => {
// Trigger the flow
new Base({
accessToken: token,
requestType: RequestType.GraphPost,
endpoint: flowInfo.properties.flowTriggerUri,
data: {
rows: [{
entity: props.data
}]
}
}).execute(
// Success
() => {
// Resolve the request
resolve({
executed: true,
flowToken: token
});
},

// Error
(ex) => {
// Resolve the request
resolve({
executed: false,
errorDetails: ex.response,
errorMessage: "Error triggering the flow."
});
}
)
});
// Error
(ex) => {
// Resolve the request
resolve({
executed: false,
errorDetails: ex.response,
errorMessage: "Error triggering the flow."
});
}
)
});
} else {
// Resolve the request
resolve({
executed: false,
errorDetails: "The flow with id " + props.id + " doesn't exist." as any,
errorMessage: "Error getting the flow instance."
});
}
},

// Error
Expand Down
2 changes: 1 addition & 1 deletion src/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { IREST } from "../@types";
* SharePoint REST Library
*/
export const $REST: IREST = {
__ver: 7.86,
__ver: 7.87,
AppContext: (siteUrl: string) => { return Lib.Site.getAppContext(siteUrl); },
Apps: Lib.Apps,
ContextInfo: Lib.ContextInfo,
Expand Down

0 comments on commit 2bf3e42

Please sign in to comment.