cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Vino_
New Member

Patch to Sharepoint

Hi All,

I am trying to build application where I can patch data from PowerApps to SharePoint on job progress.

Any help is highly appreciated.

The application intention is very simple to make a production output entries, when we register 1st time a batch no, product, equipment ,process with start time - it creates a new registry. then when we patch again, it finds the previous start registry and enters the finish time.

and to create multiple registry for the same process the same day.  

Can you suggest me what should I improve in my formula? to get such result.

Any help is highly appreciated.

2.JPG

Start & Finish time in PowerApps has this code on text filter 

glbRo.Start
glbRo.Finish

with this code it is not updating the finish time either on the SharePoint or on the app

 

6.JPG

Button on select property was this

 

With({dataItem:   // Your Record
    LookUp(SortByColumns(Test_MDP, "Start", Descending), 
        Product = Process_dropdown.Selected.Value && 
        Equipment= Equipment_dropdown.SelectedText.Value &&
        Process = Process_dropdown.SelectedText.Value &&
        Batchno = Batchno_Textinput.Text
    )},
    With({newTrue:   // Your criteria for a new record
        (IsBlank(dataItem.Start) && IsBlank(dataItem.Finish)) || 
        (!IsBlank(dataItem.Start) && !IsBlank(dataItem.Finish))
    },

        // Your Patch to the DataSource
        Set(glbRo,
            Patch(Test_MDP,
                If(newTrue, Defaults(Test_MDP), dataItem),
                    {    Product : Product_dropdown.SelectedText.Value,
                         Equipment:Equipment_dropdown.SelectedText.Value,
                         Process : Process_dropdown.SelectedText.Value,
                         Batchno : Batchno_Textinput.Text
                    },
                    If(newTrue, {Start:Now()}, {Finish:Now()})
                )
            )
        )
    ) 

 

when i use this code i am not getting the finished time updated after lookup on the same registry.

instead i see i get new registry with start time as new line

7.JPG

Any help is highly appreciated. Thanks in advance.

3 REPLIES 3
C-Papa
Super User
Super User

Hi, if you change If(newTrue, Defaults(Test_MDP), dataItem), to {ID: dataItem.ID}, if the ID exists it will update it, if it doesn't it will add it as a new record. 

Vino_
New Member

Hi @C-Papa & All,

 

I tried to use this code, but still it din't work and i got some new error on Start & Finish columns in powerapps. It stopped showing the registered time on app. & in sharepoint it is still registering as a new line for every single patch.

Start & Finish time in PowerApps has this code on text filter

glbRo.Start
glbRo.Finish

8.JPG9.JPG New code used is here

With({dataItem:   // Your Record
    LookUp(SortByColumns(Test_MDP, "Start", Descending), 
        Product = Process_dropdown.Selected.Value && 
        Equipment= Equipment_dropdown.SelectedText.Value &&
        Process = Process_dropdown.SelectedText.Value &&
        Batchno = Batchno_Textinput.Text
    )},
    With({newTrue:   // Your criteria for a new record
        (IsBlank(dataItem.Start) && IsBlank(dataItem.Finish)) || 
        (!IsBlank(dataItem.Start) && !IsBlank(dataItem.Finish))
    },

        // Your Patch to the DataSource
        Set(glbRo,
            Patch(Test_MDP,
               {ID: dataItem.ID},
                    {    Product : Product_dropdown.SelectedText.Value,
                         Equipment:Equipment_dropdown.SelectedText.Value,
                         Process : Process_dropdown.SelectedText.Value,
                         Batchno : Batchno_Textinput.Text
                    },
                    If(newTrue, {Start:Now()}, {Finish:Now()})
                )
            )
        )
    ) 

Any help is highly appreciated. 

C-Papa
Super User
Super User

I'm not sure if With is the correct function for this. its difficult to tell without seeing all of you application. also, sort isn't required as LookUp only returns one item - there is nothing to sort.  try the below as this is how i would do it. 

 

Set(dataItem,LookUp(Test_MDP,Product = Process_dropdown.Selected.Value && Equipment= Equipment_dropdown.SelectedText.Value && Process = Process_dropdown.SelectedText.Value && Batchno = Batchno_Textinput.Text))

 

;Set(newTrue, IsBlank(dataItem.Start) && IsBlank(dataItem.Finish) || !IsBlank(dataItem.Start) && !IsBlank(dataItem.Finish))


;Set(glbRo, Patch(Test_MDP, {ID: dataItem.ID}, {Product : Product_dropdown.SelectedText.Value,
Equipment:Equipment_dropdown.SelectedText.Value, Process : Process_dropdown.SelectedText.Value,
Batchno : Batchno_Textinput.Text},If(newTrue, {Start:Now()}, {Finish:Now()}))

i would separate these 3 formulas into 3 buttons to make sure each one works individually and then press them all in order. you need to make sure that dataItem is returning a record to allow the patch to work

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,950)