Discussion
Virtusa
LK
Last activity: 28 Jun 2016 22:45 EDT
Get the Max number from a data table and assign it to a property
I need to get the Max number from a data table and assign it to a property. I used an Auto-complete control for the property and sourced it from a Report Definition. The Report Definition works fine. But the assigning doesn't happen.
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
NIIT Technologies Limited
AU
Please try below approach -
1) Create a report definition on data table class
2) Create column for the property with summarize option = Max
3) In the pre-activity of your flow action, call Rule-Obj-Report-Definition.pxRetrieveReportData activity to run report definition. This will store result in some page.
4) Read the result page and assign value to property.
Virtusa
LK
There is no activity called pxRetrieveReportData. And what do you mean by 'This will store result in some page'. Can you please explain it further?
NIIT Technologies Limited
AU
Please check OOTB activity @baseclass.pyGetClassList.
It is executing 'pyGetWorkClasses' report definition using activity pxRetrieveReportData.
Page 'WorkClasses' passed as Param.pyPageName is results page. Results of report definition execution will be stored in 'WorkClasses' page. As shown below, you can iterate over the page to read the results.
Similarly, you can execute the report using pxRetrieveReportData and read the max value from results page.
I am not sure how max value will be stored in result page but you can give a try.
Virtusa
LK
Shouldn't there be a simple way. Since we can use a dropdown or an autocomplete rule to set a value to a propery, directly using a report definition.
NIIT Technologies Limited
AU
Well, I don't think you can use report definition directly in dropdown control to achieve this because for report definition + dropdown configuration, you can only use non-summarized columns as source.
Non-summarized columns will be present in the pxResults pages of the report definition result page, so they are directly visible from dropdown to use as source. Whereas summarized columns are present in a value list 'pySummaryValue' under pxResults(), so as per my understanding they will not be visible from dropdown.
So,
1) Create a report definition with only max column
2) Use pxRetriveReportData activity to run it in a pre-acitivity
3) Set value of ResultPage.pxResults(1).pySummaryValue(1) to your property.
I tried this and it is working fine for me.
NIIT Technologies Limited
AU
Or
You can also use the approach mentioned by Bhavya in below pdn post:
https://pdn.pega.com/forums/data-table/increment-the-primary-key-of-a-data-table#comment-111361
Telstra
AU
Do a simple Obj-Browse on that class by selecting one column. Your Page.pxResultCount will have the result count. Set it to any property you want.