Hello everyone.
I would like to get data from the ListPart "Sales Invoice Subform".
What I want to do is to get the data and put it in an xml.
I have the following code.
I hope you can help me, thanks.
codeunit 50901 "XMLtestSUBFORM" { procedure XMLv4(RecordCurr: Record "Sales Header") var v_XMLDoc: XmlDocument; v_XMLDec: XmlDeclaration; v_RootNode: XmlElement; v_ParentNode: XmlElement; v_TempBlob: Codeunit "Temp Blob"; v_Instr: InStream; v_OutStr: OutStream; v_ReadTxt: Text; v_Writetxt: Text; v_Emisor: Record "Company Information"; v_customer: Record Customer; v_salesH: Record "Sales Header"; DatosActuales: Record "Sales Header"; begin DatosActuales := RecordCurr; DatosActuales.SetRecFilter(); v_XMLDoc := XmlDocument.Create(); v_XMLDec := XmlDeclaration.Create('1.0', 'UTF-8', 'no'); v_XMLDoc.SetDeclaration(v_XMLDec); v_Emisor.Get(); v_ParentNode := XmlElement.Create('Emisor', 'http://www.sat.gob.mx/cfd/4'); v_RootNode.Add(v_ParentNode); v_ParentNode.SetAttribute('Name', v_Emisor.Name); v_ParentNode.SetAttribute('Rfc', v_Emisor."RFC No."); v_salesH.FindSet(); v_ParentNode := XmlElement.Create('Receptor', 'http://www.sat.gob.mx/cfd/4'); v_RootNode.Add(v_ParentNode); v_ParentNode.SetAttribute('Name', DatosActuales."Bill-to Name"); v_ParentNode.SetAttribute('Code', DatosActuales."CFDI Export Code"); v_TempBlob.CreateInStream(v_Instr); v_TempBlob.CreateOutStream(v_OutStr); v_XMLDoc.WriteTo(v_OutStr); v_OutStr.WriteText(v_Writetxt); v_Instr.ReadText(v_Writetxt); v_ReadTxt := 'name_CFDI40.XML'; DownloadFromStream(v_Instr, '', '', '', v_ReadTxt); end; }
Hi, I agree with Nitin.
If this is a new action you added to the screen, you can directly add it in "Sales Invoice Subform", which will be much easier.
For example,
Hope this helps as well.
Thanks.
ZHU
Hi,
you can create a xmlport direcly from sales line table and use that xmlport to export the data.
thanks
Hello - We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist. If you need assistance with debugging or coding I would recommend discussing this on one of our communities.
I will open this up to the community in case they have something to add.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,151 Super User 2024 Season 2
Martin Dráb 229,993 Most Valuable Professional
nmaenpaa 101,156