Project and Portfolio Management Practitioners Forum
cancel

Auto Populate Field based on User? Also Based on Date?

SOLVED
Go to solution
Highlighted
Andy McMahon_1
Super Contributor.

Auto Populate Field based on User? Also Based on Date?

Hey guys, I think this is a simple one. 

 

I have a table component. In that Table Component, I have a field that is "Reviewer"...and basically I want it to autofill based on the user who is adding the table row.  (Similar to the "Created By" in a request Header Type)

I also have a field called "Date", and I would like it to auto populate based on..... you guessed it, the current date. 

I feel like this is probably really easy and something I just never learned. I hope you can tell me I'm right ;) 

8 REPLIES
Jim Esler
Acclaimed Contributor.

Re: Auto Populate Field based on User? Also Based on Date?

The current user is available with the tokens [SYS.USER_ID] and [SYS.USERNAME]. For the date, use the sql statement:

 

select sysdate,sysdate from dual

Andy McMahon_1
Super Contributor.

Re: Auto Populate Field based on User? Also Based on Date?

and, pardon my ignorance, would I use those in creating a new validation, or... like. the 'default' section.  

Jim Esler
Acclaimed Contributor.

Re: Auto Populate Field based on User? Also Based on Date?

You would set the field values in On Creation rules on the table component.

Andy McMahon_1
Super Contributor.

Re: Auto Populate Field based on User? Also Based on Date?

Umm... So set the rules in the request type, upon creation?  

But, what if different people add a column to the table?  The idea would be that when they clicked on "Add Data" it would autopopulate their name and date.  

Jim Esler
Acclaimed Contributor.
Solution

Re: Auto Populate Field based on User? Also Based on Date?

You can set rules on table components, too, and set fields in the table entry. Rules on the request can only set request header and details fields.

 

An On Creation rule on the table component will set fields in the table entry when that entry is created.

Andy McMahon_1
Super Contributor.

Re: Auto Populate Field based on User? Also Based on Date?

I got the date part working. The user though, I'm having problems with.  Do I use rules to do that too, or is that somehow set in the validation?  

Sorry for the confusion.  

Erik Cole
Acclaimed Contributor.

Re: Auto Populate Field based on User? Also Based on Date?

Hi Andy,

You can do both in the same rule:

select sysdate,sysdate,'[SYS.USER_ID]','[SYS.USERNAME]' from dual

In this case, put the date field first, and the user field second in the Results.

Andy McMahon_1
Super Contributor.

Re: Auto Populate Field based on User? Also Based on Date?

Yessir, I figured it out.  I was forgetting the quotes around the token.