Skip to main content

Notifications

Announcements

No record found.

Service | Customer Service, Contact Center, Fie...
Suggested answer

how to get all combination of an arraylist?

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
    LeoAlt 16,329 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
    Susritha 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
    LeoAlt 16,329 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans