Project and Portfolio Management Practitioners Forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Using rules to populate a field.

SOLVED
Go to solution
Highlighted
Andy McMahon_1
Collector

Using rules to populate a field.

Good Morning!

I have a field with a Y/N Validation, that i want to populate (Y or N) based on the results of another field.

For instance if Approach is equal to Micro I would like Implementation to equal "Y"... I can't seem to write the SQL logic for this, and was wondering if anyone could help.

Thank you!
7 REPLIES
Raka_1
Collector

Re: Using rules to populate a field.

select 'Y', 'Yes' from dual
Andy McMahon_1
Collector

Re: Using rules to populate a field.

That worked! Thanks so much...

except it chooses N...

I guess the next part of my question is, If I have a list of fields that "Micro" will effect, would I have to have a rule for each of them, or could I bundle them all together.

For instance if Approach is Equal to "Micro" I would like Implementation, Disposition and Requirements equal to "Y"

AND I would like Concept and Planning to Equal "N"... Would each of those need their own rule?

Again Thank you SO MUCH for your help. I will assign points in a second.
Raka_1
Collector

Re: Using rules to populate a field.

select 'Y', 'Yes', 'N', 'No', 'N', 'No' from dual
RichardWoodmans
Occasional Contributor

Re: Using rules to populate a field.

Yes you can set several fields within one rule. Add the fields you want to update in the Result Fields section and add the corresponding values to your SQL statement in the Logic secion.

If you really want to get fancy, you set the condition in the dependency section to 'Any Value' and use the SQL Decode in your SQL statement.
Andy McMahon_1
Collector

Re: Using rules to populate a field.

How would I use the SQL Decode?

When I mimic what was in your attached SS (thanks by the way) I get an error. It's some GUID Exception Correlation Error.

Andy McMahon_1
Collector

Re: Using rules to populate a field.

Whoops! I got it. There was an extra Comma at the end of your select statement, before From Dual.

It works! I wish I could give you the full 10 points now! Sorry!
RichardWoodmans
Occasional Contributor
Solution

Re: Using rules to populate a field.

Your error may be cause by the last comma in the select statement. I just noticed that I had the extra comma in my sample.

If you google 'SQL Decode' you will find many examples. The syntax is:
decode( expression , search , result [, search , result]... [, default] )

Don't quote me verbatim but in your example you could use something like:
Select decode('[REQD.P.APPROACH]'='MICRO', 'Y', 'N'), ('[REQD.P.APPROACH]'='MICRO', 'Yes', 'No')
from dual
(this assumes that you would update your Dependency condition to 'Any Value' and would only update one field in your Results section).

Just remember that there is a limit to the number of characters you can use in the Logic section.

//Add this to "OnDomLoad" event