In Batch Payment (AR305000) how can i export xml file include Reference Nbr, payment date, payment method using grid button. any one know solution ?
In Batch Payment (AR305000) how can i export xml file include Reference Nbr, payment date, payment method using grid button. any one know solution ?
Best answer by tharinduweerasooriya90
This is the answer
public PXAction<PX.Objects.CA.CABatch> Attach;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Attach")]
protected virtual IEnumerable attach(PXAdapter adapter)
{
// Use your favorite library to create XML file
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.AppendChild(xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", null));
// Create root node of XML file
XmlNode rootNode = xmlDoc.CreateElement("GridData");
// Iterate rows of the DataView
foreach (CABatchDetail dacRecord in Base.BatchPayments.Select())
{
// Create an XML Element to represent the DAC row
XmlNode xmlDACRecord = xmlDoc.CreateElement("DACRecord");
// Add desired DAC fields as child XML Elements of the DAC row XML element
XmlNode xmlDACField1 = xmlDoc.CreateElement("DACField1");
xmlDACField1.AppendChild(xmlDoc.CreateTextNode(dacRecord.OrigRefNbr.ToString()));
xmlDACRecord.AppendChild(xmlDACField1);
XmlNode xmlDACField2 = xmlDoc.CreateElement("DACField2");
xmlDACField2.AppendChild(xmlDoc.CreateTextNode(dacRecord.OrigDocType.ToString()));
xmlDACRecord.AppendChild(xmlDACField2);
// Adding XML DAC Record to XML root node
rootNode.AppendChild(xmlDACRecord);
}
// Adding XML root node to XML document
xmlDoc.AppendChild(rootNode);
// Redirect browser to XML file created in memory on server
throw new PXRedirectToFileException(new PX.SM.FileInfo(Guid.NewGuid(),
"filename.xml",
null,
System.Text.Encoding.UTF8.GetBytes(xmlDoc.OuterXml)),
true);
return adapter.Get();
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.