Extend ARPaymentEntry Release Action

时间:2015-09-01 21:19:35

标签: acumatica

Hi I am trying to extend the ARPaymentEntry graph so I can do some extra stuff when the user releases the payment.

I have extended the paymententry graph and copied the Release action over like so

    public PXAction<ARPayment> release;
    [PXUIField(DisplayName = "Release", MapEnableRights = PXCacheRights.Update, MapViewRights = PXCacheRights.Update)]
    [PXProcessButton]
    public virtual IEnumerable Release(PXAdapter adapter)
    {

        PXCache cache = Base.Document.Cache;
        List<ARRegister> list = new List<ARRegister>();
        foreach (ARPayment ardoc in adapter.Get<ARPayment>())
        {
            if (!(bool)ardoc.Hold)
            {
                cache.Update(ardoc);
                list.Add(ardoc);
            }
        }
        if (list.Count == 0)
        {
            throw new PXException(Messages.Document_Status_Invalid);
        }
        Base.Save.Press();

        PXLongOperation.StartOperation(this, delegate()
        {
            if (SyncPaymentToRex(list))
            {
                ARDocumentRelease.ReleaseDoc(list, false);
            }
        });

        return list;
    }

If you look at the PXLongOperation I have a my own method I want to pass before it goes and releases the document.

Now this works for me but there is no user feedback on the screen (e.g. the controls arent disabled, no processing icon appears while its performing the operation etc) and also the screen doesnt reload, I have to manually reload the page before I can see the payment has been release etc

Can I get some help so I can get the page updating and reacting like it usually does on release but with my code in there as well?

1 个答案:

答案 0 :(得分:1)

试试这个

     public PXAction<ARPayment> release;


  [PXUIField(DisplayName = "Release", MapEnableRights = PXCacheRights.Update, MapViewRights = PXCacheRights.Update)]
    [PXProcessButton]
    [PXOverride]
    public virtual IEnumerable Release(PXAdapter adapter)
    {

        PXCache cache = Base.Document.Cache;
        List<ARRegister> list = new List<ARRegister>();
        foreach (ARPayment ardoc in adapter.Get<ARPayment>())
        {
            if (!(bool)ardoc.Hold)
            {
                cache.Update(ardoc);
                list.Add(ardoc);
            }
        }
        if (list.Count == 0)
        {
            throw new PXException(Messages.Document_Status_Invalid);
        }
        Base.Save.Press();

        PXLongOperation.StartOperation(this.Base, delegate()
        {
            if (SyncPaymentToRex(list))
            {
                ARDocumentRelease.ReleaseDoc(list, false);
            }
        });

        return list;
    }