cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Advocate II
Advocate II

Collection: Pulling first record of sharepoint list and then the data I want, Bug?

Hi All, 

 

I have made a job card application, Basically, it has 2 SharePoint lists. 1 is the primary list with client details and 2nd list holds items provided and details about those items. 

On the selection of the gallery item, it will clear the collection ColJCItems and set the Gallery.Selected.ID to a Variable, and on a button, it collects the items for the given job card. 

 

The button that shows Code:

Clear(COLJCITEMS);
Set(
    JobCardID,
    GALJobCards.Selected.ID
);
ClearCollect(
    JCJobCard,
    First(
        Filter(
            'Job Cards',
            ID = JobCardID
        )
    )
);
ForAll(
    Filter(
        'Job Card Items',
        Title = Text(JobCardID)
    ),
    Collect(
        COLJCITEMS,
        Last(
            FirstN(
                AddColumns(
                    'Job Card Items',
                    "RowNumber",
                    CountRows(COLJCITEMS) + 1
                ),
                CountRows(COLJCITEMS) + 1
            )
        )
    )
);
Set(
    EditV,
    false
);
Set(
    TimeV,
    false
);
Set(
    ItemsV,
    false
);
Set(
    InformationV,
    false
);
Set(
    SignV,
    false
);
Set(
    HTMLView,
    true
)

 

Now the collection is returning the Items I am looking for as well as the first Item in the SharePoint list.  I can confirm the Item Title field (Job cards ID's) are not equal to the ID of the job card. 

 

The Gallery label "on select" property is:

 

Clear(COLJCITEMS);Set(JobCardID,ThisItem.ID);Set(HTMLView, false );Set(EditV, false );Set(TimeV, false );Set(ItemsV, false );Set(SignV, false );Set(InformationV, true )

I am clearing the COLJCITEMS twice to try and remove the added item. but nothing is working. 

 

If I just have a button clear the collection and then go view the collection, it is empty. however on collect, it returns the wrong data. 

 

any assistance is appreciated. please let me know if you need anything further.

 

thank you 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi All

 

So there is an issue with the for all function doing a collect as if I do a basic collect it works perfectly every time. code below:

Clear(COLJCITEMS);
Set(
    JobCardID,
    GALJobCards.Selected.ID
);
ClearCollect(
    JCJobCard,
    First(
        Filter(
            'Job Cards',
            ID = JobCardID
        )
    )
);
Collect(
    COLJCITEMS,
    Filter(
        'Job Card Items',
        Title = Text(JobCardID)
    )
);
Set(
    EditV,
    false
);
Set(
    TimeV,
    false
);
Set(
    ItemsV,
    false
);
Set(
    InformationV,
    false
);
Set(
    SignV,
    false
);
Set(
    HTMLView,
    true
)

I don't know why it would not apply the filter on the records while for all was there however it was only there to give me a row number for my items on the list.

 

After taking row numbers out it works fine. a bit disappointed but what can you do. 

Comparison of changed code:

Before:
----------------------
ForAll(
    Filter(
        'Job Card Items',
        Title = Text(JobCardID)
    ),
    Collect(
        COLJCITEMS,
        Last(
            FirstN(
                AddColumns(
                    'Job Card Items',
                    "RowNumber",
                    CountRows(COLJCITEMS) + 1
                ),
                CountRows(COLJCITEMS) + 1
            )
        )
    )
)
---------------------------------
After:
---------------------------------
Collect(
    COLJCITEMS,
    Filter(
        'Job Card Items',
        Title = Text(JobCardID)
    )
)

Thanks for the support 

View solution in original post

3 REPLIES 3
Community Support
Community Support

Hi @SnowFlake ,

Could you describe more clearly about "If I just have a button clear the collection and then go view the collection, it is empty. however on collect, it returns the wrong data. "?

Do you mean that the Clear function do not work?

Actually, I haven't quite understand your issue.

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yutliu-msft 

I trust you well, I should have sent screenshots in the last post 🙂 image.png

 

The collection that holds child records 
image.png

now the code for the button that collects data

Clear(COLJCITEMS);
Set(
    JobCardID,
    GALJobCards.Selected.ID
);
ClearCollect(
    JCJobCard,
    First(
        Filter(
            'Job Cards',
            ID = JobCardID
        )
    )
);
ForAll(
    Filter(
        'Job Card Items',
        Title = Text(JobCardID)
    ),
    Collect(
        COLJCITEMS,
        Last(
            FirstN(
                AddColumns(
                    'Job Card Items',
                    "RowNumber",
                    CountRows(COLJCITEMS) + 1
                ),
                CountRows(COLJCITEMS) + 1
            )
        )
    )
);
Set(
    EditV,
    false
);
Set(
    TimeV,
    false
);
Set(
    ItemsV,
    false
);
Set(
    InformationV,
    false
);
Set(
    SignV,
    false
);
Set(
    HTMLView,
    true
)

Sharepoint items 

Title is ID of JobcardTitle is ID of Jobcard

I dont know if this will help but it works first time perfectly when the app starts up. after you select different a different gallery item (Job card) it seems to stop doing the filter on the for all function. Thus why I assumed it was not clearing the collection from the first run. 

I then thought maybe its the gallery not updating the job card id to a variable. but I can confirm that it goes and fetches the correct job card parent using the Set(JobCardId, gallery.selected.id) 

 

I made a button to clear the collection and even when the app collects to an empty collection it still fetches the wrong child items.

 

Im really stumped here as from what I can see it works the first time it runs so the code is correct. its almost like not all the code is running again.  


if you would like me to send screenshots of it working on start I can?

Thank you for your support

Hi All

 

So there is an issue with the for all function doing a collect as if I do a basic collect it works perfectly every time. code below:

Clear(COLJCITEMS);
Set(
    JobCardID,
    GALJobCards.Selected.ID
);
ClearCollect(
    JCJobCard,
    First(
        Filter(
            'Job Cards',
            ID = JobCardID
        )
    )
);
Collect(
    COLJCITEMS,
    Filter(
        'Job Card Items',
        Title = Text(JobCardID)
    )
);
Set(
    EditV,
    false
);
Set(
    TimeV,
    false
);
Set(
    ItemsV,
    false
);
Set(
    InformationV,
    false
);
Set(
    SignV,
    false
);
Set(
    HTMLView,
    true
)

I don't know why it would not apply the filter on the records while for all was there however it was only there to give me a row number for my items on the list.

 

After taking row numbers out it works fine. a bit disappointed but what can you do. 

Comparison of changed code:

Before:
----------------------
ForAll(
    Filter(
        'Job Card Items',
        Title = Text(JobCardID)
    ),
    Collect(
        COLJCITEMS,
        Last(
            FirstN(
                AddColumns(
                    'Job Card Items',
                    "RowNumber",
                    CountRows(COLJCITEMS) + 1
                ),
                CountRows(COLJCITEMS) + 1
            )
        )
    )
)
---------------------------------
After:
---------------------------------
Collect(
    COLJCITEMS,
    Filter(
        'Job Card Items',
        Title = Text(JobCardID)
    )
)

Thanks for the support 

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Users online (7,217)