Fetch the first record whenever a property value changes in a pagelist.
There is a property , say , Taskcode. In total there are 4 task codes, for ex- A,B,C,D.
Now, I have a pagelist in the below structure having task code as one of the properties in the pagelist records.
Lets say the pagelist has 12 records.
SamplePage.pxResults(1)
SamplePage.pxResults(2)
:
:
SamplePage.pxResults(12)
We have sorted the pagelist by pxCreatedatetime. and TaskkCode.
So from 1 to 5 , "A" task code records are there, from 5 to 8 "B" task code records are there......Similarly till 20th record.
The requirement is, we have to delete all these records except The Latest record from a particular task code.
Means, (Since the pagelist is already sorted on the basis of creation date) we just have to delete the records except for the first record having A, for the first record having 'B'.......similarly till "D".
Also, we have to check if there is only one record for a particular task code it should not be deleted.
To be more clear,
if ,
SamplePage.pxResults(1).Taskcode = A
SamplePage.pxResults(2).Taskcode = A
SamplePage.pxResults(3).Taskcode = A
SamplePage.pxResults(4).Taskcode = A
SamplePage.pxResults(5).Taskcode = A
SamplePage.pxResults(6).Taskcode = B
SamplePage.pxResults(7).Taskcode = B
SamplePage.pxResults(8).Taskcode = B
SamplePage.pxResults(9).Taskcode = C
There is a property , say , Taskcode. In total there are 4 task codes, for ex- A,B,C,D.
Now, I have a pagelist in the below structure having task code as one of the properties in the pagelist records.
Lets say the pagelist has 12 records.
SamplePage.pxResults(1)
SamplePage.pxResults(2)
:
:
SamplePage.pxResults(12)
We have sorted the pagelist by pxCreatedatetime. and TaskkCode.
So from 1 to 5 , "A" task code records are there, from 5 to 8 "B" task code records are there......Similarly till 20th record.
The requirement is, we have to delete all these records except The Latest record from a particular task code.
Means, (Since the pagelist is already sorted on the basis of creation date) we just have to delete the records except for the first record having A, for the first record having 'B'.......similarly till "D".
Also, we have to check if there is only one record for a particular task code it should not be deleted.
To be more clear,
if ,
SamplePage.pxResults(1).Taskcode = A
SamplePage.pxResults(2).Taskcode = A
SamplePage.pxResults(3).Taskcode = A
SamplePage.pxResults(4).Taskcode = A
SamplePage.pxResults(5).Taskcode = A
SamplePage.pxResults(6).Taskcode = B
SamplePage.pxResults(7).Taskcode = B
SamplePage.pxResults(8).Taskcode = B
SamplePage.pxResults(9).Taskcode = C
SamplePage.pxResults(10).Taskcode = C
SamplePage.pxResults(11).Taskcode = C
SamplePage.pxResults(12).Taskcode = D
In this case
SamplePage.pxResults(1)
SamplePage.pxResults(6)
SamplePage.pxResults(9)
SamplePage.pxResults(12)
The above 4 should NOT be DELETED. And the rest should be DELETED.
We have to write an activity for that. Any suggestions?
Regards,
Anan