Окно заметок не обновляется на счет - PullRequest
0 голосов
/ 29 августа 2018

Я обновляю Примечания по векселю через некоторый пользовательский код в расширении графика. Моя проблема заключается в том, что окно, открывающееся при нажатии на значок «Примечания» в правом верхнем углу экрана, не отражает изменения, которые я внес в примечания в коде. Если я использую кнопки <>, чтобы перейти к другому Биллу, а затем вернуться к тому, который я обновил, он показывает изменения. Так что я не уверен, как обновить заметки.

Это на экране AP301000. Я пробовал Base.Document.View.RequestRefresh (), Base.Document.View.Clear () и вызывал Base.Actions.PressSave () после того, как мой код изменил примечание для Билла.

ТИА!

Вот код:

protected void APTran_RowInserted(PXCache cache, PXRowInsertedEventArgs e)
    {

        var row = (APTran)e.Row;
        if (row == null)
            return;

        //*********************** copy notes and file attachments from PO lines and header to the Bill **********************************
        if ((row.PONbr != null) && (row.POLineNbr != null))
        {
            POOrderEntry poEntry = (POOrderEntry)PXGraph.CreateInstance(typeof(POOrderEntry));
            poEntry.Clear();
            POOrder poHeader = poEntry.Document.Search<POOrder.orderNbr>(row.PONbr);
            poEntry.Document.Current = poHeader;
            POLine poLine = poEntry.Transactions.Search<POLine.lineNbr>(row.POLineNbr);

            if (poLine != null)
            {
                PXNoteAttribute.CopyNoteAndFiles(poEntry.Caches[typeof(POLine)], poLine, cache, row); //// - use this for Notes and Files.

                // making of copy of what the note is on the APInvoice at this point because the PXNoteAttribute.CopyNoteAndFiles() below
                // will replace what is in the notes with what is in the PO instead of appending.
                string oldNote = PXNoteAttribute.GetNote(Base.Caches[typeof(APInvoice)], Base.CurrentDocument.Current);

                PXNoteAttribute.CopyNoteAndFiles(poEntry.Caches[typeof(POOrder)], poHeader, Base.Caches[typeof(APInvoice)], Base.CurrentDocument.Current);
                PXNoteAttribute.SetNote(Base.Caches[typeof(APInvoice)], Base.CurrentDocument.Current, oldNote);

                Base.Actions.PressSave();

                string poNote = PXNoteAttribute.GetNote(poEntry.Caches[typeof(POOrder)], poHeader);
                if (!string.IsNullOrEmpty(poNote))
                {
                    //string oldNote = PXNoteAttribute.GetNote(Base.Caches[typeof(APInvoice)], Base.CurrentDocument.Current);
                    if ((oldNote == null) || !oldNote.Contains(poNote))
                    {
                        string newNote = "";

                        if (string.IsNullOrEmpty(oldNote))
                            newNote = poNote;
                        else
                            newNote = oldNote + Environment.NewLine + poNote;
                        //These 2 lines will not update the note without the PressSave();
                        //Guid noteGuid = (Guid)PXNoteAttribute.GetNoteID(Base.Caches[typeof(APInvoice)], Base.CurrentDocument.Current, null);
                        //PXNoteAttribute.UpdateNoteRecord(Base.Caches[typeof(APInvoice)], noteGuid, newNote);

                        PXNoteAttribute.SetNote(Base.Caches[typeof(APInvoice)], Base.Document.Current, newNote);  // Sets the note but, screen does not refresh.


                        //Base.Caches[typeof(APInvoice)].Update(Base.Document.Current); //Does not refresh Notes on screen.

                        //PXNoteAttribute.GetNoteID<APInvoice.noteID>(Base.Caches[typeof(APInvoice)], Base.Document.Current);  // Does not update the screen.

                        //Base.Caches[typeof(Note)].IsDirty = true;  /// No Effect.

                        //Base.Caches[typeof(Note)].Clear();  //this has no effect on refreshing the notes that are seen on the screen.
                        //Base.Caches[typeof(NoteDoc)].Clear();

                        //Base.Actions.PressSave();  // blanks out the header if the Bill has never been saved. Does not refresh note on screen.
                        //Base.Document.View.Clear();
                        //Base.Document.View.RequestRefresh();  // this wipes out the new note if adding a second PO.


                    }
                }


            }
        }

    }

1 Ответ

0 голосов
/ 03 октября 2018

Вот исправление для этого, которое я развернул. Я думаю, что есть лучший способ сделать это, но, похоже, пока работает нормально. Я добавил это:

    [PXOverride]
    public void Persist(Action persist)
    {
        persist();

        APInvoice invoice = (APInvoice)Base.CurrentDocument.SelectSingle();
        if (invoice.Status == "H")
            throw new PXRedirectRequiredException(Base, "Reloading Notes...");
    }

Итак, я переопределил Persist (), чтобы обновить страницу, но я делаю это только в том случае, если Билл все еще в ожидании. Это обновит заметки, которые отображаются на экране.

...