Thursday, August 27, 2009

Dynamic Dropdown in PS

In the "PeopleCode API Reference" PeopleBook, it mentions how to do dynamic dropdowns:

1. Define a field in the DERIVED record called fieldname.
2. In the record definition for the field you want to have a dynamic prompt table, define the prompt
table for the field as %PromptField,where PromptField is the name of the field you created in the
DERIVED record.
Note. When you use SetEditTable, you don’t have to add a hidden field to the page.
3. Use SetEditTable to dynamically set the prompt table.
%PromptField is the name of the field on the DERIVED work record. RECORD.recordname is the name of
the record to be used as the prompt table.
&REC.SetEditTable("%EDITTABLE1", Record.DEPARTMENT);
&REC.SetEditTable("%EDITTABLE2", Record.JOB_ID);
&REC.SetEditTable("%EDITTABLE3", Record.EMPL_DATA);
&REC.ExecuteEdits();
Since I am new to PS (this is probably my 8th months in), it's not easy for me to understand it. Been online looking for examples, but no much help found. After about 3 hours of playing, I finally made it work. Here is how:

First, I will show you the final look and feel so it's easier to explain:

I want use that "Long Name" field as the one for the dynamic drop-down. I will code it to prompt against the JOB_CODE table.








Here the SZ_PJ2_RC1 is my main record.





Now I set it to prompt against the EditTable3 Field of the DERIVED record.











Next, I will drop the new field (SZ_PJ2_FD1) to my page, along with DERIVED.EDITTABLE3. (The PeopleBook says "Note. When you use SetEditTable, you don’t have to add a hidden field to the page.", but I just could not make it to work, I had to add it. If you know how to not the hidden field, please let me know). The "Third Edit Table" is DERIVED.EDITTABLE3, I am making it hidden.


Last step, writing PeopleCode. In this case, I am putting the PeopleCode in the FieldDefault event in my SZ_PJ2_FD1 field.



Now try it online. You see the magnifying glass next to "Long Name". Clicking on it.








Now you see the look-up page. Notice it says "Look Up Long Name", that's my field. Notice also the dropdown there says "Job Code", so it's pulling data from Job Code table. I then chose the 2nd one from the results - 120000.












The original page will have my value. Clicking on the Save button, no error. Let's check what's in the database now:






Cool, I have120000 in there now.



-- End.

Tuesday, August 25, 2009

Trace in PS

To turn on online trace, add "&trace=Y" at the end of the login URL, for example, if your login URL is:

https://www.yoursite.com/instance_name/?cmd=login

You will need to do this:

https://www.yoursite.com/instance_name/?cmd=login&trace=Y

This should bring you to a login page where you can specify the trace options.

This trace will stop when your session is complete. Be careful with this, the trace file could grow very large.

The trace file should be under the app server's log directory.

PS login

PS login is the login userid/password we use to log into PS web portal as well as App Designer. It's different from our Oracle user id/password.