0

Good day

I have an Import scenario that executes an action that I wrote. The action does work when I click it on the customer screen but when I try to execute it from an import scenario its as if it doesn't execute. I have added a breakpoint in C# to see if it ever executes but it doesn't "break".

Here is the code i am trying to execute:

   public PXAction<Customer> UpdateCreditRemaining;

        [PXButton(CommitChanges = true)]
        [PXUIField(DisplayName = "Recalculate Credit details")]
        protected void updateCreditRemaining()
        {
            try
            {
                Customer row = (Customer)this.Base.BAccount.Current;
                BAccountExt curBAccountExt = row.GetExtension<BAccountExt>();

                curBAccountExt.UsrUpdateDateTime = DateTime.Now.ToString();
                Base.BAccount.Update(row);
               // Base.Persist();

            }
            catch(Exception ex)
            { }
        }

Here is my import Scenario enter image description here

Hope someone has had the same problem and can help.

JvD
  • 473
  • 3
  • 18

1 Answers1

1

You have not updated the record with your DAC Extension object, nor have you saved it. Try this...

Base.BAccount.Update(curBAccountExt);
Base.Save.Press();

Once you update your code, try adding as a button to the page, and then press the button to see if it works as expected. Generally speaking, if it works as a button, then it should work in the import scenario.

Your code, updated:

public PXAction<Customer> UpdateCreditRemaining;

    [PXButton(CommitChanges = true)]
    [PXUIField(DisplayName = "Recalculate Credit details")]
    protected void updateCreditRemaining()
    {
        try
        {
            Customer row = (Customer)Base.BAccount.Current;
            BAccountExt curBAccountExt = row.GetExtension<BAccountExt>();

            curBAccountExt.UsrUpdateDateTime = DateTime.Now.ToString();
            Base.BAccount.Update(curBAccountExt);
            Base.Save.Press();

        }
        catch(Exception ex)
        { }
    }
Brian Stevens
  • 1,826
  • 1
  • 7
  • 16