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 / Error when trying to r...
Power Apps
Suggested Answer

Error when trying to retrieve data from the network

(0) ShareShare
ReportReport
Posted on by 4
Dear Team
 
I built a electronic approval apps using power apps,
the code is very simple, check login user email and compare with user is valid user to get started approval flow with current item's approval status.
for example, if 1st approver just approved then the status would be updated as of "approved by 1st approver".
If you're MD and 2nd approver is blank, then status would be updated as of "approved by md" when MD click approve button.
 
somehow, submit -> 1st approver, 1st approver -> 2nd approver or MD is fine but MD approver is not working even though condition is all true.
I just use UpdateIf as below, please check.
 
UpdateIf(
    'Claim/Penalty',
    And(
        Title = VarAppData,
        Trim(Lower(LookUp('Claim/Penalty', Title = VarAppData).'1st_Approver')) = Trim(Lower(UserEmail)),
        LookUp(ColHRAppData, Title = VarAppData).Status.Value = "Submitted"
    ),
    {Status: {Value: "Approved by 1st approver"}},
    And(
        Title = VarAppData,
        Trim(Lower(LookUp('Claim/Penalty', Title = VarAppData, '2nd_Approver'))) = Trim(Lower(UserEmail)),
        LookUp(ColHRAppData, Title = VarAppData).Status.Value = "Approved by 1st approver"
    ),
    {Status: {Value: "Approved 2nd approver"}},
    And(
        Title = VarAppData,
        Trim(Lower(LookUp('Claim/Penalty', Title = VarAppData).MD)) = Trim(Lower(UserEmail)),
        Or(
            LookUp(ColHRAppData, Title = VarAppData).Status.Value = "Approved by 2nd approver",
            And(
                IsBlank(LookUp('Claim/Penalty', Title = VarAppData).'1st_Approver'),
                IsBlank(LookUp('Claim/Penalty', Title = VarAppData, '2nd_Approver')),
                LookUp(ColHRAppData, Title = VarAppData).Status.Value = "Submitted"
            ),
            And(
                IsBlank(LookUp('Claim/Penalty', Title = VarAppData, '2nd_Approver')),
                LookUp(ColHRAppData, Title = VarAppData).Status.Value = "Approved by 1st approver"
            )
        )
    ),
    {Status: {Value: "Approved by MD"}}
);
error.png
Categories:
  • Suggested answer
    abc 123 Profile Picture
    789 Moderator on at
    First, a pet peeve. Naming a variable VarAnything doesn't reflect what is stored in that variable. Consider adopting a more informative naming convention. 
    strFirstName
    dtmBirthday
    intYears
    fltRatio
     
    Next, the use of the And() and Or() functions is archaic, when just a simple And (&&) or Or (||) will do. 
     
    x = 5 And y = 9,  x=5 && y = 9
    x = 5 Or y = 9,     x=5 || y = 9
     
    Getting rid of excessive parenthesis makes the code more readable, and less error prone.
     
    Then, 
    LookUp('Claim/Penalty', Title = VarAppData).'1st_Approver'
     
    Does this need a .Email or .EmailAddress? (What is the column type of the 1st_Approver column. Just Text, or a Lookup or Person column?
     
    Finally, 
    To debug, I'd start with just the first condition. And when I know that it resolves correctly, then introduce the next condition. And keep debugging each one by one, rather than trying to find the one error in the entire swamp.  Or, perhaps break these down to multiple UpdateIf(), such that you can better debug and maintain the code, as this current state is impossible to debug easily... as you've discovered. 
  • ronaldwalcott Profile Picture
    3,914 Moderator on at
    I would hazard a guess, but I have not tested nor ever came across this issue is that using UpdateIf with the final set of conditions is problematic.
    From the documentation
     
    Use the UpdateIf function to modify one or more values in one or more records that match one or more conditions. The condition can be any formula that results in a true or false and can reference columns of the data source by name.
     
    this seems to imply that the condition needs to reference a record in the data source.
    Your condition references records four times 
    Trim(Lower(LookUp('Claim/Penalty', Title = VarAppData).MD)) = Trim(Lower(UserEmail)),
            Or(
                LookUp(ColHRAppData, Title = VarAppData).Status.Value = "Approved by 2nd approver",
                And(
                    IsBlank(LookUp('Claim/Penalty', Title = VarAppData).'1st_Approver'),
                    IsBlank(LookUp('Claim/Penalty', Title = VarAppData, '2nd_Approver')),
                    LookUp(ColHRAppData, Title = VarAppData).Status.Value = "Submitted"
                ),
                And(
                    IsBlank(LookUp('Claim/Penalty', Title = VarAppData, '2nd_Approver')),
     
    Which record or records reference is it going to try to update? Also I think that Or stops evaluating when the condition becomes true.
     
  • ronaldwalcott Profile Picture
    3,914 Moderator on at
    Also UpdateIf probably checks every record. So you are navigating a table while also looking up values in that same table to update when you should be accessing the values just using the column names.
  • AY-10120606-0 Profile Picture
    4 on at
    Dear All 
     
    Thank you for reply.
     
    1. I tried to use "&&" or "||" instead of "And" or "Or" phrase....
    2. I would like to update "Status" column when login user click "Approve" Button.
    3. 1st Approver, 2nd Approver, MD columns stored "email address", and type is "Text".
    4. The reason why I keep checking Status column is status value would be differently updated based on login user and current status.
    4-1 login user = 1st approver, and status = "submitted" then status would be updated "approved by 1st approver".
    4-2 login user = 2nd approver, and status = "approved by 1st approver" then status would be updated "approved by 2nd approver".
    4-3 login user = MD, and status = "approved by 2nd approver" then status would be updated " approved by md".
    but there are exceptional cases.
    a. no 1st and 2nd approver with status value "submitted" ==> md should approve this item, then status value should be "approved by md"
    b. no 2nd appvoer only with status value "approved by 1st approver" ==> it also md should approve this item, then status value should be "approved by md".
     
    5. The reason why I keep putting "LookUp(ColHRAppData, Title = VarAppData).Status.Value" code is I have no I idea how to check current status value. pleae let me know if there are better idea....
     
    Thank you...
     
  • ronaldwalcott Profile Picture
    3,914 Moderator on at
    How many records are you updating? If one, then use Patch. If more than one, then you are still using UpdateIf incorrectly.
    UpdateIf checks every record therefore statements such as
    Trim(Lower(LookUp('Claim/Penalty', Title = VarAppData).'1st_Approver')) = Trim(Lower(UserEmail))
     
    becomes more like
    Trim(Lower('1st_Approver')) = Trim(Lower(UserEmail))
     
    where you are accessing the column name of the active record

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

#2
WarrenBelz Profile Picture

WarrenBelz 204 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 122

Last 30 days Overall leaderboard