GetAbstractPermission in business logic  Topic is solved

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

GetAbstractPermission in business logic

Postby pricerc » Mon Apr 01, 2019 11:10 am

In a UI plugin, I can
Code: Select all
accessLevel = salesOrderForm.GetAbstractPermission("sales order - email invoices")


How would I achieve similar, but in business logic?

e.g. I'd like to (but can't):
Code: Select all
accessLevel = salesOrder.GetAbstractPermission("sales order - email invoices")
/Ryan

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

Re: GetAbstractPermission in business logic

Postby Mike.Sheen » Mon Apr 01, 2019 12:02 pm

pricerc wrote:e.g. I'd like to (but can't):
Code: Select all
accessLevel = salesOrder.GetAbstractPermission("sales order - email invoices")


Hi Ryan,

The GetAbstractPermission of the form is simply a convenience wrapper around Manager.Staff.GetAbstractPermission - so you want:

Code: Select all
accessLevel = salesOrder.Manager.Staff.GetAbstractPermission("sales order - email invoices")


Mike
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: GetAbstractPermission in business logic

Postby pricerc » Mon Apr 01, 2019 12:26 pm

That one has a className parameter as well as an AbstractPermissionName parameter?

(from Object Browser):
Public Function GetAbstractPermission(ClassName As String, AbstractPermissionName As String) As JiwaFinancials.Jiwa.JiwaApplication.Security.UserGroup.AccessLevels
Member of JiwaFinancials.Jiwa.JiwaApplication.JiwaStaff.clsStaff
/Ryan

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

Re: GetAbstractPermission in business logic  Topic is solved

Postby Mike.Sheen » Mon Apr 01, 2019 12:30 pm

pricerc wrote:That one has a className parameter as well as an AbstractPermissionName parameter?

(from Object Browser):
Public Function GetAbstractPermission(ClassName As String, AbstractPermissionName As String) As JiwaFinancials.Jiwa.JiwaApplication.Security.UserGroup.AccessLevels
Member of JiwaFinancials.Jiwa.JiwaApplication.JiwaStaff.clsStaff


Ahh - yes I forgot about that.

The ClassName is the class type for the FORM associated with the business logic. You'll find those in the SY_Forms table - but for sales orders it's either "JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm" or "JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.CreditNoteForm" (different permissions for credit notes).

Mike

EDIT: For completeness, the code is:

Code: Select all
accessLevel = salesOrder.Manager.Staff.GetAbstractPermission("JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm", "sales order - email invoices")


EDIT #2:
And you can obtain the ClassName from the business logic itself, without having to inspect the SY_Forms table - use the ClientClassName property of the business logic:

So a more technically correct way:
Code: Select all
accessLevel = salesOrder.Manager.Staff.GetAbstractPermission(salesOrder.ClientClassName, "sales order - email invoices")
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: GetAbstractPermission in business logic

Postby pricerc » Mon Apr 01, 2019 3:46 pm

Mike.Sheen wrote:So a more technically correct way:
Code: Select all
accessLevel = salesOrder.Manager.Staff.GetAbstractPermission(salesOrder.ClientClassName, "sales order - email invoices")


I'm glad I spent so much time responding to your anti-VB propaganda... :P (otherwise I would have used your less elegant version already)

I was going to suggest that maybe helper functions on the business objects would be something worth adding. This is pretty good though; makes a nice one-line extension method in my SalesOrder library :):

Code: Select all
       
<Extension()>
        Public Function GetAbstractPermission(salesOrder As SalesOrder, AbstractPermissionName As String) As AccessLevels
            Return salesOrder.Manager.Staff.GetAbstractPermission(salesOrder.ClientClassName, AbstractPermissionName)
        End Function
/Ryan

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


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 4 guests