Good day and thank you for your interest.
Background: The current use case is that we have a Canvas App embedded on the Opportunity form, and there are multiple buttons which initiate various workflow processes. (See Below)
Ask is to update canvas app for processes so that if the Opportunity isn't in Sales Stage 3 or higher (either Sales Stage OR Sales Stage-Commercial), the process will exit with notification. We have a requirement where we want to evaluate two option set fields on a current record and then based on any combination of conditions, the user could either advance to the next stage or be presented with a notification message.
The two option set values are Sales Stage and Commercial Sales Stage:
Criteria:
Current Code on the "Assign" Button on the Canvas App
If(
ContextRecord.Status = 'Status (Opportunities)'.Open && ContextRecord.'RFQ Opportunity' = 'RFQ Opportunity (Opportunities)'.Yes&&!IsBlank(ContextRecord.'Frame Break'),
Navigate('Assign To Quoter Screen'),
Notify(
If(
ContextRecord.Status <> 'Status (Opportunities)'.Open,
"The opportunity is not currently in an open status, unable to continue."
) & If(
ContextRecord.'RFQ Opportunity' <> 'RFQ Opportunity (Opportunities)'.Yes,
"The opportunity is not currently classified as an RFQ opportunity, unable to continue."
)& If(
IsBlank(ContextRecord.'Frame Break'),
"Frame Break is required to Assign to Quoter. Save a Frame Break value, then run process again."
)& If(
ContextRecord.'Sales Stage' =
),NotificationType.Warning
)
)
Appreciate any help with this!
Best Regards,
Arslan
Hey Wizey.
Thanks for the idea. Testing it out in sandbox now.
Both Sales Stage and Sales Stage - Commercial are choice fields (previously known as option sets), so I am not sure there being stored at all and whether the 'in' function would still apply. FYI, these are Local option sets and not global option sets. Also this is canvas app embedded and integrated on a Model Driven App, there is an ContextRecord function which is evaluating for the current record on the opportunity form. So basically we are checking and evaluating against two choice fields on the same opportunity record and trying apply restrictive logic.
The first image is Sales Stage, and the second image is Sales Stage -Commercial.
Just a thought, but what type of data is stored in your "Stage" and "Stage-Commercial"?
If they act as status, you could actually check if their value is set in a range with the "in" operator.
If (Sales Stage 0 && 0-Sales Stage-Commercial - 0). Should fail
If (Sales Stage 0 && 1-Sales Stage-Commercial - 1). Should fail
If (Sales Stage 0 && 2-Sales Stage-Commercial - 2). Should fail
If (Sales Stage 1 && 0-Sales Stage-Commercial - 0). Should fail
If (Sales Stage 2 && 0-Sales Stage-Commercial - 0). Should fail
If (Sales Stage 1 && 1-Sales Stage-Commercial - 1). Should fail
If (Sales Stage 2 && Sales Stage-Commercial - 2). Should fail
==
Switch(
'Sales Stage' = "Stage 0" && 'Sales Stage-Commercial' in ["Stage 0", "Stage 1", "Stage 2"],
Should fail,
'Sales Stage' = "Stage 1" && 'Sales Stage-Commercial' in ["Stage 0", "Stage 1"],
Should fail,
'Sales Stage' = "Stage 2" && 'Sales Stage-Commercial' in ["Stage 0", "Stage 2"],
Should fail
)
Would that work in your situation?
Thank you
This is helpful in that we can frame the scenarios in a switch. The main challenge is actually evaluating against the underlying option set values in CDS. For example in this one scenario, here would be the possible combinations: There are three other scenarios which would multiply these expressions by 5 in total.
1. Sales Stage and Sales Stage-Commercial are BOTH at Stage 2 or less. Should get notice.
If (Sales Stage 0 && 0-Sales Stage-Commercial - 0). Should fail
If (Sales Stage 0 && 1-Sales Stage-Commercial - 1). Should fail
If (Sales Stage 0 && 2-Sales Stage-Commercial - 2). Should fail
If (Sales Stage 1 && 0-Sales Stage-Commercial - 0). Should fail
If (Sales Stage 2 && 0-Sales Stage-Commercial - 0). Should fail
If (Sales Stage 1 && 1-Sales Stage-Commercial - 1). Should fail
If (Sales Stage 2 && Sales Stage-Commercial - 2). Should fail
By Stage 2 or less, we are evaluating the two option set values as if they are in a *range or *sequence, but PowerApps does not intuitively compare and evaluate all the given values in an option set as a range.
So in theory, based on your suggested formula it would be something like this; I wonder if there is a clean way to accomplish this, so all the expressions do not become extensive in length.?
Thank you and appreciate your contribution!
Switch( If (Sales Stage equals 0(*option set value) & Sales Stage-Commercial equals 0(2nd *option set value), Notify(...), defaultresult )
Hello @Arslan001 ,
I'm not sure I fully get your need here, but basically you want to check multiple scenario and either move to another screen or send a notification to the user?
"Switch()" allows you to quickly check multiple scenarios, to return their result and even manage a default scenario just in case.
https://learn.microsoft.com/en-us/power-platform/power-fx/reference/function-if
"Notify()" can send a short notification at the top of the screen, useful for showing the user a short-timed message about the situation.
https://learn.microsoft.com/en-us/power-platform/power-fx/reference/function-showerror
Switch(
condition1 & condition 2,
Notify(...),
condition 3 & condition 4,
Notify(...),
defaultresult
)
Unfortunately, I don't know how your stages are represented in your app nor how you run your processes, so I hope my hints are helpful enough to you.
If not, could you further describe the data you're working with and the result you're looking for please?
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.