U4-9690 - IsLast helper always return false

Created by Bjarne Fyrstenborg 29 Mar 2017, 09:14:22 Updated by Bjarne Fyrstenborg 29 Mar 2017, 09:44:08

It seems that the IsLast helper always return false. https://our.umbraco.org/Documentation/Reference/Querying/IPublishedContent/IsHelpers#ishelper-methods

I have a MNTP picker to pick case items, in the example below I have two cases picked.

@foreach (var caseItem in caseCollection)
    int imageId = caseItem.GetPropertyValue<int>("image");
    var image = imageId > 0 ? Umbraco.TypedMedia(imageId) : null;

    int count = caseCollection.Count();
    bool isFirst = caseItem.IsFirst();
    bool isNotFirst = caseItem.IsNotFirst();

    bool isLast = caseItem.IsLast();
    bool isNotLast = caseItem.IsNotFirst();

    bool isLastAlt = caseCollection.IndexOf(caseItem) == caseCollection.Count() - 1;

    <div class="col-md-3">
        Count:  @count<br />
        IsFirst: @isFirst<br />
        IsNotFirst: @isNotFirst<br />
        IsLast: @isLast<br />
        IsNotLast: @isNotLast<br />
        Alternative (islast): @isLastAlt<br />

which return the following output:

Count: 2
IsFirst: True
IsNotFirst: False
IsLast: False
IsNotLast: False
Alternative (islast): False

Count: 2
IsFirst: False
IsNotFirst: True
IsLast: False
IsNotLast: True
Alternative (islast): True

In the screenshot @isLast is highlighted with yellow and my alternative "is last" variable @isLastAlt is marked with green border.

Furthermore is seems that IsNotLast is in wrong order - for item 1 it should be True and for Item 2 it should be False.

4 Attachments


Bjarne Fyrstenborg 29 Mar 2017, 09:36:49

When I pick a three cases (there are in total three case nodes), IsLast does return True for last item. I wonder if it doesn't evaluate the current collection, but the nodes at that level?

Bjarne Fyrstenborg 29 Mar 2017, 09:44:08

If I add .ToContentSet() on caseCollection it returns True for IsLast on last item (with two items picked). But IsNotLast returns same values as IsLast.

Priority: Normal

Type: Bug

State: Submitted


Difficulty: Normal


Backwards Compatible: True

Fix Submitted:

Affected versions: 7.5.11

Due in version:


Story Points: