Updating fields from changes in scroll levels

1.2k Views Asked by At

I have a page that has 3 levels. Levels 0 & 1 are from the same record. Level 2 is from a second record. When a change is made to level 1, I would like to apply that change to the same field in Level 2's record.

Basically, this deals with EFF_STATUS in peoplesoft. If an effective row gets added to the record, and the EFF_STATUS is changed to Active or Inactive, I'd like to update the EFF_STATUS in my second record to match.

Here is the code I'm trying to execute and it is giving me an error of.. "Invalid row number 2 for class Rowset method GetRow. (2,263) K_OFFNSV_REC_EX.EFF_STATUS.SaveEdit PCPC:267 Statement:8 "

If %Component = Component.K_OFFNSV_CMP Then
   Local Rowset &LEVEL0, &Level1, &Level2;
   Local Row &L1Row, &L2Row;
   Local number &I, &J;
   
   &LEVEL0 = GetLevel0();
   &Level1 = &LEVEL0(1).GetRowset(Scroll.K_OFFNSV_REC);
   &I = CurrentRowNumber();
   &L1Row = &Level1(&I);
   If &L1Row.IsNew Then
      &L1Row.K_OFFNSV_REC.LASTUPDDTTM.Value = %Date;
      &L1Row.K_OFFNSV_REC.OPRID.Value = %UserId;
   End-If;
   &Level2 = &L1Row.GetRowset(Scroll.K_OFFNSV_REC_EX);
   For &J = 1 To &Level2.ActiveRowCount
      &L2Row = &Level2(&J);
      &L2Row.K_OFFNSV_REC_EX.EFFDT.Value = %Date;
      &L2Row.K_OFFNSV_REC_EX.EFF_STATUS.Value = &L1Row.K_OFFNSV_REC.EFF_STATUS.Value;
   End-For;
End-If;
1

There are 1 best solutions below

0
On

A suggestion, change/set values on SavePreChange. SaveEdit should be use for validations only.

With that being said:

Your currentrownumber returns the current row, so probably it is returning the row #2 on the level #2.

You need CurrentRowNumber(1) to get the #1 level.

Also, why are you setting the EFFDT yourself on the save? Look at other peoplesoft pages, you will see it is populated on the add by PS itself.