【问题标题】:How to Automate Extend To Vendor via Customer Import Scenario如何通过客户导入场景自动扩展到供应商
【发布时间】:2017-11-07 01:01:11
【问题描述】:

如何在 Acumatica 中通过 Import Scenario 引入同时归类为 Customer 和 Vendor 的 Business Account?

【问题讨论】:

    标签: c# acumatica acumatica-kb


    【解决方案1】:

    开箱即用的Extend To Vendor 操作无法在导入方案中使用,因为它会重定向到带有预填充数据的供应商屏幕,并且用户必须手动保存供应商。

    在下面的代码 sn-p 中,我们正在创建一个新的隐藏操作,它调用基本的将客户扩展到供应商操作并保留供应商数据而不是重定向到供应商屏幕。

    using System;
    using System.Collections;
    using PX.Data;
    using PX.Objects.AR;
    
    namespace PXExtendCustomerToVendorExtPkg
    {
        public class CustomerMaintPXExt : PXGraphExtension<CustomerMaint>
        {
            public PXAction<Customer> extendToVendorPXExt;
            [PXUIField(DisplayName = "Extend To Vendor Ext",
                       MapEnableRights = PXCacheRights.Select, 
                       MapViewRights = PXCacheRights.Select, 
                       Visible = false)]
            [PXButton]
            public virtual IEnumerable ExtendToVendorPXExt(PXAdapter adapter)
            {
                try
                {
                    if (Base.extendToVendor.GetEnabled())
                        Base.extendToVendor.Press();
                }
                catch (Exception ex)
                {
                    if (ex is PXRedirectRequiredException)
                    {
                        PXRedirectRequiredException rdEx = (PXRedirectRequiredException)ex;
                        rdEx.Graph.Actions.PressSave();
                    }
                    else
                        throw ex;
                }
                return adapter.Get();
            }
        }
    }
    

    发布自定义后,将Import Scenario修改为Customers(SM206025),并在Save Action后添加新的Extend To Vendor Ext action。

    Download Customization Package

    【讨论】:

      【解决方案2】:

      DChhapgar 非常好的解决方案。以下是在 Acumatica 21R1 中工作的修改版本,因为 Acumatica 进行了一些修改:各自的 ExtendToCustomerExtendToVendor PXGraphExtension(s) 是在以下条件下创建的: p>

      App_Data\CodeRepository\PX.Objects\Extensions\ExtendBAccount

      因此需要先获取扩展名var graphExt = Base.GetExtension&lt;ExtendToCustomer&gt;();。下面的代码用于从 BusinessAccount 扩展到客户,这也在保存之前对客户进行了一些更改(在代码中注释)。扩展到供应商的概念是相同的。

      using PX.Data;
      using PX.Objects.AR;
      using System;
      using System.Collections;
      using static PX.Objects.CR.BusinessAccountMaint;
      
      namespace PX.Objects.CR
      {
          public class IBBusinessAccountMaintExt : PXGraphExtension<BusinessAccountMaint>
          {
              public PXAction<BAccount> extendToCustomerPXExt;
              [PXUIField(DisplayName = "Extend As Customer Ext", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Visible = false)]
              [PXButton]
              public virtual IEnumerable ExtendToCustomerPXExt(PXAdapter adapter)
              {
                  try {
                      var graphExt = Base.GetExtension<ExtendToCustomer>();
                      if (graphExt.extendToCustomer.GetEnabled()) { graphExt.extendToCustomer.Press(); }
                  } catch (Exception ex) {
                      if (ex is PXRedirectRequiredException) {
                          PXRedirectRequiredException rdEx = (PXRedirectRequiredException)ex;
                          
                          // If there is a need to make changes in new Graph
                          CustomerMaint editCustomer = (CustomerMaint)rdEx.Graph;
                          //editCustomer.CurrentCustomer.SetValueExt<Customer.paymentsByLinesAllowed>(editCustomer.BAccount.Current, true);
      
                          rdEx.Graph.Actions.PressSave();
                      } else
                          throw ex;
                  }
                  return adapter.Get();
              }
          }
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-11-02
        • 1970-01-01
        • 2017-05-05
        • 2016-06-25
        • 2019-02-18
        • 1970-01-01
        • 1970-01-01
        • 2018-03-24
        相关资源
        最近更新 更多