Good day.
My client needs a new report and for the report I have to check customer and vendor attachments.
When I test the table selection in a job, the DocuRef.TypeId has a value, but when I print the report the field is empty.
The report has no special design, it is just a simple table.
I need the TypeId for the if statement, but it looks as it never fetches the value.
I created a table "testTable" for testing to see what values are fetched and after I execute the report I see that TypeId is empty in all rows but the table DocuRef itself has no row with an empty TypeId field.
I am doing something wrong but I just can't see the error.
I hope you could help me.
Code below.
X++:
public void processReport()
{
CustTable custTable;
VendTable vendTable;
DocuRef docuRef;
LogisticsPostalAddress postalAddress;
DirPartyLocation partyLocation;
LogisticsAddressCountryRegion addressCountryRegion;
CustVendAC custVendAcc;
utcDateTime startDateTime, endDateTime;
TestTable_t testTable;
#define.SPP('URL')//TODO:Testing
startDateTime = DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::getSystemDateTime(), DateTimeUtil::getCompanyTimeZone());
endDateTime = DateTimeUtil::addYears(startDateTime, -1);
while select createdBy, createdDateTime, TypeId from docuRef
where docuRef.RefTableId == tableNum(CustTable) &&
docuRef.RefCompanyId == curext() &&
(docuRef.createdDateTime >= startDateTime &&
docuRef.createdDateTime <= endDateTime &&
docuRef.TypeId == #SPP) || docuRef.TypeId != #SPP
join AccountNum, Party from custTable
where custTable.RecId == docuRef.RefRecId &&
custTable.Blocked == CustVendorBlocked::No
exists join partyLocation
where partyLocation.IsPrimary == true &&
partyLocation.Party == custTable.Party
exists join postalAddress
where postalAddress.Location == partyLocation.Location
exists join addressCountryRegion
where addressCountryRegion.CountryRegionId == postalAddress.CountryRegionId &&
addressCountryRegion.SanctionedCountry_mb == NoYes::Yes
{
tmpCustVendListTable.clear();
testTable.clear();
if (custVendAcc != custTable.AccountNum)
{
custVendAcc = custTable.AccountNum;
}
else
{
if (docuRef.TypeId != #SPP)
continue;
}
tmpCustVendListTable.BPAccountNum = custVendAcc;
tmpCustVendListTable.BPName = custTable.name();
testTable.BPAccountNum = custVendAcc;
testTable.BPName = custTable.name();
testTable.TypeId = docuRef.TypeId;
if (docuRef.TypeId == #SPP)
{
tmpCustVendListTable.ResponsibleUser = XUserInfo::find(false, docuRef.createdBy).name;
tmpCustVendListTable.ScreeningDateTime = docuRef.createdDateTime;
testTable.ResponsibleUser = XUserInfo::find(false, docuRef.createdBy).name;
testTable.ScreeningDateTime = docuRef.createdDateTime;
}
tmpCustVendListTable.insert();
testTable.insert();
}
}