Page 1 of 1

'focusable', readonly sales order notes for closed orders

PostPosted: Mon Nov 09, 2020 12:09 pm
by pricerc
So,

there are settings to allow modification of notes after an order is process/closed.

If this is off, I can't interact with the notes at all, but if it's on, I can do what I like.

What I'd like is for them to be read-only, but to still be able to interact with them - e.g. to copy the content to send to someone (in my case it's transaction log information for a payment integration).

For bonus points, I'd like this setting to be dependent on the NoteType of the record, so that I always can make some active-but-read-only, regardless of the state of the order.

Re: 'focusable', readonly sales order notes for closed order

PostPosted: Mon Nov 09, 2020 12:26 pm
by Mike.Sheen
pricerc wrote:What I'd like is for them to be read-only, but to still be able to interact with them - e.g. to copy the content to send to someone (in my case it's transaction log information for a payment integration).


In my testing, you can already do that - even if the fields on the notes grid are locked (not editable) you can still select a cell and the focus reticle is shown around the cell and you can ctrl-C to copy the contents to the clipboard.

Are you wanting more than that - like allowing to select certain parts of the notes?

Re: 'focusable', readonly sales order notes for closed order

PostPosted: Mon Nov 09, 2020 1:17 pm
by pricerc
Mike.Sheen wrote:
pricerc wrote:What I'd like is for them to be read-only, but to still be able to interact with them - e.g. to copy the content to send to someone (in my case it's transaction log information for a payment integration).


In my testing, you can already do that - even if the fields on the notes grid are locked (not editable) you can still select a cell and the focus reticle is shown around the cell and you can ctrl-C to copy the contents to the clipboard.

Are you wanting more than that - like allowing to select certain parts of the notes?


That's probably good enough for the troubleshooting I'm doing at the moment.

Although I see it seems to be putting double quotes around multi-line strings and XML, which kind of messes with the XML, and I think being able to poke around inside the cell editor would resolve that.

I also wouldn't mind blocking deleting and/or editing of these records based on the note type - regardless of what the settings are.

Re: 'focusable', readonly sales order notes for closed order  Topic is solved

PostPosted: Thu Nov 12, 2020 10:49 am
by pricerc
So I realised that I need to lock these fields all the time. This is what I got to. Seems to be working.

Code: Select all
       public void Setup(IJiwaForm JiwaForm, Plugin Plugin)
        {
            var salesOrderForm = JiwaForm as BaseSalesOrderEntryForm;

            if (salesOrderForm == null)
            {
                return;
            }

            salesOrderForm.SalesOrder.ReadEnd += (s, e) => LockEftposNotes(salesOrderForm);
        }

        private static void LockEftposNotes(BaseSalesOrderEntryForm salesOrderForm)
        {
            var eftPosNoteTypes = new Dictionary<string, NoteType>();

            foreach (var nt in salesOrderForm.SalesOrder.Notes.NoteTypeCollection.ToEnumerable())
            {
                if (nt.Description.ToUpperInvariant().Contains("EFTPOS") || nt.Description.ToUpperInvariant().Contains("WINDCAVE"))
                {
                    eftPosNoteTypes.Add(nt.RecID, nt);
                }
            }

            var grdNotes = salesOrderForm.grdNotes;
            for (int row = 0; row < grdNotes.ActiveSheet.RowCount; row++)
            {
                var noteRecId = (string)grdNotes.get_GridText("Type", row);
                if (string.IsNullOrWhiteSpace(noteRecId))
                {
                    continue;
                }

                if (eftPosNoteTypes.ContainsKey(noteRecId))
                {
                    for (int col = 0; col < grdNotes.ActiveSheet.ColumnCount; col++)
                    {
                        grdNotes.ActiveSheet.Cells[row, col].Locked = true;
                    }
                }
            }
        }