
Hi All,
I have a requirement in D365 FO to implement a new Custom report on Transfer orders with Print management setup for that . I have followed below steps but facing the issue when the code hits formletterreport.Loadprintsetting() in controller class.
Please suggest if any code changes are required.
Created new Enum elements
Base Enums\PrintMgmtNodeType-> TransferOrderInvoice
Base Enums\PrintMgmtDocumentType -> TransferOrderInvoice
Updated code in below classes
Classes\PrintMgmtHierarchy_Invent_Extension -> getNodesImplementation()
,getParentImplementation()
Created a new class as below and added 4 methods as required
[PrintMgmtDocumentTypeFactoryAttribute(PrintMgmtDocumentType::TransferOrderInvoice)]
class InventFormLetterReport_TransferOrderInvoice extends FormLetterReport
Created a new class to implement delegate methods for Class -> PrintMgmtDocType methods -> getDefaultReportFormatDelegate(),getQueryRangeFieldsDelegate(),getQueryTableIdDelegate()
Created new class and added below code
[SubscribesTo(classStr(PrintMgmtDelegates), delegateStr(PrintMgmtDelegates, constructPrintMgmtNodeDelegate))]
public static void PrintMgmtDelegates_constructPrintMgmtNodeDelegate(PrintMgmtNodeType _nodeType, EventHandlerResult _result)
{
switch(_nodeType)
{
case PrintMgmtNodeType::TransferOrderInvoice :
_result.result(new PrintMgmtNode_TransferOrderInvoice());
break;
}
}
Created a new class and written code to populate report designs
class PrintMgmtReportFormatPublisherHelper
{
/// <summary>
///
/// </summary>
[SubscribesTo(classStr(PrintMgmtReportFormatPublisher), delegateStr(PrintMgmtReportFormatPublisher, notifyPopulate))]
public static void PrintMgmtReportFormatPublisher_notifyPopulate()
{
//code
}
Created a new controller class with below method
protected void runPrintMgmt()
{
formLetterReport.loadPrintSettings(mytablebuffer, -> here facing the issue
mytablebuffer,CompanyInfo::languageId());
this.parmReportContract().parmRdlContract().parmLanguageId(CompanyInfo::languageId());
this.parmReportContract().parmRdlContract().parmLabelLanguageId(CompanyInfo::languageId());
}
When i debug the code , i found that the below code is iterating and never coming out of while loop because of empty parmReferencedTableBuffer
class -> PrintMgmt Method ->getnodeInstance() ,
// If parentBuffer is null and should not be, move to up until we find a valid parent. It is possible
// for certain nodes to not reference any data and they should be skipped when traversing the hierarchy.
while (parentInstance != null && !parentInstance.isValidReference())
{
parentInstance = hierarchy.getParent(parentInstance, documentType);
}
I have tried changing the code as below , but still the same issue
Classes\PrintMgmtHierarchy_Invent_Extension
protected PrintMgmtNodeInstance getParentImplementation(PrintMgmtNodeInstance _nodeInstance, PrintMgmtDocumentType _docType)
{
// Find the appropriate parent
PrintMgmtNodeInstance result;
InventTransferTable transfertable;
result = next getParentImplementation(_nodeInstance,_docType);
// Get the node instance type
switch (_nodeInstance.parmNodeDefinition().getNodeType())
{
case PrintMgmtNodeType::TransferOrderInvoice:
transfertable = _nodeInstance.parmReferencedTableBuffer();
result.parmReferencedTableBuffer(transfertable.selectRefRecord(fieldnum(InventTransferTable, TransferId)));
//result.parmReferencedTableBuffer(null);
result.parmNodeDefinition(PrintMgmtNode::construct(PrintMgmtNodeType::TransferOrderInvoice));
break;
}