Using PeopleCode with PeopleSoft Pure Internet Architecture
This section discusses how to:
Use internet scripts.
Use the field object Style property.
Use the HTML area.
Use HTML definitions and the GetHTMLText function.
Use PeopleCode to populate key fields in search dialog boxes
An internet script is a specialized PeopleCode function that generates dynamic web content. Internet scripts interact with web clients (browsers) using a request-response paradigm based on HTTP.
In PeopleSoft Application Designer, on the Use tab of the page definition properties, you can associate a page with a style sheet component.
The style sheet has several classes of styles defined for it. You can edit each style class to change the font, the color, the background, and so on. Then, you can dynamically change the style of a field using the Style field class property. The style sheet does not change, only the style class associated with that field changes.
The following example changes the style class of a field depending on a value entered by the user. This code is in the FieldChange event.
Local Field &field; &field = GetField(); If TESTFIELD1 = 1 Then; &field.Style = "PSHYPERLINK"; End-If; If TESTFIELD1 = 2 Then; &field.Style = "PSIMAGE"; End-If;
Two methods are used to populate an HTML area control. Both require accessing the HTML area in the PeopleSoft Application Designer. One method is to select Constant on the HTML tab of the HTML page field properties dialog and enter HTML directly into the page field dialog.
The other method is to select Value on the HTML tab of the HTML page field properties dialog and associate the control with a record field. At runtime, populate that field with the text that you want to appear in the HTML area.
If you are using an HTML area to add form controls to a page, you can use GetParameter request class method in PeopleCode to get the user input from those controls.
Note: When you associate an HTML area control with a field, make sure the field is long enough to contain the data you want to pass to it. For example, if you associate an HTML area control with a field that is only 10 characters long, only the first 10 characters of your text will appear.
The following code populates an HTML area with a simple bulleted list. This code is in the RowInit event of the record field associated with the HTML control.
Local Field &HTMLField; &HTMLField = GetField(); &HTMLField.Value = "<ul><li>Item one</li><li>Item two</li></ul>";
The following code is in the FieldChange event of a button. It populates an HTML area (associated with the record field CHART_DATA.HTMLAREA) with a simple list.
Local Field &HTMLField; &HTMLField = GetRecord(Record.CHART_DATA).HTMLAREA; &HTMLField.Value = "<ul><li>Item one</li><li>Item two</li></ul>";
The following code populates an HTML area (associated with the record DERIVED_HTML and the field HTMLAREA) with the output of the GenerateTree function:
DERIVED_HTML.HTMLAREA = GenerateTree(&TREECTL);
The following tags are unsupported by the HTML area control:
If you are using the same HTML text in more than one place or if it is a large, unwieldy string, you can create an HTML definition in PeopleSoft Application Designer, and then use the GetHTMLText function to populate an HTML area control.
The following is the HTML string to create a simple table:
<P> <TABLE> <TR bgColor=#008000> <TD> <P><FONT color=#f5f5dc face="Arial, Helvetica, sans-serif" size=2>message 1 </FONT></P></TD></TR> <TR bgColor=#0000cd> <TD> <P><FONT color=#00ffff face="Arial, Helvetica, sans-serif" size=2>message 2</FONT></P></TD></TR> </TABLE> </P>
This HTML is saved to an HTML definition called TABLE_HTML.
This code is in the RowInit event of the record field associated with the HTML area control:
Local Field &HTMLField; &HTMLField = GetField(); &string = GetHTMLText(HTML.TABLE_HTML); &HTMLField.Value = &string;
This code produces the following:
In a PeopleSoft Pure Internet Architecture application, you typically want users to directly access their own data. To facilitate this, you may want to use SearchInit PeopleCode to populate standard key fields in search page fields and then make the fields unavailable for entry. You might assign the search key field a default value based on the user ID or alias the user entered when signing in.
You must also call the AllowEmplIdChg function, which enables users to change their own data. This function takes a single Boolean parameter in which you pass True to allow employees to change their own data.
Here is a simple example of such a SearchInit program, using %EmployeeId to identify the user:
EMPLID = %EmployeeId;