71
Views
16
Comments
if expressions
Application Type
Traditional Web


I want to ask about the use of if expression in assignment expression. 

the case is as follows

on request 1:

- if the assignment is approved then it will go to the proposal page section

- if the assignment is not approved it will return to the previous page

in request 2:

-if the task is approved, it will go to the close stage section

-if the task is not approved, the process will end


The following is a picture of the logic that will be created

and here is the assignment for the if expression that I have to make


thank you...



Hi,

Create one boolean variable to redirect in the page according to your condition true false.

First Condition in expression:

If(IsApproved,True,False)

Assign it in boolean variable that we above created.

After that you have to check if it is true than it will go to Proposal page else it will go to previous page.

Second Condition in expression:

Create one boolean variable to redirect in the page according to your condition true false.

If(IsApproved,True,False)

Assign it in boolean variable that we above created.

After that you have to check if it is true than it will go to Close Stage section else it will go to end.

Or if you want you can share your OML I will check the code.

Thanks

Ruchi



No. Never ever ever create an If that results in a True or False. That's an giganormous anti-pattern. "If(IsApproved, True, False)" is 100% equal to "IsApproved".

the case I want to solve is exactly like this, can I get a more complete example so that I understand better, thank you. 

Is this right? thankyou


Hello Marhta,

For Situation 1:

1- You need to create a variable and set its data type to Boolean(True or False).

2- Set the value of if condition to- If(IsTaskApproved,True,False).

3-Assign it in Boolean variable that we above created.

4- After that you need to set the destination if the variable value is true then it will redirects to proposal page section else it will be redirecting to previous page. 

For Situation 2:

1- You need to create a variable and set its data type to Boolean(True or False).

2- Set the value of if condition to- If(IsTaskApproved,True,False).

3-Assign it in Boolean variable that we above created.

4- After that you need to set if the variable value is true then it will redirects to close stage section else it will end. 


Thanks and Regards,

Vibhor Agarwal

See my post above. If(condition, True, False) is an anti-pattern. Never ever ever use it!

the case I want to solve is exactly like this, can I get a more complete example so that I understand better, thank you. 

 Can I have an example of this statement, thank you.

"4- After that you need to set the destination if the variable value is true then it will redirects to proposal page section else it will be redirecting to previous page. "

Hello,

Yes, You can use the if in and in If condition will be If(IsTaskApproved,True,False) if this condition true then it will be redirects to the destination else redirects to the previous page.

You can destination from the widget set the value to the destination screen.

Thanks and Regards,

Vibhor Agarwal

Hi Marhta Batubara,


Do you want to implement this logic in process or any other actions?


Regards,

Wasimkhan S 


i want to implement this login in process..

Hey Marhta,

You have "if" . Try to use that.

I have used this in OnNotify. Based on your code you have to place the "if" accordingly.

I hope this might help you!

Thanks & Regards,

Sudip Pal

I'm not sure if I completely understood the question, but based on the flow you shared, I realize that you want to either go back to the previous page or end the flow, either by executing the close action or choosing not to execute it. From what I gathered, you should create two Boolean variables, 'GoBack' and 'OnlyFinished,' to control the progress of your application. The conditions for these variables are based on the values of the 'prefinal,' 'Approved,' and 'Revised' variables. Here's what I plan to do:


**Variable 1: GoBack (Boolean)**

- Condition: Go back to the previous page if:

  - (prefinal is true and Approved is false) OR

  - (prefinal is true, Approved is true, and Revised is true)


**Variable 2: OnlyFinished (Boolean)**

- Condition: Set it to true if:

  - prefinal is true and Approved is true, regardless of the value of Revised. If this condition is not met, set it to false.

These variables will help you control the execution flow based on these conditions. You can use these variables to determine whether to return to the previous page or to end the flow, either by executing the close action or choosing not to execute it.

I still don't understand, can I get more specific logic for that case, thank you.


Redirection to previous page must be validated first 

Goback 

  if (SalesPipelineData.IsFinalApproval and Approve = false,

     true

         if(SalesPipelineData.IsFinalApproval and Approve and revised,

             TRUE,

            false

           )

)

if Goback returns to false you only need to validate to finish or close and finish.

OnlyFinished = (SalesPipelineData.IsFinalApproval = false and Approve = false) That in reality the only time you will finish without executing the close step,

The "revised" variable depends on proposal and negotiation or something like that


I also don't fully understand the question, but here are my 2 cents about some of the answers that have been given. (in regards to expressions)

I would avoid creating an expression with huge if statements, because they are a pain in the ass to maintain. Especially if they are nested.
Instead of putting huge 'if conditions' or 'logic' in your expressions consider making a function where you encapsulate and build the logic using OutSystems nodes. Or a combination of both.
It would help with maintainability and readability.

Functions are a strong tool that is usually forgotten during development.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.