web
You’re offline. This is a read only version of the page.
close
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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 49 Super User 2025 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 27 Most Valuable Professional

#3
Soundari Profile Picture

Soundari 15

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans