cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
thatakke
Helper II
Helper II

Patch last created item stopped working

Hello,

 

I'm going crazy as I cannot figure out why my app has suddenly stopped working. My app collects data from people and then patches to a SP list. There are 4 separate forms, 3 of them are used for collecting data, 1 shows the collected data as a summary where people can make final changes before submitting. So, I have 2 separate buttons that patch the data. My summary form button works, but for some reason, despite working last week, my other button stopped working. It doesn't patch any data at all. I'm using a variable "LastCreatedID" to identify whether a user is already in the list or not. Here is the button function that's not working. 

 

Set(
        LastCreatedID,
        Patch(
            'SP List',
            If(
                IsBlank(LastCreatedID),
                Defaults('SPList'),
                LookUp(
                    'SPList',
                    ID = LastCreatedID
                )
            ),
            {
            'Name of the Person': appuser.FullName,
            Job: JobTitle.Text,
            'Official email address': appuser.Email,
           //There are around 20 fields that are used for patching data to SP
        },
        ProfileForm.Updates,
        WorkForm.Updates,
        SkillForm.Updates,
//These are the forms I use for collecting data
        SummaryForm.Updates//This is the form that I use for showing a summary
        ).ID
    )

 What is wrong with my function that it stopped working? As I mentioned, it's not patching any of the fields. 

Thanks,

8 REPLIES 8
StalinPonnusamy
Community Champion
Community Champion

Hi @thatakke 

 

  • Do we need individual forms to submit if Summary has all the fields?
  • Create and Updating not working?
  • We may need to update the Summary form submission once the previous forms are submitted successfully

 

Thanks @StalinPonnusamy as always you are the real MVP 🙂 to answer your questions:

- I actually preferred separating the forms to enhance the data collection experience, each form collects certain information about specific themes; personal life, work life, previous experiences etc. Technically, you are right, 1 form (the summary form) could've been enough, but I think this was a better user experience.

- If you remember, it's my first app, so I'm not sure what is create and updating, can you elaborate?

- Weirdly enough, the summary form and the button on the summary form is the only ones that actually work. I'm not sure if I need to update the summary form. As a test, I created a test button on the very first form that patches all the fields in the first form, but still no luck. It's extremely frustrating, as I said, I did not touch the app at all. I'm not sure what's going wrong here. Happy to provide more details!

 

Thanks!

 

 

 

StalinPonnusamy
Community Champion
Community Champion

Hi @thatakke 

 

The first time is Create and the subsequent time updates.

 

Does this application is creating a record but not updating? Or Even a first time, this is not working?

 

For troubleshooting, Set the Notification OnSucess property of the Summary Form

Notify("Form Saved Succesfully")

 

Set OnFailure Property of the SummaryForm to

 If(
     !IsEmpty(Errors('SPList')),
     Notify(
         Concat(Errors('SPList'), Column&": "&Message),
         NotificationType.Error
     )
 )

 

thatakke
Helper II
Helper II

Thanks @StalinPonnusamy 

 

My test button patches the fields that I'm automatically gathering (I have an appuser function to gather User() details), the rest of the fields are not patched, so I'm not sure what's not working. I'm afraid your OnFailure function did not give any type of notification, I assume it's because technically there is no error?

 

In my test, I figured out if I remove the "Updates" functions in my forms from my patch function, it works. What I don't understand is why? My app has been collecting data without any issues, suddenly stopped working and I'm only now realising removing ".updates" from my forms helps with my issue. I added these after your suggestion in another post, do you have any ideas?

 

Thanks,

StalinPonnusamy
Community Champion
Community Champion

Hi @thatakke 

 

We try to separate the Patch and form Updates.

 

Set(
        ItemCreatedOrUpdated,
        Patch(
            'SP List',
            If(
                IsBlank(LastCreatedID),
                Defaults('SPList'),
                LookUp(
                    'SPList',
                    ID = LastCreatedID
                )
            ),
            {
            'Name of the Person': appuser.FullName,
            Job: JobTitle.Text,
            'Official email address': appuser.Email,
           //There are around 20 fields that are used for patching data to SP
        }
        )
);

If(
     !IsEmpty(Errors('SPList')),
     Notify(
         Concat(Errors('SPList'), Column&": "&Message),
         NotificationType.Error
     ),
Set(LastCreatedID, ItemCreatedOrUpdated.ID);
Patch(
            'SP List',
        ItemCreatedOrUpdated,
        ProfileForm.Updates,
        WorkForm.Updates,
        SkillForm.Updates,
        SummaryForm.Updates//This is the form that I use for showing a summary
        )
 )

 
Thanks,
Stalin - Learn To Illuminate

Hi @StalinPonnusamy 

 

Thanks for your answer. Before I go on with implementing your suggestion, I would like to verify something. According to your formula, there will be two separate variables: 

ItemCreatedOrUpdated

and my current one, 

LastCreatedID

 

I'm a little confused how they will interact with one another. Can you elaborate before I move on?

 

Many thanks,

 

I introduced a new variable to reduce the code.

 

ItemCreatedOrUpdated - Full Record
LastCreatedID - Just ID (Unique)

 

In the second patch condition instead of using 

If(
                IsBlank(LastCreatedID),
                Defaults('SPList'),
                LookUp(
                    'SPList',
                    ID = LastCreatedID
                )
),

Simply using 

ItemCreatedOrUpdated

 Still, LastCreatedID should have a valid ID to use for any other screen.

 


Thanks,
Stalin - Learn To Illuminate

StalinPonnusamy
Community Champion
Community Champion

Hi @thatakke 


Please let us know if anything needs on your post. We can help with this.

Please mark the post as Solved If I have answered your question.
Please give it a Thumbs Up if you find the suggestion helpful

Thanks,
Stalin - Learn To Illuminate

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,554)