Hi,
I have requirement to read data from xml file and insert the data into the custom table.
This xml file is daily updated into the location.So,I need to automated the process.
Anyone can suggest resources or workaround for that.
Hi,
I have requirement to read data from xml file and insert the data into the custom table.
This xml file is daily updated into the location.So,I need to automated the process.
Anyone can suggest resources or workaround for that.
Best answer by davidnavasardyan
Hello
Acumatica allows for automating these kinds of tasks. I suggest you implement a scheduled processing screen for this, where you can read the XML file and insert its data into the custom table. Here's a general guideline to achieve this:
PXGraph
) with an action that reads the XML file and writes its contents into your custom table.public class ReadXMLProcess : PXGraph<ReadXMLProcess>
{
public PXCancel<XMLFile> Cancel;
public PXProcessing<XMLFile> Files;
public ReadXMLProcess()
{
Files.SetProcessDelegate(ProcessFile);
}
public static void ProcessFile(List<XMLFile> files)
{
foreach (var file in files)
{
// Add logic to read XML file, deserialize it into a class,
// and then insert data into your custom table
// You can use System.Xml.Serialization.XmlSerializer to deserialize XML
// and use PXCache to insert into your custom table
}
}
}
[Serializable]
public class XMLFile : IBqlTable
{
#region FileID
public abstract class fileID : PX.Data.BQL.BqlInt.Field<fileID> { }
[PXDBIdentity]
public virtual int? FileID { get; set; }
#endregion
#region FileName
public abstract class fileName : PX.Data.BQL.BqlString.Field<fileName> { }
[PXDBString(200, IsUnicode = true)]
[PXUIField(DisplayName = "File Name")]
public virtual string FileName { get; set; }
#endregion
// Add other fields needed to represent your XML file
}
Schedule the Process: In Acumatica, you can schedule your process to run at specific intervals. You can do this from the Automation Schedules (SM205020) screen. Use your processing graph (ReadXMLProcess) and set the desired frequency.
Read XML and Insert into Custom Table: You need to implement the logic to read the XML file and insert its data into your custom table within the ProcessFile
delegate.
To read the XML file, you can use the System.Xml.XmlDocument
class or System.Xml.Linq.XDocument
class in .NET. You would typically read the file into a string
or Stream
, load that into the XmlDocument
or XDocument
, and then query the data you need using XPath or LINQ to XML.
To insert data into the custom table, use the Insert
method on the PXCache
object for your custom DAC. You get the PXCache
object by calling this.Caches[typeof(YourDAC)]
in your graph.
This is a general outline of the process and you would need to customize it to fit your needs. Ensure to add appropriate error handling and reporting so you can track the process and handle any issues that arise.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.