Как установить поля во второй форме, используя перенаправление на той же странице - PullRequest
0 голосов
/ 05 ноября 2018

Я использую сетку с галочками, что при нажатии строки на поле галочки вторая форма автоматически заполняется двумя полями, принадлежащими другому ЦАП, проблема начинается при нажатии действия перенаправления, оно должно установить все поля, которые пользователь ранее вводил, но всегда устанавливает 2 поля первой строки, Как я могу установить поля последней выбранной строки?

This is my page

Это код действия копирования:

public PXAction<SOProcessCustomerFilter> CopyDescription;
    [PXUIField(DisplayName = "Copy", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
    [PXButton(CommitChanges = true)]
    public virtual void copyDescription()
    {
        SOProcessCustomerFilter sOProcessCustomerFilterRow = SOProcessCustomerRecord.Current;
        InternalNotesHelper internalNotesHelperRow = NotesRecord.Current;
        FSServiceOrder fSServiceOrderRow = SOProcessDetails.Current;
        FSServiceOrderTGExt fSServiceOrderExtRow = PXCache<FSServiceOrder>.GetExtension<FSServiceOrderTGExt>(fSServiceOrderRow);
        bool serviceOrderSelected = false;
        bool SODescriptionDash = fSServiceOrderRow.DocDesc.Contains("-");
        string[] SODescription = fSServiceOrderRow.DocDesc.Split('-');
        string internalNotes = "";
        string internalNotesSO = "";

        if (sOProcessCustomerFilterRow != null)
        {
            PXLongOperation.StartOperation(this, delegate ()
            {
                ServiceOrderEntry serviceOrderGraph = PXGraph.CreateInstance<ServiceOrderEntry>();

                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    if (fSServiceOrderExtRow != null)
                    {
                        serviceOrderGraph.ServiceOrderRecords.Current = serviceOrderGraph.ServiceOrderRecords.Search<FSServiceOrder.refNbr>(fSServiceOrderRow.RefNbr, fSServiceOrderRow.SrvOrdType);

                        if (serviceOrderGraph.ServiceOrderRecords.Current != null)
                        {
                            if (fSServiceOrderExtRow.SelectExt == true)
                            {
                                if (SODescriptionDash == true)
                                {
                                    if (SODescription.Length <= 2)
                                    {
                                        internalNotesHelperRow.InternalNotes = " - " + SODescription[1] + "\r\n" + internalNotesHelperRow.InternalNotes;
                                    }
                                    else
                                    {
                                        for (int i = 1; i < SODescription.Length; i++)
                                        {
                                            internalNotesHelperRow.InternalNotes += " - " + SODescription[i];
                                        }
                                        internalNotesHelperRow.InternalNotes = internalNotesHelperRow.InternalNotes;
                                    }
                                    fSServiceOrderExtRow.UsrJobDescription = internalNotesHelperRow.InternalNotes;
                                    fSServiceOrderExtRow.UsrInternalNotes = internalNotesHelperRow.InternalNotesSO;
                                    internalNotes = fSServiceOrderExtRow.UsrJobDescription;
                                    internalNotesSO = fSServiceOrderExtRow.UsrInternalNotes;
                                    fSServiceOrderExtRow.UsrModified = true;
                                    serviceOrderGraph.ServiceOrderRecords.Update(fSServiceOrderRow);
                                    serviceOrderGraph.Actions.PressSave();

                                    fSServiceOrderExtRow.ModifiedNotes = false;
                                    TGSOProcessMaint tGSOProcessGraph = PXGraph.CreateInstance<TGSOProcessMaint>();
                                    if (sOProcessCustomerFilterRow != null)
                                    {
                                        tGSOProcessGraph.SOProcessCustomerRecord.Current.CustomerID = sOProcessCustomerFilterRow.CustomerID;
                                        tGSOProcessGraph.SOProcessCustomerRecord.Current.MSPType = sOProcessCustomerFilterRow.MSPType;
                                        if (sOProcessCustomerFilterRow.ManagerInt != null)
                                        {
                                            tGSOProcessGraph.SOProcessCustomerRecord.Current.ManagerInt = sOProcessCustomerFilterRow.ManagerInt;
                                        }
                                        foreach (FSServiceOrder fSServiceOrderrow in SOProcessDetails.Select())
                                        {
                                            FSServiceOrderTGExt fSServiceOrderRowExt = PXCache<FSServiceOrder>.GetExtension<FSServiceOrderTGExt>(fSServiceOrderrow);
                                            fSServiceOrderExtRow.SelectExt = fSServiceOrderRowExt.SelectExt;
                                            tGSOProcessGraph.SOProcessDetails.Update(fSServiceOrderrow);

                                        }
                                        throw new PXRedirectRequiredException(tGSOProcessGraph, false, "Page") { Mode = PXBaseRedirectException.WindowMode.Same };
                                    }
                                }
                                else
                                {
                                    throw new PXException("Description doesn't contain '-'");
                                }
                            }
                            serviceOrderSelected = true;
                        }
                    }
                    if (!serviceOrderSelected)
                    {
                        throw new PXException("No Service Order Selected");
                    }

                    ts.Complete();
                }
            });
        }
    }
...