You can use something like this. It uses functions in DFFS so you cannot use it outside of your DFFS forms.
function getAllAzureGroups() {
var d = jQuery.Deferred();
spjs.dffs.getMSGraphAccessToken().done(function (t) {
spjs.dffs.getAzureGroupsForUser(t).done(function (gData) {
var groups = {};
jQuery.each(gData.value, function () {
groups[this.displayName] = this;
});
d.resolve(groups);
}).fail(function (err) {
spjs.dffs.alert({
"title": "Error in spjs.dffs.getAzureGroupsForUser",
"msg": JSON.stringify(err)
});
});
}).fail(function (err) {
spjs.dffs.alert({
"title": "Error in spjs.dffs.getMSGraphAccessToken",
"msg": JSON.stringify(err)
});
});
return d.promise();
}
var userGroups = getAllAzureGroups().done(groups => {
console.log("Logged in users groups", groups);
});
Alexander