[英]Post a Report in a Sharepoint folder
I have been working in project that create a folder through Business Central when you click on an Action.当您单击一个操作时,我一直在通过 Business Central 创建一个文件夹的项目中工作。 It's working fine, but now I wanted to when I click in the Action it send the Report, in Page Item Card(30), to my folder in the Sharepoint. I created a procedure to do that, but the problem its when I try to open the Report(PDF) on Sharepoint, it says "looks like the file don't have a preview we can show you."它工作正常,但现在我想在单击操作时将页面项目卡 (30) 中的报告发送到我在 Sharepoint 中的文件夹。我创建了一个程序来执行此操作,但问题出在我尝试时打开 Sharepoint 上的报告 (PDF),它说“看起来文件没有我们可以给你看的预览。” Here is the procedure that Im using.这是我使用的程序。
procedure UploadFile(AccessToken: Text; Url: Text; Item: Record Item): Boolean
var
Client: HttpClient;
Headers: HttpHeaders;
RequestMessage: HttpRequestMessage;
ResponseMessage: HttpResponseMessage;
RequestContent: HttpContent;
ResponseText: Text;
IsSucces: Boolean;
Item_Vendor_Catalog: Report "Item/Vendor Catalog";
ItemVendor: Record "Item Vendor";
Json1: JsonObject;
out: OutStream;
ins: InStream;
RecRef: RecordRef;
TempBlob_lRec: Codeunit "Temp Blob";
FileManagement_lCdu: Codeunit "File Management";
Base64: Codeunit "Base64 Convert";
begin
Headers := Client.DefaultRequestHeaders();
Headers.Add('Authorization', StrSubstNo('Bearer %1', AccessToken));
Headers.Add('Accept', 'application/json;odata=nometadata');
ItemVendor.Get(Item."Vendor No.", Item."No.");
Item_Vendor_Catalog.SetTableView(ItemVendor);
RequestMessage.SetRequestUri(Url);
RequestMessage.Method('POST');
TempBlob_lRec.CreateOutStream(out, TEXTENCODING::UTF8);
RecRef.Get(ItemVendor.RecordId);
Report.SaveAs(Report::"Item/Vendor Catalog", '', ReportFormat::Pdf, out);
TempBlob_lRec.CreateInStream(ins, TEXTENCODING::UTF8);
// ins.Read(out);
// Message(Base64.ToBase64(ins));
// Message('out ' + Format(out));
// Message('ins ' + Format(ins));
System.CopyStream(out, ins);
RequestContent.WriteFrom(ins);
RequestMessage.Content(RequestContent);
if Client.Send(RequestMessage, ResponseMessage) then
if ResponseMessage.IsSuccessStatusCode() then begin
if ResponseMessage.Content.ReadAs(ResponseText) then
IsSucces := true;
end else
ResponseMessage.Content.ReadAs(ResponseText);
end;
I don't think your report is actually getting generated.我认为您的报告实际上并未生成。 I would add a variable Parameters: Text
and make the following changes我会添加一个变量Parameters: Text
并进行以下更改
Item_Vendor_Catalog.SetTableView(ItemVendor);
Parameters := Item_Vendor_Catalog.RunRequestPage();
...
Report.SaveAs(Report::"Item/Vendor Catalog", Parameters, ReportFormat::Pdf, out);
You can remove this line of code RecRef.Get(ItemVendor.RecordId);
您可以删除这行代码RecRef.Get(ItemVendor.RecordId);
and I think it should work.我认为它应该有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.