Skip to main content

Notifications

Power Apps - Building Power Apps
Suggested answer

"Invalid argument type. can not use boolean in this Context" inside OnOkClick inside a Component

Like (1) ShareShare
ReportReport
Posted on 20 Sep 2024 14:38:25 by 1,388
I want to build a reusable popups as mentioned in this link https://www.youtube.com/watch?v=SfxNHYvCgcw&pp=ygUhcmV1c2FiZWwgcG9wdXBzIGluc2lkZSBwb3dlciBhcHBz , using the "Enhanced components" feature:-
 
 
So, I have  created a component library inside a solution, with 3 properties, 2 of them of type Event (named OnOkClick & OnOkCancel), as follow:-
 
 
 
 
Then inside the "Custom Properties" >> "OnOKclick", i added this formula, which mainly do some checks and delete the items:-
 
ClearCollect(
    varWOWOInfoDetails,
    Filter(
        'Work Orders Work Order Info Details',
        'Work Order ID' = DashBoardGallery_1.Selected.ID
    )
);
ClearCollect(
    varWOSP,
    Filter(
        'Work Orders Spare Parts',
        'Work Order ID' = DashBoardGallery_1.Selected.ID
    )
);
 
ForAll(varWOSP As wosp,
Collect(
    varWOSPWOSPAPP,
    Filter(
        'Work Order Spare Parts Work Order Spare Part Approvals',
        'Work Order Spare Part ID' = wosp.ID
    )
));
 
IfError(RemoveIf(
    'Work Orders',
        ID = DashBoardGallery_1.Selected.ID
),
Notify(
    "Can not delete work order",
    NotificationType.Error
),
ForAll(varWOWOInfoDetails As wowo,
RemoveIf('Work Orders Work Order Info Details',ID=wowo.ID);
RemoveIf('Work Orders Info Details',ID=wowo.'Work Order Info Detail ID')
 
);
ForAll(varWOWOInfoDetails As wowo,
 
RemoveIf('Work Orders Info Details',ID=wowo.'Work Order Info Detail ID');
RemoveIf('Work Orders Work Order Info Details',ID=wowo.ID);
);
 
ForAll(varWOSP As wosp,
 
RemoveIf('Work Orders Spare Part Details','Work Order Spare Part ID'=wosp.ID)
 
);
 
ForAll(varWOSPWOSPAPP As wospwoapp,
 
RemoveIf('Work Orders Spare Part Approvals',ID=wospwoapp.'Work Order Spare Part Approval ID');
 
);
ForAll(varWOSPWOSPAPP As wospwoapp,
 
RemoveIf('Work Order Spare Parts Work Order Spare Part Approvals',ID=wospwoapp.ID);
 
);
 
ForAll(varWOSP As wosp,
 
RemoveIf('Work Orders Spare Parts',ID=wosp.ID);
 
);Notify(
    "Deleted successfully",
    NotificationType.Success
););
 
UpdateContext({showPopup: false});
Set(selectedID,DashBoardGallery_1.Selected.ID);
Set(
    selectedID,
    Blank()
);
Set(
    varPrintProcessID,
    Blank()
);
Set(
    varPrintProcessPrintOrder,
    Blank()
);
Set(
    varPostingUnPotingProcess,
    Blank()
);
Set(
    varPostingUnPotingProcessPostingUnPostingForms,
    Blank()
);
 
 
but on the first semi-colon i get this error:-
 
 
here is the error:-
 
 
also despite this error the code is working on Test environment and partially working on PROD.. so what is causing this error?
  • johnjohnPter Profile Picture
    johnjohnPter 1,388 on 20 Sep 2024 at 18:43:30
    "Invalid argument type. can not use boolean in this Context" inside OnOkClick inside a Component
    But why i need to return a boolean? i did not get the point exactly? Thanks
  • Suggested answer
    FLMike Profile Picture
    FLMike 27,286 on 20 Sep 2024 at 14:53:00
    "Invalid argument type. can not use boolean in this Context" inside OnOkClick inside a Component
    Hi
     
    If you created a function or action or event that is supposed to RETURN a Boolean then you need too(at the end of your code end of it, not where its showing you the error), add it to the end.
     
     
    literally just add
     
    true
     
    or 
     
    false
     
    at the end.
     

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

End of Year Newsletter…

End of Year Community Newsletter…

Tuesday Tip #12 Start your Super User…

Welcome to a brand new series, Tuesday Tips…

Tuesday Tip #11 New Opportunities…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 144,654

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,440

Leaderboard
Loading started