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

Discussions relating to plugin development, and the Jiwa API.

'focusable', readonly sales order notes for closed orders

Postby pricerc » Mon Nov 09, 2020 12:09 pm

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.
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 504
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 20

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

Postby Mike.Sheen » Mon Nov 09, 2020 12:26 pm

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?
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2440
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 755

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

Postby pricerc » Mon Nov 09, 2020 1:17 pm

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.
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 504
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 20

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

Postby pricerc » Thu Nov 12, 2020 10:49 am

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;
                    }
                }
            }
        }
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 504
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 20


Return to Technical and or Programming

Who is online

Users browsing this forum: Google [Bot] and 4 guests

cron