Skip to main content
Answer

Save records to a different table.

  • January 10, 2024
  • 2 replies
  • 175 views

Forum|alt.badge.img

Hi Team,

I need to save some data into an another table in the DB. I created a table in the DB and also created a DAC. 

Can someone please help me?

public PXSelect<CISTaxSubmittedData> cisTaxSubmittedData;

[PXButton(CommitChanges = true)]
        [PXUIField(DisplayName = "Submit Tax Report", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Enabled = false)]
        protected virtual IEnumerable submitTaxReport(PXAdapter adapter)
        {

             need to save data to the cisTaxSubmittedData

             return adapter.Get();

        }

 

Best answer by Django

In that line of code you’re going to create an instance of the graph used to manage those records.

Something like:

YourGraph graph = PXGraph.CreateInstance<YourGraph>();
YourDAC record = (YourDAC)graph.graphView.Insert(new YourDAC());
record.field = somevalue;
record.field2 = somevalue;
record = (YourDAC)graph.graphView.Cache.Update(record);
graph.Save.Press();

If you’re planning to update an existing record then instead of the .Insert line, you’ll locate the record you want to update and then set the new field values, call .Update and then save.

2 replies

Forum|alt.badge.img+7
  • Captain II
  • Answer
  • January 10, 2024

In that line of code you’re going to create an instance of the graph used to manage those records.

Something like:

YourGraph graph = PXGraph.CreateInstance<YourGraph>();
YourDAC record = (YourDAC)graph.graphView.Insert(new YourDAC());
record.field = somevalue;
record.field2 = somevalue;
record = (YourDAC)graph.graphView.Cache.Update(record);
graph.Save.Press();

If you’re planning to update an existing record then instead of the .Insert line, you’ll locate the record you want to update and then set the new field values, call .Update and then save.


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • January 11, 2024

In that line of code you’re going to create an instance of the graph used to manage those records.

Something like:

YourGraph graph = PXGraph.CreateInstance<YourGraph>();
YourDAC record = (YourDAC)graph.graphView.Insert(new YourDAC());
record.field = somevalue;
record.field2 = somevalue;
record = (YourDAC)graph.graphView.Cache.Update(record);
graph.Save.Press();

If you’re planning to update an existing record then instead of the .Insert line, you’ll locate the record you want to update and then set the new field values, call .Update and then save.

Thank you very much @Django