web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Pro Dev & ISV
Suggested answer

Patch

(1) ShareShare
ReportReport
Posted on by 51
Hi all
 
I am trying to update a sharepoint list
 
However the list is not updating after i patch - Where do i look to troubleshoot?   no errors are being given
 
Patch(
    'Truck Driver Time Card',
    LookUp(
        'Truck Driver Time Card',
        ID = frm_Fleet.LastSubmit.ID
    ),
    {
        'Driver Name': {
            Id: varDriver.ID,
            Value: varDriver.'Full Name'
        },
        'Vehicle Type': {
            Id: varVehicleType.ID,
            Value: varVehicleType.'Vehicle Type'
        },
        Vehicle: {
            Id: varVehicle.ID,
            Value: varVehicle.'Vehicle Details'
        }
    }
);
Notify(
    "Form Submitted Successfully!",
    NotificationType.Success
);
ResetForm(frm_Fleet);
Navigate(scr_Fleet_Main);
Set(varDriver, Blank());
Set(varVehicleType, Blank());
Set(varVehicle, Blank()
);
I have the same question (0)
  • Suggested answer
    abc 123 Profile Picture
    784 Moderator on at
    Patch
    First, look for obscure things like a Required field in the list that you're not populating.  (I have to imagine the Driver and Vehicle would be required to enter a time card.) If you need to default the Driver and Vehicle, do that on the form, and let the Update property of the Card do the work.
     
    Second, you're trying to save from variables, but I don't know enough about their population method to discuss. Feel free to clarify.
     
    Next, use IfError to trap for errors to help with debugging.
     
    UpdateContext({strErrMsg: "None"});
    IfError(
      Patch(...whatever...),
      UpdateContext({strErrMsg: FirstError.Message});
    );
    If(strErrMsg <> "None",
       //Show the error
       Notify(strErrMsg),
      //Do non-error stuff
      ...
    );
     
    Finally, your Vehicle list should already have the Vehicle Details, so to add this to the TimeCard is redundant and unnecessarily redundant. Consider restructuring to eliminate the need for this data. (Research Boyce-Codd Normalization if you need more information about building a proper Entity Relationship.)
     
  • WarrenBelz Profile Picture
    151,271 Most Valuable Professional on at
    Patch
    I suspect the fundamental issue will be the content of varDriver, varVehicle and varVehicleType. You are (I assume) patching to Lookup columns in SharePoint (they honestly are a waste of time and cause nothing but unnecessary complexity - I never use them), so the essential element you require is that the ID column of the Variable contains the ID of the relevant value being looked up in the other list.
    So the question is how and when are you setting these Variables ?
  • bB-27090143-0 Profile Picture
    51 on at
    Patch
    Thank you
     
    can I ask what you suggest - I’m new to power apps
     
    form is frm_fleet
     
    sharepoint list trying to update with form is Truck driver time card SharePoint list
     
    field in power apps:
     
    driver name field coming from employee lost
    Vehicle type  vehicle list
    vehicle coming from vehicle list this is to allow filtering vehicle by drop down in vehicle list
    all other fields coming from truck driver time card SharePoint list
     
     
    Thanks for any help
     
  • Suggested answer
    Michael E. Gernaey Profile Picture
    50,796 Super User 2025 Season 2 on at
    Patch
    Hi
     
    So you have 2 possible things
     
    1) That your LookUp is returning NO row and therefor it updates nothing
     
    2) that your variables are bad and have no data, BUT if that's the case, I would expect that in the SharePoint List, the values would be blank.
     
    3) Lookup columns are garbage, never use them, like ever, no matter who tells you they rock they do NOT. Simply map the ID of the Row in the other table into this table, and then if you have to, do a lookup to pull its value. In your code, you could simply do a lookup to the other table, even in what you have to set the LookUp value, versus trying to do it like a record. Again.... they... are ... horrible... never... use them...

    So I believe its #1 not #2.
     
    So how do you validate this first.
     
    Change your code to do this
    What this will do is first pull back the record IF there is one that you want to patch.
    If its there then it will patch, and it will TELL you that it was in the Patch section of the IsBlank check
    If its Not there, meaning your LookUp didnt find a record, then it will tell you that.
     
    then we can figure out why your fmr_Fleet.LastSubmit.ID is bad.
    With(
        {TimeCardRecord: LookUp('Truck Driver Time Card', ID = frm_Fleet.LastSubmit.ID)  },
    
        If(!IsBlank(TimeCardRecord),
    	Patch('Truck Driver Time Card',LookUp('Truck Driver Time Card', ID = frm_Fleet.LastSubmit.ID),
           		{
            	'Driver Name': {
              	  	Id: varDriver.ID,
              	  	Value: varDriver.'Full Name'
              		},
              	'Vehicle Type': {
                		Id: varVehicleType.ID,
                		Value: varVehicleType.'Vehicle Type'
               		},
               	Vehicle: {
                   		Id: varVehicle.ID,
                   		Value: varVehicle.'Vehicle Details'
                		}
             	}
             );
        
    	  Notify("Form Submitted Successfully!",NotificationType.Success);
    	  ResetForm(frm_Fleet);
    	  Navigate(scr_Fleet_Main);
    	  Set(varDriver, Blank());
    	  Set(varVehicleType, Blank());
    	  Set(varVehicle, Blank());
        ,
           Notify("ID was Blank so record returned from LookUp")
        )    
    );
    
    
    
     
     
  • bB-27090143-0 Profile Picture
    51 on at
    Patch
    Ok the patch error I am getting is the Id is blank cannot proceed with blank but I have a column id populating each time numerically
     
    Should I recreate this list as it might be buggy or any other solutuons?
     
    Thanks again for help
  • WarrenBelz Profile Picture
    151,271 Most Valuable Professional on at
    Patch
    Can you please answer the specific question I asked - how and when are you setting these Variables - the problem I believe is exactly what I assumed - the ID in the Variables needs to be the ID of the record being looked up in the other list and now you are confirming it is blank.
  • bB-27090143-0 Profile Picture
    51 on at
    Patch
    HI there
     
    Setting Variables in "on success" of submit button
     
    Set(varDriver,DataCardValue14.Selected);
    Set(varVehicleType, DataCardValue45.Selected);
    Set(varVehicle,DataCardValue44.Selected);
    SubmitForm(frm_Fleet);
    ResetForm(frm_Fleet)
  • WarrenBelz Profile Picture
    151,271 Most Valuable Professional on at
    Patch
    Have you had a look in the Variables to see what they contain ?
  • bB-27090143-0 Profile Picture
    51 on at
    Patch
    Apologies, Ive tried mapping the fields but that didnt work either...sorry I am a noob at this
     
    im still getting the ID error not found - thats ok im sorry to waste time
     
    Patch(
        'Truck Driver Time Card',
        LookUp(
            'Truck Driver Time Card',
            ID = frm_Fleet.LastSubmit.ID
        ),
        {
            'Driver Name': {
                Id: varDriver.ID,
                Value: varDriver.field_3
            },
            'Vehicle Type':
            {
                Id: varVehicleType.ID,
                Value: varVehicleType.field_1
            },
            'Vehicle':
            {
                Id: varVehicle.ID,
                Value: varVehicle.field_6
            }
        }
    );
    Notify(
        "Form submitted successfully!",
        NotificationType.Success
    );
    ResetForm(frm_Fleet);
     
    Navigate(scr_Fleet_Main);
    Set(varDriver, Blank());
    Set(varVehicleType, Blank());
    Set(varVehicle, Blank());
  • WarrenBelz Profile Picture
    151,271 Most Valuable Professional on at
    Patch
    OK - I see the issue, but this is getting even more complicated because you are using Lookup fields (please heed the advice I gave which was even more accentuated by FLMike - throw them away and use Text fields).
    Your problem is that not only have you used Lookup fields, but then changed the Items of the drop-downs from the default Choices(ListName.FieldName), which would have given you your Id field. You have also created your List from Excel, which gives you the underlying field name syntax of field_x and will cause you more confusion in the future (but this is unrelated to your current problem).
    If you want your Id values back you would need to do something like this
    Set(
       varVehicleType, 
       {
          Value: DataCardValue45.Selected.field_1,
          Id: 
          LookUp(
             YourLookupUpListName,
             YourLookedUpFieldName = DataCardValue45.Selected.field_1,
          ).ID
       }
    )
    but honestly you are far better (it is good to learn good habits from the start) changing them to Text columns and simply using
    Set(
       varVehicleType, 
       DataCardValue45.Selected.field_1
    )
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee

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…

Tom Macfarlan – Community Spotlight

We are honored to recognize Tom Macfarlan as our Community Spotlight for October…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 829 Most Valuable Professional

#2
developerAJ Profile Picture

developerAJ 570

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 403 Super User 2025 Season 2

Last 30 days Overall leaderboard