Showing posts with label Component Buffer. Show all posts
Showing posts with label Component Buffer. Show all posts

How to Travel through all the records and fields all levels in a component

How to Travel through all the records and fields all levels in a component
Travel through all the records and fields all levels in a component This is a typical peoplecode example for traverse through all the records and fields in a component This might be handy when you want to troubleshoot. 
/* Get the parent Level 0 rowset */ Local Rowset &Parent = GetLevel0(); Local number &I, &J, &K, &L; Local Rowset &RS; Local Row &RowChild; Local Record &Rec; For &II = 1 To &Parent.ActiveRowCount /* To get the number of child rowsets of the row */ For &I = 1 To &Parent(&II).ChildCount /* Get each rowset*/ &RS = &Parent(&II).GetRowset(&I); /* For each rowset each ActiveRowCount */ For &J = 1 To &RS.ActiveRowCount /* Get the each row for each rowset */ &RowChild = &RS.GetRow(&J); /* For each row, how many records */ For &K = 1 To &RowChild.RecordCount &Rec = &RowChild.GetRecord(&K); /* show each Record Name */ WinMessage(&Rec.Name, 0); /* if record has changed show a message */ If &Rec.IsChanged Then WinMessage("this record is changed " | &Rec.Name, 0); /* Go through fields */ For &M = 1 To &Rec.FieldCount If &Rec.GetField(&M).IsChanged Then /* If field has changed show a message */ WinMessage("this field is changed " |  
&Rec.GetField(&M).Name | " value " | &Rec.GetField(&M).Value, 0); End-If; End-For; Else WinMessage("this record is not changed " | &Rec.Name, 0); End-If; End-For; End-For; End-For; End-For;

Record Fields and the Component Buffer

Record Fields and the Component Buffer
This is taken directly from peoplebooks;
The record fields in the component buffer are a superset of those accessible to the user through page controls. In most cases, PeopleCode can reference any record field in a scroll area’s primary scroll record or in a related display record, not just those fields that are associated with page controls. The following table lists record types and locations:
Type and Location of Record
Presence in Component Buffer
Primary record on scroll levels greater than zero
On scroll levels greater than zero, all record fields from the primary scroll record are in the component buffer. PeopleCode can refer to any record field on the primary scroll record, even if it is not associated with a page control.
Primary record on scroll level zero
If scroll level zero of a page contains only controls associated with primary scroll record fields that are search keys or alternate search keys, then only the search key and alternate search key fieldsave in the component buffer, not the entire record. The values for the fields come from the keylist, and the record cannot run RowInit PeopleCode. If level zero contains at least one record field from the primary scroll record that is not a search key or alternate search key, then all the record fields from the primary scroll record are available in the buffer. (For this reason, you may sometimes need to add one such record field at level zero of the page to make sure that all the record fields of the level-zero primary record can be referenced from PeopleCode.)
Related display record fields
The buffer contains the related display record field, plus any record fields from the related display record that are referenced by PeopleCode programs. You can reference any record field in a related display record.
Derived/work record fields
Only derived/work record fields associated with page controls are in the component buffer. Other record fields from the derived/work record cannot be referenced from PeopleCode.
Translate table record fields
Only Translate table fields associated with page controls are available in the component buffer. Other fields from the Translate table cannot be referenced from PeopleCode.

How to Get Query String Values from PeopleCode

How to Get Query String Values from PeopleCode
In PeopleCode if you want to get the value from the Query String URL, the Request Class can be used. As you may know QueryString can be used to pass information from one page to another page (In the same component or a different component in the portal). Query string consists of the form of name-value pairs, such as EMPLID (name) = 12345678 (value). PeopleCode defines three methods to access the Query string parameter information.
  • GetParameter(name) - returns the value of a specified query string parameter or posted form data parameter.
  • GetParameterNames - returns all the parameter names for this request as an array of Strings, or an empty array if there are no input parameters
  • GetParameterValues(name) - method returns the values of the specified parameter (name) as an array of Strings, or an empty array if the named parameter does not exist. 

    as an example we can get the value of the EMPLID parameter from the query string as follows (assume that code is written in RowInit)

    Local string stringEMPLID = %Request.GetParameter("EMPLID");

    if EMPLID parameter returns multiple values then GetParameterValues() can be used as follows;

    Local Array of String &MYQueryParamValues;
    &MYQueryParamValues = GetParameterValues("EMPLID');
    for &i=1 to &MYQueryParamValues.Len Step 1
    Winmessage(&MYQueryParamValues[&i]);
    end-for;

    For more info please refer: http://docs.oracle.com/cd/E28394_01/pt852pbh1/eng/psbooks/tpcr/book.htm?File=tpcr/htm/tpcr23.htm#H4027