0

I have been asked to add a simple workflow to a SharePoint list in M365. I can see the option for checking my flows but how can I quickly check if that list already has a flow created by another account? I understand there is an admin centre for flow but I don't currently have access to this. Thanks David

1 Answer 1

0

Try the below snippet in a browser's developer console to get the list of flows associated with the SharePoint List using REST API. This will not provide the flows for a specified account, instead, it gives you all flows irrespective of accounts.

/* **** RUN THIS SNIPPET in Browser Developer Console to see the output **** */
// POST request Call
function RestRequest(url, params) {
    var req = new XMLHttpRequest();
    return new Promise(function(resolve, reject) {
        req.onreadystatechange = function() {
            if (req.readyState != 4) // Loaded
                return;
            if (req.status >= 200 && req.status < 300) {
                resolve(req);
            } else {
                reject({
                    status: req.status,
                    statusText: req.statusText
                });
            }

        };
        // Prepend web URL to url and remove duplicated slashes.
        var webBasedUrl = (_spPageContextInfo.webServerRelativeUrl + "//" + url).replace(/\/{2,}/, "/");
        req.open("POST", webBasedUrl, true);
        req.setRequestHeader("Content-Type", "application/json;odata=verbose");
        req.setRequestHeader("ACCEPT", "application/json;odata=verbose");
        req.setRequestHeader("x-requestdigest", _spPageContextInfo.formDigestValue);
        req.send(params ? JSON.stringify(params) : void 0);

    });

}

//Sends the post request and retrieves the Flow instances associated to SharePoint
RestRequest("/_api/web/GetList(@a1)/SyncFlowInstances?@a1='/sites/TeamSite/Lists/Clients'", null).then(function(resp) {
    var output = JSON.parse(resp.response);
    var flowinstances = JSON.parse(output.d.SynchronizationData).value;
    for (var i = 0; i < flowinstances.length; i++) {
        console.log('Name: ' + flowinstances[i].name + "\r\nDisplayName: " + flowinstances[i].properties.displayName + "\r\nEnvironment Name: " + flowinstances[i].properties.environment.name + "\r\nModified: " + flowinstances[i].properties.lastModifiedTime);       
    }
});

I hope this snippet will help you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.