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

Patch data to sharepoint

Hi All,

 

I am trying to build application where i can patch data from Powerapps to sharepoint on job progress.

 

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.

 

2.JPG

 

1.JPG

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

glbR.Start

glbR.Finish

Button onselect 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(glbR,
            Patch(Test_MDP,
                If(newTrue, Defaults(Test_MDP), dataItem),
                Patch(
                    {    Product  = Process_dropdown.Selected.Value,
                         Equipment = Equipment_dropdown.SelectedText.Value,
                         Process = Process_dropdown.SelectedText.Value,
                         Batchno = Batchno_Textinput.Text
                    },
                    If(newTrue, {Start:Now()}, {Finish:Now()})
                )
            )
        )
    ) 
)

but its showing me a lot of error on this program

3.JPG

 

6 REPLIES 6
StalinPonnusamy
Community Champion
Community Champion

Hi @Vino_ 

 

This code is without Start and finish time. First try 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(glbR,
            Patch(Test_MDP,
                If(newTrue, Defaults(Test_MDP), dataItem),                
                    {    Product : Process_dropdown.Selected.Value,
                         Equipment : Equipment_dropdown.Selected.Value,
                         Process : Process_dropdown.Selected.Value,
                         Batchno : Batchno_Textinput.Text 
                    }

		) //Patch End
                    
                ) //Set End
            ) //Second With

) //First With

 

 

I believe you are trying Start and Finish time added only a new record. is it correct? Let me know how this works and will add Start and Finish time

Hi,

 

Still its making different line registry, i pressed button 3 times and it made 3 different entry1.JPG

Hi @StalinPonnusamy ,

 

I tried, but it still making 3 different registry when i pressed Button 3 times.

1.JPG

StalinPonnusamy
Community Champion
Community Champion

Hi @Vino_ 

 

I created something similar to your structure and tried.

With(
    {
        dataItem: // Your Record
LookUp(
            SortByColumns(
                Test_MDP,
                "Start",
                Descending
            ),
            Product.Value = Product_dropdown.Selected.Value && Equipment.Value = Equipment_dropdown.Selected.Value && Process.Value = Process_dropdown.Selected.Value && Batchno = Batchno_Textinput.Text
        )
    },
    With(
        {newTrue: // Your criteria for a new record
(IsEmpty(dataItem)) || (IsBlank(dataItem)) || (!IsBlank(dataItem.Start) && !IsBlank(dataItem.Finish))},
        // Your Patch to the DataSource
        Patch(
            Test_MDP,
            If(newTrue, Defaults(Test_MDP), dataItem),
            {
                Product: Product_dropdown.Selected,
                Process : Process_dropdown.Selected,
                Equipment: Equipment_dropdown.Selected,
                Batchno: Batchno_Textinput.Text
            },If(newTrue, {Start:Now()}, {Finish:Now()})
        )//Patch End
    )//Second With
)//First With

 

StalinPonnusamy
Community Champion
Community Champion

Hi @Vino_ 

 

For Reference (If I missed any typo) - Note: Not used process dropdown on this example

StalinPonnusamy_0-1632375300470.png

 

StalinPonnusamy_1-1632375321332.png

 

 

StalinPonnusamy
Community Champion
Community Champion

Hi @Vino_ 

 

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


Please do not forget to give kudos if you find the suggestion helpful or Accept it as a solution if works fine to help other users to find it useful.

 

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