web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
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

I have the same question (0)
  • Suggested answer
    LeoAlt Profile Picture
    16,331 Moderator on at

    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

  • Susritha Profile Picture
    195 on at

    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,

  • LeoAlt Profile Picture
    16,331 Moderator on at

    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

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

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

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 51 Super User 2026 Season 1

#1
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 51 Most Valuable Professional

#3
Nagaraju_Matta Profile Picture

Nagaraju_Matta 50

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans