You are viewing this site as a guest. You can still ask questions and help others! Join our Dev2Dev IT Community to receive your own blog, share your knowledge, and much more.

How to check if the field value is changed for derived/work record fields using people code.

10 replies [Last post]
ashok_star2004's picture
User offline. Last seen 3 years 51 weeks ago. Offline
Joined: 02/13/2009
Posts: 45

Hi,

In HR Self Service Time Reporting,the weekly time grid has the derived/ work record fields capturing hours.

The requirement is that when an employee report the time,he should hit the apply rules button. In a situation,when he want to change the number of hours reported or the trc,a warning must be displayed to hit the apply rules button. Im not able to check if the field value is changed through people code as all are the derived/work record fields. Can any one suggest how to achieve this my code looks like this.

/*********************************************/
Local Rowset &RS1;
Local Row &RW1;
Local Record &Recd;
Local Field &Fld;
/*********************************************/

/****************************************************************/

&RS1 = GetLevel0()(1).GetRowset(Scroll.TL_INSTALL_VW);

&rc2 = "TL_TR_WEEK_WRK";

For &I = 1 To &RS1_RS.ActiveRowCount

&Recd = &RS1.GetRow(&I).GetRecord(@("RECORD." | &rc2));
For &J = 1 To &Recd.FieldCount
&Fld = &Recd.GetField(&J);

If &Fld.IsChanged Then
Warning "Hit Apply Rules";
End-If;
End-For;
End-For;

/****************************************************************/

Where i cant use the Field Is Changed property as the derived ones aree not stored in the buffer.

Thanks,
Ashok

Hari_aindian's picture
User offline. Last seen 3 years 5 weeks ago. Offline
Joined: 08/02/2010
Posts: 84
Re: How to check if the field value is changed for ...

Can you check the priorvalue of that derived rec field?

like current value<>prior value then
warning ""

let us know if you can do this

Ashok's picture
Ashok (not verified)
Re: How to check if the field value is changed for ...

Hi Hari,

Prior value is giving an error stating the field is not present in the Grid main record name(a view in my case).

The following code is working for me.

Function DataChanged(&Elp_Rowset As Rowset, &Orig_Rowset As Rowset, &Rtn_value, &REC);

For &I = 1 To &Elp_Rowset.ActiveRowCount
If &Elp_Rowset.ActiveRowCount <> &Orig_Rowset.ActiveRowCount Then
/*Some change in the rowset*/
&I = &Elp_Rowset.ActiveRowCount;
&Rtn_value = 1;
Else
&Record = &Elp_Rowset.GetRow(&I).GetRecord(@("Record." | &REC));
&Orig_Record = &Orig_Rowset.GetRow(&I).GetRecord(@("Record." | &REC));
If (&Orig_Record.CompareFields(&Record)) Then
/*No change in the rowset*/
&Rtn_value = 2;
Else
&I = &Elp_Rowset.ActiveRowCount;
&Rtn_value = 1;
End-If;
End-If;
End-For;

End-Function;

Function Call :

&ReturnValue = 2;

If %Page = Page.TL_RPTD_ELP Then
&Elp_Rowset = GetLevel0()(1).GetRowset(Scroll.TL_INSTALL_VW);
&REC = "TL_TR_WEEK_WRK";

DataChanged(&Elp_Rowset, &Orig_Rowset, &ReturnValue, &REC);
End-If;
If &ReturnValue = 1 Then
Warning "Please hit Apply Rules Button";
End-If;

Thanks,
Ashok

Hari_aindian's picture
User offline. Last seen 3 years 5 weeks ago. Offline
Joined: 08/02/2010
Posts: 84
Re: How to check if the field value is changed for ...

Ashok, Glad that you resolved the issue and happy that you ve shared how you resolved. Thanks for sharing.

SR's picture
SR (not verified)
Re: How to check if the field value is changed for ...

Ashok

Thanks for sharing. I have similar situation to verify if the employee made a change. where did you write the &Orig_Rowset code. My code seem to not differentiate between old and new

Thank you
SR

ashok_star2004's picture
User offline. Last seen 3 years 51 weeks ago. Offline
Joined: 02/13/2009
Posts: 45
Re: How to check if the field value is changed for ...

SR,

I have wrote the code in the Save Edit of TL_TR_WEEK_WRK.EMPLID

If &ReturnValue = 1 as returned from the function "DataChanged", then the rowset is changed.

=> The Employee made a change.

Thanks,
Ashok

ashok_star2004's picture
User offline. Last seen 3 years 51 weeks ago. Offline
Joined: 02/13/2009
Posts: 45
Re: How to check if the field value is changed for ...

Thanks Hari:)

SR's picture
SR (not verified)
Re: How to check if the field value is changed for ...

Ashok

Thanks for reply

I was wondering where would you write the following
&Orig_Rowset = GetLevel0()(1).GetRowset(Scroll.TL_INSTALL_VW);

I am guessing, you must have written in another event since we need to capture before employee touched time sheet

I tried in couple of places the following code so rowset is available during time sheet save for comparison
Component Rowset &Orig_Rowset;
&Orig_Rowset = GetLevel0()(1).GetRowset(Scroll.TL_INSTALL_VW);
but still code not finding they are different

Appreciate your feedback

Thank you
SR

ashok_star2004's picture
User offline. Last seen 3 years 51 weeks ago. Offline
Joined: 02/13/2009
Posts: 45
Re: How to check if the field value is changed for ...

Hi SR,

Write the code to get the Actual Rowset in the time sheet page activate. Use it as a component rowset to compare it with the changed/elapsed rowset.

&Orig_Rowset = CreateRowset(Record.TL_TR_WEEK_WRK);

Thanks,
Ashok

SR's picture
SR (not verified)
Re: How to check if the field value is changed for ...

Ashok

Thanks for your tip

Now I am getting a return value 1, even if I make no changes. not sure if there are any default values or something else going on

Thank you
SR

Guest's picture
Guest
Re: How to check if the field value is changed for ...

thank you for your valuable info...It save's my time lot...

Post new comment

CAPTCHA
The question below is to prevent automated spam submissions.
7 + 4 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.