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 / Please help spot the e...
Power Apps
Answered

Please help spot the error

(0) ShareShare
ReportReport
Posted on by 115

Hi All

 

Please help me spot the error in the following code:

 

If(
CountIf(
collDefectsList,
fkAssetID = iAssetID,
fkDefectID = ThisItem.DefectID
) > 0,
Patch(
collDefectsList,
LookUp(
collDefectsList,
fkAssetID = iAssetID && fkDefectID = ThisItem.DefectID
),
{
DTStamp: Now(),
fkAssetID: iAssetID,
fkDefectID: ThisItem.DefectID
}
),
Patch(
collDefectsList,
Defaults(collDefectsList),
{
DTStamp: Now(),
fkAssetID: iAssetID,
fkDefectID: ThisItem.DefectID
}
)
);

 

Thank you in advance!

Categories:
  • JomarGF Profile Picture
    115 on at

    The error starts with Patch...

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @JomarGF what is the error? 

  • JomarGF Profile Picture
    115 on at

    Red line from Patch to end of the code. Saying Patch has invalid arguments?

     

      

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @JomarGF you're using ThisItem.DefectID

    What is ThisItem referring to? 

  • JomarGF Profile Picture
    115 on at

    Hi CNT

     

    ThisItem.DefectID is from the gallery where I select the defect desc + defectID. I tried taking out ThisItem.DefectID and the issue persists. 😞 

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @JomarGF In the If you have 2 Patch statements ( 1 in the If part and the other in the else part). To isolate the error could you just remove one and see which Patch has the problem.

  • JomarGF Profile Picture
    115 on at

    Hi CNT

     

    Thank you for your reply.

     

    I took out the values inside the brackets and the redline disappears! (see screenshot). What do you think is the issue?

     

    Capture.JPG

  • JomarGF Profile Picture
    115 on at

    Hi CNT

     

    Does Patch work for Collections???

     

    Thank you.

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @JomarGF Are the datatypes of fkAssetID & fkDefectID matching with iAssetID & ThisItem.DefectID.

    Did you try to hardcode some value and see?

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @JomarGF For sure they do.

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 397 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 354

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard