Entra group comparison

Michael Fleet 41 Reputation points
2025-04-09T14:53:17.37+00:00

How do I add users to Entra group A based on whether users are in existing Entra group B but not in Entra group C?

@Rithwik Bojja

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,457 questions
{count} votes

Accepted answer
  1. RithwikBojja 1,530 Reputation points Microsoft External Staff
    2025-04-09T15:25:37.45+00:00

    Hi @Michael Fleet,

    You can use below JavaScript code to achieve that:

    enter image description here

    
    const rith_grpBMem = [
    
      { id: '68rithwik2739fc7c', name: 'Rithwik User' },
    
      { id: '48testb5717de', name: 'Bojja User1' },
    
      { id: 'e9ce96emoc29af837', name: 'Chotu User2' }
    
    ];
    
    const rith_grpCMem = [
    
      { id: '48testb5717de', name: 'Bojja User1' }
    
    ];
    
    const choIds = new Set(rith_grpCMem.map(u => u.id));
    
    const usersToAddToGroupA = rith_grpBMem.filter(u => !choIds.has(u.id));
    
    return usersToAddToGroupA;
    
    

    Here, I have taken hardcoded groups. You can replace it with yours.

    Output:

    enter image description here

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.