Skip to main content

Notifications

Power Apps - Building Power Apps
Unanswered

Set Status Variable after each condition is meet Not working

Like (1) ShareShare
ReportReport
Posted on 4 Oct 2024 19:01:44 by 359
Ok so I am editing a list form from SharePoint. I am trying to set the status value (varStatus) each time something happens. 
 
Currently I have the status set to New on the OnNew button of the form.
 
OnNew: Set(varStatus,"New")
 
 
When I want to change it ,it looks something like this
 
If(
    AOBW_President_DropDown.Selected.Value = "Deny",
    Set(
        varStatus,
        "Rejected"
    )
 
My Status value is in a text input DataCard, and I have the variable varStatus in the Default section
Categories:
  • WarrenBelz Profile Picture
    WarrenBelz 144,367 on 10 Oct 2024 at 20:25:45
    Set Status Variable after each condition is meet Not working
    Hi Trout19 
    The issue is that the ultimate solution lies with your knowledge of the priority of the combinations. I do not know this - my post was only to demonstrate the concept required. 
  • Trout19 Profile Picture
    Trout19 359 on 10 Oct 2024 at 14:28:28
    Set Status Variable after each condition is meet Not working
    Thanks, you so much. I implemented the code, and it is still not working. I am providing screen shots for the Status Value Property and the Form from SharePoint. Let me know if you need to see anything else. 
     
    Here is the property of the StatusValue File with the varStatus variable.
     
     
     
    Screen Shot of the form in SharePoint. This should be showing Pending Bid Waivers in the status data filed.
  • WarrenBelz Profile Picture
    WarrenBelz 144,367 on 09 Oct 2024 at 20:26:18
    Set Status Variable after each condition is meet Not working
    The fundamental issue I can see initially (and I cannot see your data) is that each iteration will overwrite any previous setting if it is true. You are probably going to need a progressive If statement with the order set so none of the previous ones also apply (the action stops on the first true item) - example
    Set(
       varStatus,
       If(
          (!IsBlank(ConSupplier1) && !IsBlank(ConSupplier2) && !IsBlank(ConSupplier3)) ||
          (!IsBlank(AOBW_Presidnt_Signature_Value) && !IsBlank(AOBW_CFOSignature)),
          "Review",
          IsBlank(ConSupplier1) || IsBlank(ConSupplier2) || IsBlank(ConSupplier3),
          "Pending Bid Waivers",
          !IsBlank('IT ReviewedByValue') && !IsBlank(FinanceReviewedByValue) && !IsBlank(PurchasingReviewedByValue),
          "Pending CAR Approvals",
          !IsBlank(BryComp_VP1_Signature_Value) && !IsBlank(BryComp_SVP2_Signature_Value) && 
      !IsBlank(BryComp_SVP3_Signature_Value) && !IsBlank(BryComp_SVP4_Signature_Value) &&
      !IsBlank(BryComp_VP1_Signature_Value) && !IsBlank(BryComp_VP2_Signature_Value) &&
      !IsBlank(BryComp_VP3_Signature_Value) && !IsBlank(BryComp_VP4_Signature_Value) &&
      !IsBlank(BryComp_President_Signature_Value) && ​!IsBlank(BryComp_CEO_Signature_Value) &&
    ​​​​​​​ !IsBlank(BryComp_Other_Signature_Value), "Legal & Purchasing Approvals", !IsBlank(LegalApproverSignatureValue) && !IsBlank(PurchasingApprovalSignatureValue), "Asset Management", !IsBlank(AssetMangReviewerValue), "SAP Purchasing Review", AOBW_President_DropDown.Selected.Value = "Deny", "Rejected"
      ) )

     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee
  • Trout19 Profile Picture
    Trout19 359 on 09 Oct 2024 at 14:52:07
    Set Status Variable after each condition is meet Not working
    Sorry for the late reply, i though i had it figured out. It still not Changing value. 
     
    Additional notes:
    The value is Set to New in the OnNew Command Control.
    //Set Status Values
    If(
        IsBlank(ConSupplier1) || IsBlank(ConSupplier2) || IsBlank(ConSupplier3),
        Set(
            varStatus,
            "Pending Bid Waivers"
        )
    );
    If(
        !IsBlank(ConSupplier1) && !IsBlank(ConSupplier2) && !IsBlank(ConSupplier3),
        Set(
            varStatus,
            "Review"
        )
    );
    If(
        !IsBlank(AOBW_Presidnt_Signature_Value) && !IsBlank(AOBW_CFOSignature),
        Set(
            varStatus,
            "Review"
        )
    );
    If(
        !IsBlank('IT ReviewedByValue') && !IsBlank(FinanceReviewedByValue) && !IsBlank(PurchasingReviewedByValue),
        Set(
            varStatus,
            "Pending CAR Approvals"
        )
    );
    //Bryce Company Approval
    If(
        !IsBlank(BryComp_VP1_Signature_Value) && !IsBlank(BryComp_SVP2_Signature_Value) && !IsBlank(BryComp_SVP3_Signature_Value) && !IsBlank(BryComp_SVP4_Signature_Value) && !IsBlank(BryComp_VP1_Signature_Value) && !IsBlank(BryComp_VP2_Signature_Value) && !IsBlank(BryComp_VP3_Signature_Value) && !IsBlank(BryComp_VP4_Signature_Value) && !IsBlank(BryComp_President_Signature_Value) && !IsBlank(BryComp_CEO_Signature_Value) && !IsBlank(BryComp_Other_Signature_Value),
        Set(
            varStatus,
            "Legal & Purchasing Approvals"
        )
    );
    If(
        !IsBlank(LegalApproverSignatureValue) && !IsBlank(PurchasingApprovalSignatureValue),
        Set(
            varStatus,
            "Asset Management"
        )
    );
    If(
        !IsBlank(AssetMangReviewerValue),
        Set(
            varStatus,
            "SAP Purchasing Review"
        )
    );
    If(
        AOBW_President_DropDown.Selected.Value = "Deny",
        Set(
            varStatus,
            "Rejected"
        )
    )
     
     
     
     
  • ronaldwalcott Profile Picture
    ronaldwalcott 1,388 on 07 Oct 2024 at 21:04:11
    Set Status Variable after each condition is meet Not working
    What does not work mean?
    What result are you getting vs what result are you expecting?
     
    This is also hard to read and therefore it will be hard to debug. I would recommend structuring it as follows

    UpdateContext({Condition1:true});
    UpdateContext({Condition2:false});
    UpdateContext({Condition3:true});
    UpdateContext({Condition4:true});

    UpdateContext({BusinessRule1:And(Condition1,Condition2)});
    UpdateContext({BusinessRule2:Or(Condition1,Condition3)});
    UpdateContext({BusinessRule3:And(Condition3,Condition4)});

    If (BusinessRule1, UpdateContext({Result1:"Value1"}));
    If (BusinessRule2, UpdateContext({Result2:"Value2"}));

    This should allow easier debugging and should make the code easier to read.
    You will obviously use Set instead of UpdateContext where necessary.
     
  • WarrenBelz Profile Picture
    WarrenBelz 144,367 on 07 Oct 2024 at 20:21:12
    Set Status Variable after each condition is meet Not working
    Please post all of that in a Code box and I will have a look at it.
  • Trout19 Profile Picture
    Trout19 359 on 07 Oct 2024 at 14:36:07
    Set Status Variable after each condition is meet Not working
    Basically, I would like for the value of the Status text label to change each time a condition is meet. 
     
    For Example,
    Before formula Status = "Status Test"
     
    If(isBlank(value1) & isBlank(value2), Status = "Change Status")
     
    After formula Status = " Change Status"
     
    This is the code I have so far it doesn't seem to work:
     
     
     
  • WarrenBelz Profile Picture
    WarrenBelz 144,367 on 04 Oct 2024 at 21:36:28
    Set Status Variable after each condition is meet Not working
    Sorry I am confused - what is the question here ?

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #9 Get Recognized…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 144,367

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,297

Leaderboard
Loading started