Purchasing Order Entry - initial disable email/print  Topic is solved

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

Purchasing Order Entry - initial disable email/print

Postby neil.interactit » Wed Nov 04, 2015 11:32 am

Hi guys,

I am having trouble initially disabling email/print on the Purchasing Order Entry form. In code, I disable ID_RecordSetStatusToMenu, ID_RecordEmail, ID_RecordPrint ... "set status" is disabling fine, but email/print do not disable initially. On the first change within the form, email/print then disable. It feels like there is a handler being called (during the form load) subsequent to my handler(s) that is overriding my logic.

My hooks are:
Code: Select all
        AddHandler _purchaseOrderForm.PurchaseOrder.PropertyChanged, AddressOf PurchaseOrderExtraLogic
        AddHandler _purchaseOrderForm.PurchaseOrder.CreateEnd, AddressOf PurchaseOrderExtraLogic
        AddHandler _purchaseOrderForm.PurchaseOrder.ReadEnd, AddressOf PurchaseOrderExtraLogic
        AddHandler _purchaseOrderForm.PurchaseOrder.CopyEnd, AddressOf PurchaseOrderExtraLogic
        AddHandler _purchaseOrderForm.PurchaseOrder.DeserialiseEnd, AddressOf PurchaseOrderExtraLogic

Can you advise a handler I can use that fires after whatever is enabling email/print?

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

Re: Purchasing Order Entry - initial disable email/print

Postby neil.interactit » Tue Nov 10, 2015 4:16 pm

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

Re: Purchasing Order Entry - initial disable email/print

Postby Scott.Pearce » Thu Nov 12, 2015 5:04 pm

Had a quick look. There are some silly buggers going on with SetPermissions and the ID_RecordEmail tool. What happens if you instead manipulate the permissions collection to control the enable/disable of the emailing tool - i.e. in form (or business logic) setup:

Code: Select all
PurchaseOrder.AbstractPermissionCollection("Email Order").AccessLevel = Security.UserGroup.AccessLevels.Disallow


Try something like that and I'll dig deeper tomorrow. Sorry I can't be more thorough today.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230

Re: Purchasing Order Entry - initial disable email/print

Postby neil.interactit » Fri Nov 13, 2015 8:52 am

Hi Scott,

Looks like that has me on the right track. My preliminary test here seems to indicate that AccessLevel affects initially but not subsequently (so the opposite of the enabled/disabled approach). I have nailed this by using both approaches:
Code: Select all
        _purchaseOrderForm.UltraToolbarsManager1.Ribbon.Tabs("Main").Groups("Actions").Tools("ID_RecordEmail").SharedProps.Enabled = isAuthorised
        _purchaseOrderForm.PurchaseOrder.AbstractPermissionCollection("Email Order").AccessLevel = IIf(isAuthorised, UserGroup.AccessLevels.Allow, UserGroup.AccessLevels.Disallow)

This has the emailing under control but isn't disabling the printing (initally) ... I had a look through that collection but couldn't spot any print related item ... is there another approach to disabling printing?

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

Re: Purchasing Order Entry - initial disable email/print

Postby Scott.Pearce » Fri Nov 13, 2015 9:57 am

I've worked out why this is happening:

1. When the form first starts, the reports for the particular form are read in by the base form. This causes and event to fire and therefore a base function "UpdatePrintTool" to be called. This checks whether any reports are defined for the form, if there are, enable the print button, if not disable the print button. (i.e. the reports collection has changed, I need to refresh the UI toolbar buttons).
2. The UpdatePrintTool also calls the base "SetPermissions" after it has disabled or enabled the print button (so user permissions can be reapplied over the top).
3. SetPermissions (overridden by the purchase order form) then messes with ID_RecordEmail:

Code: Select all
        If PurchaseOrder.AbstractPermissionCollection("Email Order").AccessLevel <> Security.UserGroup.AccessLevels.Allow Or _PurchaseOrder.ChangeFlag = True Then
            UltraToolbarsManager1.Tools("ID_RecordEmail").SharedProps.Enabled = False
        Else
            UltraToolbarsManager1.Tools("ID_RecordEmail").SharedProps.Enabled = True
        End If


4. Your plugin runs and disables the Email button.
5. The base form calls UpdatePrintTool again before .show-ing.

So, UpdatePrintTool is called twice, and perhaps shouldn't be when a form is being set up initially. Further, your plugin is not hooking in late enough in this process. You should also hook into the forms' .show() event.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230

Re: Purchasing Order Entry - initial disable email/print  Topic is solved

Postby Scott.Pearce » Fri Nov 13, 2015 10:06 am

I created a sample for you:

viewtopic.php?f=27&t=472
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230

Re: Purchasing Order Entry - initial disable email/print

Postby neil.interactit » Fri Nov 13, 2015 11:26 am

Very sweet. Many thanks.

In case it helps others, the solution, from Scott's detail above, boils down to:
Code: Select all
        AddHandler _purchaseOrderForm.PurchaseOrder.PropertyChanged, AddressOf PurchaseOrderExtraLogic
        AddHandler _purchaseOrderForm.PurchaseOrder.CreateEnd, AddressOf PurchaseOrderExtraLogic
        AddHandler _purchaseOrderForm.PurchaseOrder.ReadEnd, AddressOf PurchaseOrderExtraLogic
        AddHandler _purchaseOrderForm.PurchaseOrder.CopyEnd, AddressOf PurchaseOrderExtraLogic
        AddHandler _purchaseOrderForm.PurchaseOrder.DeserialiseEnd, AddressOf PurchaseOrderExtraLogic
        AddHandler _purchaseOrderForm.Shown, AddressOf PurchaseOrderExtraLogic

So, adding the extra handler:
Code: Select all
        AddHandler _purchaseOrderForm.Shown, AddressOf PurchaseOrderExtraLogic

Which fires after all the stuff above.
neil.interactit
Kohai
Kohai
 
Posts: 232
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: Purchasing Order Entry - initial disable email/print

Postby Ernst » Mon Apr 11, 2016 6:13 pm

you can also go to utility, set permission, and Under Tools, make those buttons disallowed, which makes them disappear from the menu. :)
Used for Delete button successfully, as client didn't want staff deleting, unsent PO. Which would allow a staff to make a PO, email it to somebody and then delete it.
User avatar
Ernst
Kohai
Kohai
 
Posts: 242
Joined: Tue Feb 19, 2008 3:43 pm
Topics Solved: 13


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 5 guests