Skip to main content

Notifications

Power Apps - Power Apps Pro Dev & ISV
Suggested answer

Patch

Like (1) ShareShare
ReportReport
Posted on 4 Oct 2024 10:53:30 by 30
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()
);
  • WarrenBelz Profile Picture
    WarrenBelz 144,479 on 19 Oct 2024 at 01:17:56
    Patch
    Just following up to see if you received the answer you needed, or if you require further assistance.

    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
  • WarrenBelz Profile Picture
    WarrenBelz 144,479 on 05 Oct 2024 at 21:09:38
    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
  • bB-27090143-0 Profile Picture
    bB-27090143-0 30 on 05 Oct 2024 at 10:24:43
    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 144,479 on 05 Oct 2024 at 09:41:10
    Patch
    Have you had a look in the Variables to see what they contain ?
  • bB-27090143-0 Profile Picture
    bB-27090143-0 30 on 05 Oct 2024 at 08:08:12
    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 144,479 on 05 Oct 2024 at 07:10:47
    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 30 on 05 Oct 2024 at 05:02:52
    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 29,371 on 05 Oct 2024 at 00:32:22
    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 30 on 04 Oct 2024 at 23:07:11
    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 144,479 on 04 Oct 2024 at 22:13:25
    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 ?

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #9 Get Recognized…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 144,479

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,350

Leaderboard
Loading started
Loading complete