Tuesday, April 6, 2010

Show Pages inside the Component in display only mode.

Below is a common function that can used to make pages in a component display only.

Function Componentdisplayonly()
&COMPONENT = %Component;
&PAGES = CreateSQL("SELECT PNLNAME FROM PSPNLGROUP WHERE PNLGRPNAME = :1", &COMPONENT);
While &PAGES.Fetch(&PAGE)
GetPage(@("PAGE." | &PAGE)).DisplayOnly = True;
End-While;
End-Function;

How to disable rows in a scroll level based on a field value

In this example i need to disable the rows in the job component based on action reason field value for certain users.
The below code is written at the component level. If you have more than one level you can expand the below code to disable the fields for level 2 and level 3.


Local Rowset &MYROWSET;

If IsUserInRole("DEPT_TIMEKEEPER", "DEPT_PR_PRSR") Then
&MYROWSET = GetRowset();
For &A = 1 To &MYROWSET.ActiveRowCount;
&LEVEL1_ROW = &MYROWSET(&A);
&Action_Reason = &LEVEL1_ROW.GetRecord(Record.JOB).ACTION_REASON.VALUE;
If &Action_Reason = "WLT" Then
For &R = 1 To &LEVEL1_ROW.RECORDCOUNT
&Rec = &LEVEL1_ROW.GetRecord(&R);
For &J = 1 To &Rec.FieldCount
&Fld = &Rec.GetField(&J);
&Fld.Enabled = False;
End-For;
End-For;
End-If;
End-For;
End-If;