Обновление Acumatica с 18.210 до 18.217 (Невозможно привести объект типа 'PX.Data.PXResult`2 [PX.Objects.FS.FSServiceOrder, PX.Objects.AR.Customer]' - PullRequest
0 голосов
/ 19 февраля 2020

Исходный код действия кнопки:

public PXAction<FSServiceOrder> CreateSalesOrder;
        [PXUIField(DisplayName = "Create Sales Order", Enabled = true, MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
        [PXProcessButton]

        public virtual IEnumerable createSalesOrder(PXAdapter adapter)
        {
            foreach (FSServiceOrder fso in adapter.Get())
            {
                Customer cust = (Customer)PXSelect<Customer, Where<Customer.bAccountID, Equal<Current<FSServiceOrder.customerID>>>>.Select(this.Base);
                if (cust == null)
                {
                    string exc = "Invalid customer ID";
                    throw new PXException(exc);
                }
                yield return fso;
            }
            SOOrderEntry docgraph = PXGraph.CreateInstance<SOOrderEntry>();
            PXLongOperation.StartOperation(Base, delegate ()
            {
                Customer customer = (Customer)PXSelect<Customer, Where<Customer.bAccountID, Equal<Current<FSServiceOrder.customerID>>>>.Select(this.Base);
                FSServiceOrder fsServiceORderRow = this.Base.ServiceOrderRecords.Current;
                FSSODetPart rows = this.Base.ServiceOrderDetParts.Current;

                CurrencyInfo info = PXSelect<CurrencyInfo, Where<CurrencyInfo.curyInfoID, Equal<Current<FSServiceOrder.curyInfoID>>>>.Select(this.Base);
                info.CuryInfoID = null;
                bool createso = false;
                foreach (FSSODetPart parts in SelectItems(fsServiceORderRow.RefNbr))
                {
                    if (parts == null)
                    {
                        createso = false;
                    }
                    else
                    {
                        createso = true;
                    }
                }

                if (createso == true)
                {
                    SOOrder doc = new SOOrder();                    
                    doc.OrderType = "SM";
                    doc = docgraph.Document.Insert(doc);
                    doc.OrderDate = fsServiceORderRow.OrderDate;
                    doc.CustomerRefNbr = fsServiceORderRow.RefNbr;
                    doc.CustomerOrderNbr = fsServiceORderRow.CustPORefNbr;
                    nbr = fsServiceORderRow.RefNbr;
                    doc.OrderDesc = fsServiceORderRow.DocDesc;
                    doc.TermsID = customer.TermsID;
                    doc.CustomerID = fsServiceORderRow.CustomerID;
                    doc = docgraph.Document.Update(doc);

                    foreach (FSSODetPart parts in SelectItems(fsServiceORderRow.RefNbr))
                    {
                        if (parts == null) return;
                        SOLine tran = new SOLine();
                        tran = docgraph.Transactions.Insert(tran);
                        if (tran != null)
                        {
                            tran.InventoryID = parts.InventoryID;
                            tran.SubItemID = parts.SubItemID;
                            tran.OrderQty = parts.OrderQty;
                            tran.UOM = parts.UOM;
                            tran.CuryUnitPrice = parts.CuryUnitPrice;
                            tran.TaxCategoryID = parts.TaxCategoryID;
                            tran.SiteID = parts.SiteID;
                            tran.LocationID = parts.LocationID;
                            tran.IsFree = parts.IsFree;
                            tran.ProjectID = parts.ProjectID;
                            tran.TaskID = parts.TaskID;
                            tran.ManualPrice = parts.ManualPrice;
                        }
                        tran = docgraph.Transactions.Update(tran);
                    }
                    docgraph.Save.Press();
                    docgraph.Document.Current = docgraph.Document.Search<SOOrder.orderNbr, SOOrder.orderType>(doc.OrderNbr, doctype);                    
                }
            });
        }```
While the error being displayed in trace is

19/02/2020 7:53:31 AM Ошибка: невозможно привести объект типа 'PX.Data.PXResult`2 [PX. Objects.FS.FSServiceOrder, PX.Objects.AR.Customer] 'для ввода' PX.Objects.FS.FSServiceOrder '.

в PX.Objects.FS.ServiceOrderEntry_Extension.d__3.MoveNext () в PX. Data.PXAction 1.d__32.MoveNext() at PX.Data.PXAction 1.d__32.MoveNext () в PX.Data.PXAction 1.d__32.MoveNext() at PX.Data.PXAction 1.d__32.MoveNext () в PX.Web.UI.PXBaseDataSource.tryExecutePendingCommand (String viewName, String [] sortcolumns, Boolean [] ] по убыванию, поиск Object [], параметры Object [], фильтры PXFilterRow [], аргументы DataSourceSelectArguments, логические значения & closeWindowRequired, Int32 & adapterStartRow, Int32 & adapterTotalRows) в PX.Web.UI.PXBaseDataSource.ExecuteSelect (аргументы аргумента PSCSguguignSameguide_SelectguardSameguard_Signguigned)

I am still new to acumatica. I'll really appreciate the help

1 Ответ

0 голосов
/ 20 февраля 2020

Основываясь на информации, предоставленной вами в комментариях, попробуйте использовать этот альтернативный подход для проверки "Неверный идентификатор клиента":

Замените этот раздел:

 foreach (FSServiceOrder fso in adapter.Get())
            {
                Customer cust = (Customer)PXSelect<Customer, Where<Customer.bAccountID, Equal<Current<FSServiceOrder.customerID>>>>.Select(this.Base);
                if (cust == null)
                {
                    string exc = "Invalid customer ID";
                    throw new PXException(exc);
                }
                yield return fso;
            }

На этот:

FSServiceOrder currentServiceOrder = this.Base.ServiceOrderRecords.Current;

if (currentServiceOrder != null && currentServiceOrder.CustomerID != null)
{
                Customer cust = PXSelect<Customer, Where<Customer.bAccountID, Equal<Required<Customer.bAccountID>>>>.Select(this.Base, currentServiceOrder.CustomerID);
                if (cust == null)
                {
                    string exc = "Invalid customer ID";
                    throw new PXException(exc);
                }
}
...