rest - 通过 Acumatica REST API 从at获取PDF格式的报告输出

标签 rest pdf acumatica

是否可以通过 REST API 获取由于为特定屏幕调用的操作而生成的报告的 PDF 输出?

例如,我们希望为外部应用程序的用户提供在 Acumatica 的 AR 发票屏幕中为特定发票执行“打印发票/备忘录表单”操作的能力。他们希望通过通话获得 PDF 格式的发票表格。

如果没有这样的选项,也许有一种方法可以生成一个链接,将用户带到使用指定的参数值集执行的发票表单报告。 Acumatica 登录信息和报告参数值存储在外部应用程序中。

谢谢!

最佳答案

简短的回答是的,长的回答......不容易。

要实现您请求的功能,必须采取以下步骤。

首先在 AR 发票屏幕上创建一个操作,该操作将生成报告、保存并将其附加到文档。

public class ARInvoiceEntryExtension : PXGraphExtension<ARInvoiceEntry>
{
    public PXAction<ARInvoice> exportReport;
    [PXUIField(DisplayName = "Export Report")]
    [PXButton]
    public virtual IEnumerable ExportReport(PXAdapter adapter)
    {
        //Report Paramenters
        Dictionary<String, String> parameters = new Dictionary<String, String>();
        parameters["ARInvoice.DocType"] = Base.Document.Current.DocType;
        parameters["ARInvoice.RefNbr"] = Base.Document.Current.RefNbr;

        //Report Processing
        PX.Reports.Controls.Report _report = PXReportTools.LoadReport("AR641000", null);
        PXReportTools.InitReportParameters(_report, parameters,
                SettingsProvider.Instance.Default);
        ReportNode reportNode = ReportProcessor.ProcessReport(_report);

        //Generation PDF
        byte[] data = PX.Reports.Mail.Message.GenerateReport(reportNode,
        ReportProcessor.FilterPdf).First();

        PX.SM.FileInfo file = new PX.SM.FileInfo(reportNode.ExportFileName + ".pdf", null, data);

        UploadFileMaintenance graph = new UploadFileMaintenance();
        graph.SaveFile(file);
        PXNoteAttribute.AttachFile(Base.Document.Cache, Base.Document.Current, file);

        return adapter.Get();
    }
}

其次,您必须创建一个利用契约(Contract) API 的方法来查找发票、触发操作,然后检索附加到文档的文件。
class Program
{
    static void Main(string[] args)
    {
        AcumaticaProcessor processor = new AcumaticaProcessor();
        processor.Login();
        File[] result = processor.RetrieveReport("Invoice", "001007");
    }
}

public class AcumaticaProcessor
{
    DefaultSoapClient client = new DefaultSoapClient();

    public void Login()
    {
        client.Login("Username", "Password", "Company", "Branch", null);
    }

    public File[] RetrieveReport(string docType, string refNbr)
    {
        ARInvoice invoiceToFind = new ARInvoice()
        {
            Type = new StringSearch() { Value = docType },
            ReferenceNbr = new StringSearch() { Value = refNbr }
        };
        invoiceToFind = client.Get(invoiceToFind) as ARInvoice;

        InvokeResult result = client.Invoke(invoiceToFind, new ExportReport());


        return client.GetFiles(invoiceToFind) as File[];
    }
}

关于rest - 通过 Acumatica REST API 从at获取PDF格式的报告输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49319158/

相关文章:

java - 网络服务 : How do I detect the endpoint that sent the message

java - REST 从 jQuery : Method Not Allowed error 中删除

acumatica - 客户必填字段扩展到供应商等

ios - 从 Swift 函数中的异步调用返回数据

rest - Swagger 的 body 参数名称的用途是什么?

java - iText 变音符号(例如 D̂、M̂ 等)无法在 PDF 上正确显示

javascript - 如何将变量放入 PhantomJS 生成的 HTML 标题中以进行 PDF 转换?

Android PDF 从内部存储打开后立即关闭

Acumatica - 重写业务逻辑,访问 protected 方法

acumatica - 错误 #153 另一个进程添加了 'Note' 记录。您的更改将丢失(SalesOrderEntry)