Skip to main content
Solved

Enable TermsID only for Role 'Administrator'


idrusm52
Jr Varsity III
Forum|alt.badge.img

Hello Team,

I did a customization for Terms (Sales Order) as below;

<px:PXSelector Enabled="False" ID="edTermsID" runat="server" CommitChanges="False" DataField="TermsID" DataSourceID="ds" ></px:PXSelector>

How to make TermsID Enable only for Role ‘Administrator’?

 

Thanks,
Idrus

Best answer by Naveen Boga

Hi @idrusm52 

I’m NOT sure, why access rights are NOT working for you. Better raise a support ticket with Acumatica.

 

As you are looking for code, the below customization will work to enable the “TermID” field for only the Administrator role. 

public class SQLConstants
    {
        public class Administrator : PX.Data.BQL.BqlString.Constant<Administrator>
        {
            public Administrator() : base("Administrator") { }
        }
    }

    public class SOOrderEntrySHExt : PXGraphExtension<SOOrderEntry>
    { 
	  protected virtual void SOOrder_TermsID_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e, PXFieldSelecting InvokeBaseHandler)
        {
            InvokeBaseHandler?.Invoke(cache, e);
            SOOrder row = e.Row as SOOrder;           
            if (row != null)
            { 
                UsersInRoles objUsers = PXSelect<UsersInRoles, Where<UsersInRoles.username, Equal<Current<AccessInfo.userName>>,
                                             And<UsersInRoles.rolename, Equal<SQLConstants.Administrator>>>>.Select(Base); 
                PXUIFieldAttribute.SetEnabled<SOOrder.termsID>(cache, row, objUsers != null); 
            }
        }
	}

 

You can also achieve this, by having PXUIEnaled() at DAC level instead of field selecting event.

 

 

Hope this helps!!

 

View original
Did this topic help you find an answer to your question?

7 replies

Gabriel Michaud
Captain II
Forum|alt.badge.img+11

Hi @idrusm52,

There’s no reason to use customization to achieve this - just go to Access Rights by Screen screen, and make the field editable only for the Administrator role.


idrusm52
Jr Varsity III
Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • 30 replies
  • April 11, 2021

Hi Gabriel,

The reason I did customization due to an error while do this by Access Rights.

 


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3416 replies
  • April 11, 2021

Hi @idrusm52,

In this scenario, customization is NOT required as suggested by Gabriel.

When you're changing the settings at the child level, make sure that first modify the settings at the Parent Node level and then apply at the child node and verify once.

 

 


idrusm52
Jr Varsity III
Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • 30 replies
  • April 11, 2021

Hi Naveen,

Please show me the screenshot of Parent Node of TermsID of Sales Order where I can remove the option of “Applies to Children” as you mentioned.

 

Thanks,

Idrus


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3416 replies
  • April 11, 2021

Hi @idrusm52 
Please find the screenshots for reference.
This is for Administrator Role settings, for the other roles you can modify settings to ViewOnly.  This way only Adminitrator can modify this “Terms” field at Sales Order screen.

 

 

 

 

 

 


idrusm52
Jr Varsity III
Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • 30 replies
  • April 11, 2021

Hi Naveen,

Thank you for your reply, I have manage to change the access right but it’s still not working as expected.

I decide to remove the customization and give the Terms - View Only for Full Distribution Role and still user manage to choose Terms List.

Let’s pretend it’s not working via Access Right, then I apply again the Customization to disable Terms, so back again to my first question, how to write down the code to make TermsID become enable only for Administrator Role?

 

 


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3416 replies
  • Answer
  • April 11, 2021

Hi @idrusm52 

I’m NOT sure, why access rights are NOT working for you. Better raise a support ticket with Acumatica.

 

As you are looking for code, the below customization will work to enable the “TermID” field for only the Administrator role. 

public class SQLConstants
    {
        public class Administrator : PX.Data.BQL.BqlString.Constant<Administrator>
        {
            public Administrator() : base("Administrator") { }
        }
    }

    public class SOOrderEntrySHExt : PXGraphExtension<SOOrderEntry>
    { 
	  protected virtual void SOOrder_TermsID_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e, PXFieldSelecting InvokeBaseHandler)
        {
            InvokeBaseHandler?.Invoke(cache, e);
            SOOrder row = e.Row as SOOrder;           
            if (row != null)
            { 
                UsersInRoles objUsers = PXSelect<UsersInRoles, Where<UsersInRoles.username, Equal<Current<AccessInfo.userName>>,
                                             And<UsersInRoles.rolename, Equal<SQLConstants.Administrator>>>>.Select(Base); 
                PXUIFieldAttribute.SetEnabled<SOOrder.termsID>(cache, row, objUsers != null); 
            }
        }
	}

 

You can also achieve this, by having PXUIEnaled() at DAC level instead of field selecting event.

 

 

Hope this helps!!

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings