Skip to main content

Notifications

Power Apps Pro Dev & ISV
Suggested answer

Patch

Posted on by 2
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()
);
  • bB-27090143-0 Profile Picture
    bB-27090143-0 2 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
    WarrenBelz 141,122 on at
    Patch
    Have you had a look in the Variables to see what they contain ?
  • bB-27090143-0 Profile Picture
    bB-27090143-0 2 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
    WarrenBelz 141,122 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
    bB-27090143-0 2 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
  • Suggested answer
    FLMike Profile Picture
    FLMike 26,301 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
    bB-27090143-0 2 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
     
  • WarrenBelz Profile Picture
    WarrenBelz 141,122 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 ?
  • Suggested answer
    abc 123 Profile Picture
    abc 123 358 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.)
     

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

September 2024 Newsletter…

September 2024 Community Newsletter…

Community Update Sept 16…

Power Platform Community Update…

Welcome to the new Power Platform Community!…

We are excited to announce our new Copilot Cookbook Gallery in the Community…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 141,122

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,414

Leaderboard