Announcements
Hi guys,
i have a enum 3 element if i select "Activeworker"
1.Active worker
By default, report period starts from January up to end of current month
We will show all worker valid to greater than or equal report to date.
From data will be first of January up end of current month date.
how to achieve in X++? in report.
Thanks
Hi,
No it would be between line query = this.parmQuery(); and queryRun = new QueryRun(query);
Understnad what this does, you are adding the filter on the query just like select * from SalesTable and with filter it would be Select * from SalesTable where salesid = 'XYZ'. This is exactly what you do with QueryRange.
thanks for your answer,
in above your code in while loop inside ?
Hi,
where are you using the values of fromDate and toDate in your code?
I assume you will have to do something like below
if( employmentStatus == MPEmploymentStatus::Active) { fromDate = //1st January of current year; } QueryBuildDataSource qbds = query.datasource(); qbds.addRange(fieldnum(,)).value(queryRange(fromDate, toDate));
It is not complete code, you will have to update it where you want to apply the filter. so when QueryRun is executing it will loop on filtered records.
////// The MPWorkerEmploymentDP class declares the variables that are required for the /// MPWorkerEmploymentDP report. /// [ SRSReportParameterAttribute(classstr(MPWorkerEmploymentContract)) , SRSReportQueryAttribute(queryStr(MPWorkerEmployment)) ] class MPWorkerEmploymentDP extends SrsReportDataProviderPreProcessTempDB { MPWorkerEmplymentTmp workerEmplymentTmp; ////// Retrieves the data from the MPWorkerEmplymentTmp table for the report. /// /// /// The MPWorkerEmplymentTmp table. /// [ SRSReportDataSetAttribute(tableStr(MPWorkerEmplymentTmp)) ] public MPWorkerEmplymentTmp getMPWorkerEmplymentTmp() { select workerEmplymentTmp; return workerEmplymentTmp; } ////// /// public void processReport() { Query query; QueryRun queryRun; HcmWorker worker; HcmPersonPrivateDetails personPrivateDetails; MPLegalCommitment legalCommitment; HcmEmployment employment; RecordInsertList recordInsertList; FromDate fromDate; ToDate toDate; MPEmploymentStatus employmentStatus; MPWorkerEmploymentContract contract; contract = this.parmDataContract() as MPWorkerEmploymentContract; fromDate = contract.parmFromDate(); toDate = contract.parmToDate(); employmentStatus = contract.parmMPEmploymentStatus(); recordInsertList = new RecordInsertList(workerEmplymentTmp.TableId, true, true, true, false, true, workerEmplymentTmp); this.takeOwnershipOfTempTable(workerEmplymentTmp); query = this.parmQuery(); queryRun = new QueryRun(query); while(queryRun.next()) { worker = queryRun.get(tableNum(HcmWorker)); personPrivateDetails = queryRun.get(tableNum(HcmPersonPrivateDetails)); legalCommitment = queryRun.get(tableNum(MPLegalCommitment)); employment = queryRun.get(tableNum(HcmEmployment)); workerEmplymentTmp.PersonnelNumber = worker.PersonnelNumber; workerEmplymentTmp.BirthDate = personPrivateDetails.BirthDate; workerEmplymentTmp.Nationality = personPrivateDetails.NationalityCountryRegion; workerEmplymentTmp.Gender = personPrivateDetails.Gender; workerEmplymentTmp.JoiningDate = employment.ValidFrom; workerEmplymentTmp.EmploymentType = employment.EmploymentType; workerEmplymentTmp.GrossSalary = legalCommitment.GrossSalary; recordInsertList.add(workerEmplymentTmp); } recordInsertList.insertDatabase(); } }
my contract class
[ DataContractAttribute ] class MPWorkerEmploymentContract { private MPEmploymentStatus employmentStatus; FromDate fromDate; ToDate toDate; [ DataMemberAttribute('FromDate') ] public FromDate parmFromDate(FromDate _fromDate = fromDate) { fromDate = _fromDate; return fromDate; } [ DataMemberAttribute('ToDate') ] public ToDate parmToDate(ToDate _toDate = toDate) { toDate = _toDate; return toDate; } [DataMemberAttribute] public MPEmploymentStatus parmMPEmploymentStatus(MPEmploymentStatus _employmentStatus = employmentStatus) { employmentStatus = _employmentStatus; return employmentStatus; } ////// /// public boolean validate() { boolean ret = true; if (fromDate != dateNull() && toDate != dateNull() && fromDate > toDate) { ret = checkFailed("@SYS91020"); } if (!fromDate || !toDate) { //Both dates must be filled in. ret = checkFailed("@SYS71110"); } if (ret) { if (dateStartMth(fromDate) > dateEndMth(toDate)) { //From date cannot be greater than To date. ret = checkFailed("@SYS120590"); } } return ret; } }
here is how i can write in
1.status if it "Active worker"
2.
Thanks
Hi,
Below is just an example I searched in AOT where the value from the contract is used to update the query. you will need to do the same in your report. I am not sure what do you mean by validation. it is not validation but query manipulation.
you will find many more examples like this in OOB reports.
Thanks for your replay vinit,
yes!! is it custom report and i need it example of the validation.
Hi Riyas,
Is this custom report or OOB report? In your DP class where Query is getting initialized, you need to add/set the range for the date depending on the value from the contract. you will many examples in D365FO OOB reports for this. Please check those and if you still face issues, then please share your code and details about the report.
André Arnaud de Cal...
294,165
Super User 2025 Season 1
Martin Dráb
232,968
Most Valuable Professional
nmaenpaa
101,158
Moderator