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 / Variable defining erro...
Power Apps
Answered

Variable defining error at StartScreen

(0) ShareShare
ReportReport
Posted on by 184
Hello there,
 
I am trying to define a Variable in PowerApp StartScreen so that the ItemID store in a Variable to use it in multiple screens from the Email Deep-link. my current code is this which doesn't have any error. 
 
If(
    CountIf(
        Table(
            {Email: LookUp('Exit Clearance V02', ID = Value(Param("ItemID"))).Supervisor.Email},
            {Email: LookUp('Exit Clearance V02', ID = Value(Param("ItemID"))).Adm2ApproverEmail},
            {Email: LookUp('Exit Clearance V02', ID = Value(Param("ItemID"))).SUP2ApproverEmail},
            {Email: LookUp('Exit Clearance V02', ID = Value(Param("ItemID"))).Fin2ApproverEmail},
            {Email: LookUp('Exit Clearance V02', ID = Value(Param("ItemID"))).ICT2ApproverEmail},
            {Email: LookUp('Exit Clearance V02', ID = Value(Param("ItemID"))).Sec2ApproverEmail},
            {Email: LookUp('Exit Clearance V02', ID = Value(Param("ItemID"))).HR2ApproverEmail}
        ),
        Email = User().Email
    ) >= 2,
    ApprovalChoice, // If user has multiple roles, start at ApprovalChoice
    If(
        LookUp('Exit Clearance V02', ID = Value(Param("ItemID"))).Supervisor.Email = User().Email, SupervisorApprove,
        LookUp('Exit Clearance V02', ID = Value(Param("ItemID"))).Adm2ApproverEmail = User().Email, AdminApprove,
        LookUp('Exit Clearance V02', ID = Value(Param("ItemID"))).SUP2ApproverEmail = User().Email, SupplyApprove,
        LookUp('Exit Clearance V02', ID = Value(Param("ItemID"))).Fin2ApproverEmail = User().Email, FinanceApprove,
        LookUp('Exit Clearance V02', ID = Value(Param("ItemID"))).ICT2ApproverEmail = User().Email, ICTApprove,
        LookUp('Exit Clearance V02', ID = Value(Param("ItemID"))).Sec2ApproverEmail = User().Email, SecurityApprove,
        LookUp('Exit Clearance V02', ID = Value(Param("ItemID"))).HR2ApproverEmail = User().Email, HRApprove,
        LookUp('Exit Clearance V02', ID = Value(Param("ItemID"))).Final2ApproverEmail = User().Email, FinalApprove,
        !IsBlank(LookUp('ExitClr v02-Approvers', User().Email = Name.Email && Category.Value = "Delegator")), DelegatorLanding,
        !IsBlank(LookUp('ExitClr v02-Approvers', User().Email = Name.Email)) ||
        !IsBlank(LookUp('Exit Clearance V02', User().Email = Supervisor.Email)), ApproversLanding,
        RequestorLanding // Default screen if no conditions match
    )
)
But when I'm defining the Variable and update the code as such, the Set(VArItemX, ... showing error. And I dont have any idea why. 
 
 
// Set the variable with the LookUp result

Set(VarItemX, LookUp('Exit Clearance V02', ID = Value(Param("ItemID"))));

// After the variable is set, now use it in the If condition
If(
    CountIf(
        Table(
            {Email: VarItemX.Supervisor.Email}, 
            {Email: VarItemX.Adm2ApproverEmail}, 
            {Email: VarItemX.SUP2ApproverEmail},
            {Email: VarItemX.Fin2ApproverEmail}, 
            {Email: VarItemX.ICT2ApproverEmail}, 
            {Email: VarItemX.Sec2ApproverEmail},
            {Email: VarItemX.HR2ApproverEmail}
        ),
        Email = User().Email
    ) >= 2,
    ApprovalChoice, // Navigate to ApprovalChoice if conditions match
    If(
        VarItemX.Supervisor.Email = User().Email, SupervisorApprove,
        VarItemX.Adm2ApproverEmail = User().Email, AdminApprove,
        VarItemX.SUP2ApproverEmail = User().Email, SupplyApprove,
        VarItemX.Fin2ApproverEmail = User().Email, FinanceApprove,
        VarItemX.ICT2ApproverEmail = User().Email, ICTApprove,
        VarItemX.Sec2ApproverEmail = User().Email, SecurityApprove,
        VarItemX.HR2ApproverEmail = User().Email, HRApprove,
        VarItemX.Final2ApproverEmail = User().Email, FinalApprove,
        !IsBlank(LookUp('ExitClr v02-Approvers', User().Email = Name.Email && Category.Value = "Delegator")), DelegatorLanding,
        !IsBlank(LookUp('ExitClr v02-Approvers', User().Email = Name.Email)) || 
        !IsBlank(LookUp('Exit Clearance V02', User().Email = Supervisor.Email)), ApproversLanding,
        RequestorLanding // Default screen if no conditions match
    )
)
Please note that I have another code in OnStart event of the app which also defined the same variable "VarItemX" and working just fine. 
 
If(
    !IsBlank(Param("ItemID")),
    Set(
        VarItemX,
        LookUp(
            'Exit Clearance V02',
            ID = Value(Param("ItemID"))
        )
    );
    Set(
        VArFormMode,
        FormMode.Edit
    )
)
Please help me to identify the issue here. Im not that much expert on complex coding. 
I have the same question (0)
  • Verified answer
    NandiniBhagya20 Profile Picture
    4,667 Super User 2024 Season 1 on at
    Hi Leonard,

    Try pasting the same formula in app's OnStart property because variables can be set in OnStart property. StartScreen property is mainly used for navigation purpose.
     
    Thanks and Regards,
    Nandini Bhagya
  • LeonardLeo Profile Picture
    184 on at
    Thanks for the prompt reply. I have modified it a little and it worked. 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 993

#2
Valantis Profile Picture

Valantis 675

#3
11manish Profile Picture

11manish 545

Last 30 days Overall leaderboard