cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PaulBI
Resolver I
Resolver I

Forall patch new record returns that the column is not accessible in this context

I'm a little stuck.  If I remove the forall it works perfectly but when I add forall it gives a failure that the column is not accessible.  The even stranger part is that I use the same gallery and forall/patch above with a different table but edit records instead of create new and have no problems.  I tried changing this to edit but I still get the error.  Any help is appreciated.

 

ForAll(galWorkItems_1.AllItems,
         Patch(
    'Project Activities',
    Defaults('Project Activities'),
    {
        Project: gblProject,
       // 'Work Item': Label1.Text,
       'Work Item':LookUp('Project Work Items',Text(msft_projectworkitemid)=Label1.Text),
        Name: Left(
            WorkItemUpdate_1.Text & ": " & lblWorkItemTitle_1.Text
            ,
            100
        ),
        Description: WorkItemUpdate_1.Text & ": " & lblWorkItemTitle_1.Text, 
        Code: "0" //code for custom update
    }
)
)

  I'm convinced I'm forgetting something simple but for the life of me can't see it.

 

Thanks 

1 ACCEPTED SOLUTION

Accepted Solutions
PaulBI
Resolver I
Resolver I

So it is definitely some issue with the table itself.  I plugged other tables in that worked.  I tried disconnecting and reconnecting the table but that didn't help.  I ended up making a second table to mirror this one and wrote to that one successfully and will have to go back and rewrite everywhere else I write to the old one to the new one...  Wish I could figure out what the preventing issue was but never figured it out.

View solution in original post

17 REPLIES 17
jesudas
Helper I
Helper I

not sure what the issue is. I am just guessing here. Maybe accessing the lblworkitem is causing the issue

 

how about a set statement before Forall

 

Set(myVar, lblworkitemtitle_1.text);

 

and then use this myVar inside the ForAll statement

 

 

HimanshuSSharma
Resolver I
Resolver I

@jesudas If the label is inside the gallery, this will not work.

@PaulBI what is gblProject?

Is it a field in the Gal.AllItems? If Yes, create a label and set it to ThisItem.gblProject and use label.Text in your ForAll

If it is a global variable, ignore the above (I am assuming you are adding work items to a project)

BTW, which column gives the error of not being accessible?

PaulBI
Resolver I
Resolver I

Thanks for the quick replies.  To answer the first question, @jesudas unfortunately lblworkitemtitle_1.text is inside the gallery.  For the second question @HimanshuSSharma gblProject is a global variable.  Attached is the full error message but it never calls out specifically which column is causing the issue. 

 

 

PaulBI
Resolver I
Resolver I

I do have an update but not a fix yet.  So I found that if I collect the gallery and select a specific column out of it, the error is removed, but nothing is written.  Progress but still not able to make it work.  Any ideas?

 

Snip.PNG

PaulBI
Resolver I
Resolver I

Collected more information just now.  I changed the column to something that is unique for each row in the gallery.  If I change and update just one row it works.  If I update more than one (say 3), it recognizes that and will create 3 records but each record is identical (typically looks to be the last row I edited) and doesn't record the other two at all.  Hopefully this means something and I can start to figure out how to correct?

PaulBI
Resolver I
Resolver I

So it is definitely some issue with the table itself.  I plugged other tables in that worked.  I tried disconnecting and reconnecting the table but that didn't help.  I ended up making a second table to mirror this one and wrote to that one successfully and will have to go back and rewrite everywhere else I write to the old one to the new one...  Wish I could figure out what the preventing issue was but never figured it out.

View solution in original post

HimanshuSSharma
Resolver I
Resolver I

Okay, so one thing to note here. You are using Forall on colChangedItems but are referring to Label1.text and other labels as well. These labels should not be in a Gallery. If they are in the gallery, they will always pick from the first gallery item.

Your earlier method of looping over gallery items suggested something else. if you switched to collection, you should switch the values passed in the patch function accordingly.

 

PaulBI
Resolver I
Resolver I

Yeah I was trying everything I could think of (collecting and using a collection, connecting and reconnecting datasource, etc) even if I deleted everything after the defaults statement it still errored out so the issue originates before pulling all those labels, etc in.  My added datasource hasn't had any issues since, doesn't make any sense but it's working.  

PaulBI
Resolver I
Resolver I

Ok I really can't explain this.  The new table I created worked great from Wednesday to this afternoon.  Now it is giving the exact same error as the last one did saying that the column is no longer accessible...  Something is changing in the table that causes this error to happen, but I have no idea what could be doing it...

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,224)