Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Suggested answer

how to get all combination of an arraylist?

(0) ShareShare
ReportReport
Posted on by 195

Hi ,

I have an arraylist ["1700",1701","1702","1703"] and selected value is "1700" .

I want to a method to return another arraylist with all the possible combination of a given arraylist in PORTALS.

Please help me with this.Thanks in advance!!!

Output:                                     

1700

1700,1701

1700,1702

1700,1703

1700,1701,1702

1700,1701,1703

1700,1702,1703

1700,1701,1702,1703

Regards,

Susritha

  • LeoAlt Profile Picture
    16,331 Moderator on at
    RE: how to get all combination of an arraylist?

    Hi partner,

    Sorry that I'm not very familiar with Liquid, you could refer to the liquid details and transfer the JS into liquid.

    docs.microsoft.com/.../liquid-objects

    Regards,

    Leo

  • Susritha Profile Picture
    195 on at
    RE: how to get all combination of an arraylist?

    Hi Leo,

    I want to use that algorithm in portals web Template liquid Language.Is it possible to use functions in web Template.

    Regards,

    Susritha,

  • Suggested answer
    LeoAlt Profile Picture
    16,331 Moderator on at
    RE: how to get all combination of an arraylist?

    Hi partner,

    Actually you are asking for an algorithm.

    Please refer to the following code.

    //set original arraylist
    var arry=["1700","1701","1702","1703"]
    var num="1700";
    
    function combination(){
        var result;
        var orgresult;
        var copyarry=arry.slice(0);
        copyarry.splice(copyarry.indexOf(num),1);
        for(let i=1;i<= 0 || size === 0) {
                result.push(rootArr);
                return;
            }
            for(let i=0; i<= remainArr.length-size; i  ) {
                const root = remainArr[i];
                const other = remainArr.slice(i   1);
                createTree(rootArr.concat(root), other, size - 1);
            }
        }
    
        createTree([], arr, size);
        return result;
        
    }

    pastedimage1589189652952v1.png

    Best Regards,

    Leo

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 51 Most Valuable Professional

#2
Ramesh Kumar Profile Picture

Ramesh Kumar 42

#3
David Shaw_UK Profile Picture

David Shaw_UK 27

Featured topics

Product updates

Dynamics 365 release plans