Monday, 28 November 2016

Optional Prompt in PS Query

Sometimes we need to create a PS Query with optional prompt i.e. if there are 3 prompt in  PS Query then if user enter a value, the query fetches relevant rows otherwise it fetches all the rows. 

For example we created a PS Query which have 3 prompt as shown in below screen


Now if we only pass birthdate then we will get this result


Now there is way to bypass this error and fetch the data on the basis of birthdate. To achieve this we need to add expression in our PS Query. If criteria is character type then we have to add expression ' ' like this


*Please make sure, there should be space between single quotes (' '). 

 If criteria is number type then we have to add expression with 0 like this


After adding expression, final step is we need to group criteria and expression like this


Make sure, while grouping the criteria the logical action should be OR not AND. Now, check whether we get data after passing the same birthdate or not



We get the data only after passing birthdate. In short for optional prompt first we need to set expression and then grouping of that criteria.


Tuesday, 22 November 2016

PeopleCode Events


Below is the list of PeopleCode Events in the order of their execution:

1.  SearchInit  
2.  SearchSave
3.  RowSelect
4.  PreBuild
5.  FieldDefault
6.  FieldFormula
7.  RowInit
8.  PostBuild
9.  Activate
10. FieldEdit
11. FieldChange     
12. RowInsert
13. RowDelete
14. SaveEdit
15. SavePreChange.
16. WorkFlow
17. SavePostChange


Above mention events can be written on the following PeopleCode event locations:

1.  Page Event
2.  Menu Event
3.  Record Event
4.  Component Event
5. Component Record Level
6. Component Record Field Level



Wednesday, 9 November 2016

Auto increment of sequence number


Sometime in grid or scroll, we need to write peoplecode on a field which stores unique number every time when we click on add new row button. Below code can be used to achieve this functionality:

Local Rowset &rowset;

&rowset = GetLevel0()(1).GetRowset(Scroll.TEST);

&count = 0;

For &i = 1 To &rowset.ActiveRowCount
   If &count < &rowset(&i).TEST.SEQNBR.Value Then
      &count = &rowset(&i).TEST.SEQNBR.Value;
   End-If;
End-For;

&rowset(CurrentRowNumber()).TEST.SEQNBR.Value = &count + 1;


TEST is name of grid or scroll. Auto increment number will start from 0 if you want that it will start from 1 or any other number, assigned that value &count variable after declaring rowset.