Skip to main content

Notifications

Power Apps - Building Power Apps
Unanswered

Patch & Update Function

Posted on by 372

Hi,

 

I have this logic:

firda59_0-1701930654826.png

I get value in ComboBox using defaultsiselecteditem from SP list 2, and Item using ["aaaa", "bbbb", "cccc"].

 

I want if:

1. Value from SP list 2 already exists in ComboBox, then just update the data 
2. I just add new value in combobox with that item, then patch new data

3. if combobox still blank, then just dont patch/update

 

 

I used this formula, not error but cant work.

Formula:

ForAll(
UpdateDocument_1.AllItems,
If(
IsBlank(
First(
Filter(
'PE Workload',
'Job Description' = JobDesc_Update.Text
)
).'Task (Task0)'
),
// If 'Task (Task0)' is blank, then patch data
Patch(
'PE Workload',
Defaults('PE Workload'),// You may need to adjust this based on your list structure
{
'Job Description': JobDesc_Update.Text,
'Task (Task0)': Task_2.Text,
PIC: Text(PIC_PE_2.Selected.Value),
Title: ProductID_Update.Text,
Customer: Customer_Update.Text,
'% Progress': 0
// Add other fields as needed
}
),
// If 'Task (Task0)' is not blank, then update data
UpdateIf(
'PE Workload',
'Job Description' = JobDesc_Update.Text && 'Task (Task0)' = Task_2.Text,
{
PIC: Text(PIC_PE_2.Selected.Value)
// Add other fields as needed
}
)
)
)

 

 

How to do it? Thank you!!!

  • firda59 Profile Picture
    firda59 372 on at
    Re: Patch & Update Function

    Hi @Rajkumar_404 ,

     

    I try that formula but cant work, so I modify, and I got this formula:
    ForAll( UpdateDocument_1.AllItems,
    If(IsBlank(PIC_PE_2.Selected.Value),
    {},
    If(LookUp('PE Workload','Job Description' = JobDesc_Update.Text,'Task (Task0)') = Task_2.Text,
    UpdateIf('PE Workload','Job Description' = JobDesc_Update.Text && 'Task (Task0)' = Task_2.Text,{'Task (Task0)': Task_2.Text,PIC: Text(PIC_PE_2.Selected.Value)}),
    Patch('PE Workload',Defaults('PE Workload'),{'Job Description': JobDesc_Update.Text,'Task (Task0)': Task_2.Text,PIC: Text(PIC_PE_2.Selected.Value),Title: ProductID_Update.Text,Customer: Customer_Update.Text,'% Progress': 0}))))

     

    I can update data, I can skip update/patch the data if combobox blank, but for patch function, It will patch all data again which combobox not blank. So there are double data. Do you know how to fix it? Thankyou!

  • Rajkumar_404 Profile Picture
    Rajkumar_404 6 on at
    Re: Patch & Update Function

    Hi @firda59 

     

    Try this formula,

     

    If( 
    IsBlank(ComboBox1.Selected.Value), /* If ComboBox is blank, do nothing */,
    If(
    IsEmpty(
    Filter(
    'PE Workload',
    'Job Description' = JobDesc_Update.Text && 'Task (Task0)' = Task_2.Text)), /* If Task (Task0) is not found, patch new data */
    Patch(
    'PE Workload', Defaults('PE Workload'),
    {
    'Job Description': JobDesc_Update.Text,
    'Task (Task0)': Task_2.Text,
    PIC: Text(PIC_PE_2.Selected.Value),
    Title: ProductID_Update.Text,
    Customer: Customer_Update.Text,
    '% Progress': 0 /* Add other fields as needed */
    } ), /* If Task (Task0) is found, update data */
    UpdateIf(
    'PE Workload',
    'Job Description' = JobDesc_Update.Text &&
    'Task (Task0)' = Task_2.Text,
    {
    PIC: Text(PIC_PE_2.Selected.Value) /* Add other fields as needed */ } )
    )
    )

     

     

    Thanks!

     

    If my response has been helpful in resolving your issue, I kindly request that you consider clicking "Accept as solution" and "giving it a thumbs up" as a token of appreciation.

     

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 #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,246

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,884

Leaderboard