SetControlPermissions  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

SetControlPermissions

Postby neil.interactit » Wed Mar 09, 2016 4:53 pm

Hi guys,

I am getting a strange error that I can't nail ...

Error: Object reference not set to an intance of an object. Module : SetControlPermissions

This occurs in a plugin on the CreditorPurchases form. I have (manually) added and populated some extra grid columns.

Initially I was getting this error when opening the form. I managed to solve this by now adding the columns to the grid in the _creditorPurchases.Load event handler, which all works perfectly.

All functionality works fine on and after opening the form, until I navigate to another batch record ... then I get Error: Object reference not set to an intance of an object. Module : SetControlPermissions, which seems to also kill any further plugin code from running.

The code that adds the column is akin to the following:

Code: Select all
        _creditorPurchases = (CreditorPurchases)JiwaForm;
        _sheet = _creditorPurchases.grdLines.ActiveSheet;
        [SNIP]
        var col = _sheet.ColumnCount;
        _colFilename = col;
        _sheet.ColumnCount += 1;

        _sheet.ColumnHeader.Cells[1, _colFilename].Text = "Attachment";
        _sheet.Columns[_colFilename].Width = 300;
        _sheet.Columns[_colFilename].CellType = new TextCellType() { NullDisplay = "Drop file(s) here, or select", ReadOnly = true };

Wrapping this in a Try-Catch doesn't help, and in fact after adding debug logging to EVERY method in the plugin I discovered that none of them fire, on record change, prior to the error displaying (or at all).

My guess is that I need to register something so that SetControlPermissions knows about the new column?

Cheers,
Neil.
neil.interactit
Kohai
Kohai
 
Posts: 232
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: SetControlPermissions

Postby Mike.Sheen » Thu Mar 10, 2016 8:31 pm

neil.interactit wrote:My guess is that I need to register something so that SetControlPermissions knows about the new column?


You shouldn't need to - unless you have set permissions for the new column - in that case it may be the base form class is trying to apply a permission to a column which doesn't exist until your plugin has a chance to add it.

You can help us out to troubleshoot this by providing a plugin which replicates the issue. We'll then be able to advise if it is an issue with the permissions system, and if we can provide a work-around for it.
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: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: SetControlPermissions

Postby neil.interactit » Fri Mar 11, 2016 8:18 am

Hi Mike,

Thanks for taking a look at this. Minimal sample attached. You sgould see the error when you open Creditors / Transactions / Purchases / Purchases.

Cheers,
Neil.
Attachments
Plugin SetControlPermissions.xml
(29.7 KiB) Downloaded 639 times
neil.interactit
Kohai
Kohai
 
Posts: 232
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: SetControlPermissions  Topic is solved

Postby Mike.Sheen » Sat Mar 12, 2016 2:24 pm

The problem is when the base class tries to apply permissions, it assumes each column has a tag which is a unique text identifier for the column - and your columns were added without setting the key.

The easiest way to resolve this is to use the AddColumn method of the grid.

Code: Select all
_creditorPurchases.grdLines.AddColumn("Attachment", new TextCellType(), "Attachment", 8, false, true, false, true);
_creditorPurchases.grdLines.AddColumn("Upload", new JiwaLookupButtonCellType(), "Upload", 8, false, true, false, true);
_creditorPurchases.grdLines.AddColumn("Uploading", new ProgressCellType() { ShowText = false, }, "Uploading", 8, false, true, false, true);


Attached is your plugin modified to use the above.
Attachments
Plugin SetControlPermissions.xml
Modified plugin
(31.25 KiB) Downloaded 575 times
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: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: SetControlPermissions

Postby neil.interactit » Tue Mar 15, 2016 8:46 am

Hi Mike,

Very sweet! Many thanks.

Cheers,
Neil.
neil.interactit
Kohai
Kohai
 
Posts: 232
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 0 guests