web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / patch() not add all fi...
Power Apps
Unanswered

patch() not add all fields when creating new item and does not change existing item

(0) ShareShare
ReportReport
Posted on by 14

so i want to do

if items in sharepoint list -> add the current quantity+ arrived items quantity

if items not in sharepoint list -> create new item.

this is what i have

Set(arrivedItem,
LookUp('inventory obat,makanan,vitamin', Title = ProductNameDOCText.Text));
If(
IsBlank(arrivedItem),
Patch('inventory obat,makanan,vitamin', Defaults('inventory obat,makanan,vitamin'), {Title:ProductNameDOCText.Text,jumlah:First(DOCRecord).jumlah,hargabeli:First(DOCRecord).hargabeli}),
Patch('inventory obat,makanan,vitamin', arrivedItem, {Title:ProductNameDOCText.Text,jumlah:Value(jumlahbeliDOCText.Text)+arrivedItem.jumlah,hargabeli:Value(hargaBeliDOCText.Text)}));

but i only got the title added to my sharepoint list, not the whole fields. does anyone know why?

Categories:
  • Nogueira1306 Profile Picture
    7,390 Super User 2024 Season 1 on at

    To see why it only created the title, check if the other fields are empty. For example, this:

    First(DOCRecord).jumlah

     

    might be empty.. We don´t know for sure. 
    To create the item, I've only changed the lookup. 

    Set(arrivedItem,LookUp('inventory obat,makanan,vitamin', Title = ProductNameDOCText.Text));
    If(
    IsBlank(arrivedItem),
    Patch('inventory obat,makanan,vitamin', 
    Defaults('inventory obat,makanan,vitamin'), {
    Title: ProductNameDOCText.Text,
    jumlah: First(DOCRecord).jumlah,
    hargabeli: First(DOCRecord).hargabeli
    }),
    Patch('inventory obat,makanan,vitamin', 
    LookUp('inventory obat,makanan,vitamin', Title = ProductNameDOCText.Text), 
    {Title: ProductNameDOCText.Text,
    jumlah: Value(jumlahbeliDOCText.Text)+ arrivedItem.jumlah,
    hargabeli: Value(hargaBeliDOCText.Text)})
    );

     If you need additional help please tag me in your reply and please like my reply.
    If my reply provided you with a solution, pleased mark it as a solution ✔️!

    Best regards,
    Gonçalo Nogueira

    Check my LinkedIn!

    Check my User Group (pt-PT)!

    Last Post on Community

    My website!

  • shoog Profile Picture
    2,164 on at

    Why don't you take the amount and price from the same entry fields as for existing records?

    It would seem you could change the patch for new items to be similar to the existing items like:

    Patch('inventory obat,makanan,vitamin', Defaults('inventory obat,makanan,vitamin'), {Title:ProductNameDOCText.Text,jumlah:Value(jumlahbeliDOCText.Text),hargabeli:Value(hargaBeliDOCText.Text)})

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 405 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 368

#3
WarrenBelz Profile Picture

WarrenBelz 244 Most Valuable Professional

Last 30 days Overall leaderboard