1. Define a field in the DERIVED record called fieldname.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:
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();
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.
No comments:
Post a Comment