The community will be in read-only from Monday 11:59pm (PT) to Wednesday 7:30am (PT)
The community will be in read-only from Monday 11:59pm (PT) to Wednesday 7:30am (PT)
Project and Portfolio Management Practitioners Forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Workflow transition dependent on two field values.

SOLVED
Go to solution
Highlighted
AlanMarch
Super Collector

Workflow transition dependent on two field values.

Is there a way to make a request transition based off of two field values in a request?  Essentially I have two fields that contain user names and if the fields contain the same value the request need to transition to one step, but if they are different the request needs to transition to a different step.

Is this possible, if so how can I make this happen?

 

Thanks in advance for your time and assistance.

16 REPLIES
Jim Esler
Honored Contributor

Re: Workflow transition dependent on two field values.

Use an Immediate Execution step. Set up two commands in the request type. The first command would have the condition:

 

     '[WFS.STEP_NAME]'='your step name' AND '[REQD.P.FIRST_FIELD]' = '[REQD.P.SECOND_FIELD]'

 

The command to execute in this step is:

 

    ksc_set_exit_value "SUCCESS","Succeeded"

 

The second command's condition would be the negative of the first:

 

     '[WFS.STEP_NAME]'='your step name' AND NOT '[REQD.P.FIRST_FIELD]' = '[REQD.P.SECOND_FIELD]'

 

This command would execute:

 

     ksc_set_exit_value "FAILURE","Failed"

AlexSavencu
Honored Contributor

Re: Workflow transition dependent on two field values.

Hi,

 

you can also achieve the same with a single SQL command in an execution step:

 

select case <token>

 when <first value> then 'SUCCESS' --or any other transition you may define on the step source for end user friendlieness purposes

 when <second value> then 'FAILURE'

end result from dual.

 

cheers

alex

--remember to kudos people who helped solve your problem


--remember to kudos people who helped solve your problem
AlanMarch
Super Collector

Re: Workflow transition dependent on two field values.

Hi Jim,

 

Thank you for your response.  I've tried what you suggested, but for some reason my requests always transitions through success.  Maybe my configuration is wrong.  Please see the attached for my setup.  Remember, if the two fields are the same the request transitions to one step.  If they are different the request needs to transition to a different step. 

 

Again thanks for your help.

AlexVastartis
Acclaimed Contributor

Re: Workflow transition dependent on two field values.

Alan, 

 

In your second command you have a double negative. The 'NOT' and the '!='

 

'[WFS.STEP_NAME]'='Assigned Staff' AND NOT '[REQD.P.REQ_ASSIGNED_TO]' != '[REQD.P.HIDDEN_USER]'

AlanMarch
Super Collector

Re: Workflow transition dependent on two field values.

Sorry Alex, my mistake I didn't update the command before I took the screenshot.  I've been trying all kinds of different commands before reposting, but no matter what I try all my transitions still go through succeess.  Any idea why?

Jim Esler
Honored Contributor

Re: Workflow transition dependent on two field values.

Check the log for the execution step to verify that one of the commands was executed. I have found that if one of the fields is not populated, neither condition will be satisfied and neither command will be executed. You can add a clause for 'field1 is not null' and/or 'field2 is not null' as needed.

AlanMarch
Super Collector

Re: Workflow transition dependent on two field values.

My log states "All command conditions evaluated to false. No commands were run as a result.

Succeeded"

 

As far as having an empty field this isn't possible because I have a rule "On Page Load" where the "Assigned To :" field popuates the "Hidden User:" field.  I can also see this rules is working properly since the field is not hidden during my testing.

Jim Esler
Honored Contributor

Re: Workflow transition dependent on two field values.

Copy and paste the actual conditiions you have on your commands to this thread so we can see what you are executing. Also, add an additional command that executes on the step with no additional conditions before the ones you have there now:

 

ksc_local_exec echo [token1] [token2]

 

 

AlanMarch
Super Collector

Re: Workflow transition dependent on two field values.

First Command

Command:

ksc_set_exit_value "SUCCESS","Succeeded"

 

Condition:

'[WFS.STEP_NAME]'='Assigned Staff' AND '[REQD.P.REQ_ASSIGNED_TO]' = '[REQD.P.HIDDEN_USER]'

 

Steps:

ksc_set_exit_value "SUCCESS","Succeeded"

 

Second Command:

Command:

ksc_set_exit_value "FAILURE","Failed"

 

Condition:

'[WFS.STEP_NAME]'='Assigned Staff' AND NOT '[REQD.P.REQ_ASSIGNED_TO]' = '[REQD.P.HIDDEN_USER]'

 

Steps:

ksc_set_exit_value "FAILURE","Failed"

AlexSavencu
Honored Contributor

Re: Workflow transition dependent on two field values.

Dude,

Just implement it the way I suggested, that is using SQL. It is way more clean, simple, and it implies less server-side processing.

Cheers
Alex

--remember to kudos people who helped solve your problem
AlanMarch
Super Collector

Re: Workflow transition dependent on two field values.

LOL -


Alex,

 

Dude :) - As much as I truly appreciate your feedback I don't think your solution will work because your solution looks like it is dependent on one field value or the other, but not both fields.  Please keep in mind I need the request to transition to one step if the two fields are identical or transition to a different step if they are not identical.

 

I'll be glad to give it a try, but please see my questions in green.

 

select case <token> which field should this be?  Or should I add a second token for the second field?

when <first value> This values can be 1 of over 50 values and can change because the validation is based off a security group.  Should I make it a validation or do I need to create a transition for each possible selection...Which (if you care) I really don't have a problem doing?

then 'SUCCESS' --or any other transition you may define on the step source for end user friendlieness purposes

when <second value>  (ditto to the first value) This values can be 1 of over 50 values and can change because the validation is based off a security group.  Should I make it a validation or do I need to create a transition for each possible selection...Which (if you care) I really don't have a problem doing?

then 'FAILURE'

end result from dual.

Jim Esler
Honored Contributor

Re: Workflow transition dependent on two field values.

Since neither command is being executed, one of the tokens is not being substituted with the expected value. Add a command with no conditions and execute the following:

 

ksc_local_exec echo X[WFS.STEP_NAME]X[first token]X[second token]X

 

The X (or whatever character you choose) is merely a separator so you can tell if there are any white space characters in the value.

 

You can do this with sql instead. I would suggest something like the following to select a value if that is preferable:

 

select decode('[token1]','[token2]','SUCCESS','FAILURE'),

            decode('[token1]','[token2]','Successful','Failed')  from dual

AlexSavencu
Honored Contributor

Re: Workflow transition dependent on two field values.

Alan,

 

think simple! - check the attachment and let me know.

 

cheers

alex


--remember to kudos people who helped solve your problem
AlanMarch
Super Collector
Solution

Re: Workflow transition dependent on two field values.

Okay I'm in a dilemma. Both Jim's and Alex's solution work great.  However, I will say that Alex's solution is simpler and quicker to enable.  It makes me think "Well, heck why didn't I think of that?"

 

Kudos's to both of you!  I very much appreciate your time and effort in providing a solution.

vonderhe
Occasional Contributor

Re: Workflow transition dependent on two field values.

 
vonderhe
Occasional Contributor

Re: Workflow transition dependent on two field values.

HI, just put the aggregated fields in an SQL-Based execution.

//Add this to "OnDomLoad" event