Extend the node for
your document type
There are already so called node-classes for
various standard types and you just need to find the right one for your target
module. In this example: Sales.
Step 2:
The second step should be to extend the PrintMgmtNode class
based on the module where you want to add the custom document. We will add a
document to the accounts receivable print management configuration as an
example.
Code:
/// <summary>/
/// Get Document type that we created
/// </summary>
[ExtensionOf(classStr(PrintMgmtNode_Sales))]
final class PrintMgmtNode_Sales_Extension
{
public List getDocumentTypes()
{
List docuTypes;
docuTypes = new List(Types::Enum);
docuTypes = next getDocumentTypes();
docuTypes.addEnd(PrintMgmtDocumentType::CustomDocument);
return docuTypes;
}
}
Step 3: For this business document you should add a
default report in the Printer Management setup. To add a default report we
should subscribe to the NotifyPopulate method of PrintMgmtReportFormatPublisher class and add the following code.
Code:
/// <summary>/
/// Get Document type that we created
/// </summary>
public class
PrintMgmtReportFormatPublisherHelper
{
///
<summary>/;
/// Insert a default report to custom
document
/// </summary>
[SubscribesTo(classstr(PrintMgmtReportFormatPublisher),
delegatestr(PrintMgmtReportFormatPublisher, notifyPopulate))]
public static void notifyPopulate()
{
#PrintMgmtSetup
void addFormat(PrintMgmtDocumentType _type, PrintMgmtReportFormatName _name,
PrintMgmtReportFormatCountryRegionId _countryRegionId = #NoCountryRegionId)
{
PrintMgmtReportFormatPublisherHelper::addPrintMgmtReportFormat(_type, _name,
_name,
_countryRegionId);
}
addFormat(PrintMgmtDocumentType::CustomDocument,
ssrsReportStr(CustomReport, Report));
}
private static void addPrintMgmtReportFormat(
PrintMgmtDocumentType _type,
PrintMgmtReportFormatName _name,
PrintMgmtReportFormatDescription _description,
PrintMgmtReportFormatCountryRegionId _countryRegionId,
PrintMgmtReportFormatSystem _system = false,
PrintMgmtSSRS _ssrs = PrintMgmtSSRS::SSRS)
{
PrintMgmtReportFormat printMgmtReportFormat;
select firstonly printMgmtReportFormat
where printMgmtReportFormat.DocumentType == _type
&& printMgmtReportFormat.Description == _description
&& printMgmtReportFormat.CountryRegionId == _countryRegionId;
if (!printMgmtReportFormat)
{
// Add the new format
printMgmtReportFormat.clear();
printMgmtReportFormat.DocumentType = _type;
printMgmtReportFormat.Name = _name;
printMgmtReportFormat.Description = _description;
printMgmtReportFormat.CountryRegionId = _countryRegionId;
printMgmtReportFormat.System = _system;
printMgmtReportFormat.ssrs = _ssrs;
printMgmtReportFormat.insert();
}
}
}
Code:
/// <summary>/;
/// Associate new print management document type with a default report design
/// </summary>
Public class PrintMgmtDocTypeEventHandler
{
[SubscribesTo(classStr(PrintMgmtDocType), delegateStr(PrintMgmtDocType,
getDefaultReportFormatDelegate))]
public static void getDefaultReportFormat(PrintMgmtDocumentType _docType,
EventHandlerResult
_result)
{
switch (_docType)
{
case PrintMgmtDocumentType::CustomDocument:
_result.result(ssrsReportStr(CustomReport, Report));
break;
}
}
[SubscribesTo(classStr(PrintMgmtDocType), delegateStr(PrintMgmtDocType,
getQueryTableIdDelegate))]
Public static void PrintMgmtDocType_getQueryTableIdDelegate(PrintMgmtDocumentType _docType,
EventHandlerResult _result)
{
TableId tableId;
switch (_docType)
{
case PrintMgmtDocumentType::CustomDocument:
tableId = tableNum(CustomReportTemp);
_result.result(tableId);
break;
}
}
}
No comments:
Post a Comment