cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dianhudayahr
Helper I
Helper I

Patch with Lookup Validation in SP List

Hi Everyone,

I am going to build inspection report.
I have  submit Button (Checking). the purpose is to checking and patch data based on lookup.

So i have detail as below:

SP List : inspection production ->> inside SP list, i have column as below.
Column name : incomingID ->> for lookup data (checking)
Column Name  : Batch ->> for store data if lookup data (checking) value is true

in my case, i want to patch and validate the data with lookup. And also if data incoming ID not found or (No Exist Exactly) it supposed to be appear/notify error information.
the code as below.

 

 

If(
    IsEmpty(
        Errors(
            'Inspection Production',
            Patch(
                'Inspection Production',
                LookUp(
                    'Inspection Production',
                    'Incoming ID' = Value(LabelIncomingID.Text)
                ),
                {Batch: LabelMS_Batch.Text}
            )
        )
    ),
    Notify(
        "Data has been successfuly Update",
        NotificationType.Success
    ),
    Notify(
        "Incoming ID Not Found In SP List",
        NotificationType.Error
    )
);

 

 

 

For now, the code is work. But if lookup no found "Incoming ID". they don't show information error message. 
So i need advice to correct fault code.

Thank you very much.

 

9 REPLIES 9
WarrenBelz
Super User III
Super User III

Hi @dianhudayahr ,

I think this is what you are trying to do

Patch(
   'Inspection Production',
   {'Incoming ID':Value(LabelIncomingID.Text)},
   {Batch: LabelMS_Batch.Text}
);
If(
   IsEmpty(Errors('Inspection Production')),
    Notify(
      "Data has been successfully updated",
      NotificationType.Success
   ),
   Notify(
      "Incoming ID Not Found In SP List",
      NotificationType.Error
   )
)

 

Please click Accept as solution 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 Thumbs Up.

Hi @WarrenBelz 

thank you for your quick response,

But, i want to patch item based on my lookup.

Patch(
                'Inspection Production',
                LookUp(
                    'Inspection Production',
                    'Incoming ID' = Value(LabelIncomingID.Text)
                ),
                {Batch: LabelMS_Batch.Text}
            )


and then showing error information if in list 'inspection production' -> incoming ID doesn't have value.

I need your advice.

 

Thank you very much.



Hi @dianhudayahr ,

You do not need the Lookup - the syntax I gave you does the same thing - I was addressing the error issue (which I thought was your problem).

 

Please click Accept as solution 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 Thumbs Up.

Hi @WarrenBelz 

i was trying your code.
I still looking for lookup, because in 'inspection production' already data which must be equalize.
if match, posting batch in the same ID,
but if do not match, show the error message.

that the code i build above, it always show TRUE..

Please I need your advice again.

regards,





@dianhudayahr ,

Keep with the lookup if you are more comfortable with it - it works the same as this

{'Incoming ID':Value(LabelIncomingID.Text)}

as you are simply asking Patch to update the record that matches this.

So taking a step back, if you just do the Patch (without the error trap, does the Patch work?

 

Please click Accept as solution 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 Thumbs Up.

hi @WarrenBelz 


Good Morning,

if you just do the Patch (without the error trap, does the Patch work?
perhaps the patch work but don't update anything because criteria 'Incoming ID' not match, and the notification message its always show success not the error.

as you can see update my code below.

 

Patch(
    'Inspection Production',
    LookUp(
        'Inspection Production',
        'Incoming ID' = Value(LabelIncomingID.Text)
    ),
    {Batch: LabelMS_Batch.Text}
);
If(
    !IsEmpty('Inspection Production'),
    Notify(
        "Data has been successfully updated",
        NotificationType.Success
    ),
    Notify(
        "Incoming ID Not Found In SP List",
        NotificationType.Error
    )
);

 


Im still struggle, how to find notify error message if lookup condition not match with the criteria..

Regards,

@dianhudayahr ,

I meant only the Patch code - does this work as expected?

Patch(
    'Inspection Production',
    {'Incoming ID':Value(LabelIncomingID.Text)},
    {Batch: LabelMS_Batch.Text}
)

 

Please click Accept as solution 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 Thumbs Up.

Mr @WarrenBelz 

 

Yes Sir,
For the patch only.

I try to find something idea to this case patch with lookup. 

Regards,

@dianhudayahr ,

As mentioned before, this code

{'Incoming ID':Value(LabelIncomingID.Text)}

does exactly the same thing as your Lookup (you do not need the lookup) - are you confirming that the patch works - if so how are you testing for the error as if the patch works, there will be no error.

 

Please click Accept as solution 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 Thumbs Up.

 

 

 

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 (3,049)