Get a list of users from Entra ID group to populate User Allocation

Luiz Lucena
Mega Sage

Hello friends, 

 

I've created 3 Software Entitlement records for us to track user licenses in Entra ID.
Those licenses are associated with an Entra ID group respective. 
My current challenge is to create a Flow to update the User Allocation every morning if a new user was added manually to those groups in Entra ID.

I'm still crawling in Flow designer and I'm facing some issues I enumerated in the screenshot below:
Screenshot 2025-12-17 at 14.40.20.png

1. in the action to Look up records in the Software Entitlement table where the Entra ID (u_entra_id) is not empty, only the first record is passed to the Flow Variable (step 4). If it is a "for each", why just one is being passed (number 2 in the screenshot)?

2. I've added this script action (below) to compare both lists, from Entra ID and the User Allocation table and for each difference (users to Add or to Remove), perform the necessary action. 

(function execute(inputs, outputs) {
    var groupMembers = inputs.groupMembers || [];
    var currentAllocations = inputs.currentAllocations || [];

    var usersToAdd = [];
    var usersToRemove = [];

    // Find users to add
    groupMembers.forEach(function(member) {
        if (currentAllocations.indexOf(member) === -1) {
            usersToAdd.push(member);
        }
    });

    // Find users to remove
    currentAllocations.forEach(function(allocation) {
        if (groupMembers.indexOf(allocation) === -1) {
            usersToRemove.push(allocation);
        }
    });

    outputs.usersToAdd = usersToAdd;
    outputs.usersToRemove = usersToRemove;
})(inputs, outputs);

Screenshot 2025-12-17 at 15.05.38.png

 

Not sure if the script action is correct. 

0 REPLIES 0