Bikash Lama
Bikash Lama

Reputation: 187

Add custom table record

I have been trying to add custom DAC record which is the in database. But it is now working. Here is how I have tried to accomplish.

    public class SquarePOSTransactionInquiry : PXGraph<SquarePOSTransactionInquiry>
{

    public PXSave<MasterTable> Save;
    public PXCancel<MasterTable> Cancel;


    public PXFilter<MasterTable> MasterView;
    public PXSelect<INSquarePOSTransaction> INSquarePOSTransactions;

    public PXAction<MasterTable> calc;

    [PXUIField(DisplayName = "Sync Square Transactions")]
    [PXProcessButton()]
    protected virtual IEnumerable Calc(PXAdapter adapter)
    {
        PXLongOperation.StartOperation(this, () =>
        {
            using (var scope = new PXTransactionScope())
            {
                INSquarePOSTransaction trans = new INSquarePOSTransaction();
                trans.TransacationCD = "new";
                trans.Description = "Another new";
                var test = this.INSquarePOSTransactions.Insert(trans);
                this.INSquarePOSTransactions.Cache.IsDirty = true;
                //this.INSquarePOSTransactions.Update(trans);
                this.Actions.PressSave();
                scope.Complete();
            }

        });
        return adapter.Get();
    }

    public SquarePOSTransactionInquiry()
    {

    }

    [Serializable]
    public class MasterTable : IBqlTable
    {

    }
}

I tried setting cache IsDirty property to false, but that didn't help too. But the strange part is updating the DAC is working. I have even looked into other Business Logic codes from other pages and it looks same like I have tried above. Could you please tell me what I am missing?

Thanks.

Upvotes: 0

Views: 348

Answers (1)

Ilya Kalmykov
Ilya Kalmykov

Reputation: 216

Within the method that you pass to StartOperation(), you have to create a new instance of the graph and invoke the processing method on that instance.

Upvotes: 1

Related Questions