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!
Solved! Go to Solution.
Hi CNT
Not yet. I think I need to rethink my approach. Maybe not start with CountIf? What I am trying to do is check if a record exist in the collection with the argument fkAssetID and fkDefectID.
If it does, I would update that record, if not add new.
What if I just delete the record and add my new value each time an update or add new is triggered?
Have a great day!
Jomar
The error starts with Patch...
Red line from Patch to end of the code. Saying Patch has invalid arguments?
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. 😞
@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.
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?
Hi CNT
Does Patch work for Collections???
Thank you.
@JomarGF Are the datatypes of fkAssetID & fkDefectID matching with iAssetID & ThisItem.DefectID.
Did you try to hardcode some value and see?
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
191 | |
65 | |
46 | |
35 | |
25 |
User | Count |
---|---|
240 | |
108 | |
89 | |
86 | |
64 |