Solved

Enable TermsID only for Role 'Administrator'

  • 11 April 2021
  • 7 replies
  • 75 views

Userlevel 1
Badge

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

icon

Best answer by Naveen Boga 11 April 2021, 12:09

View original

7 replies

Userlevel 7
Badge +9

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.

Userlevel 1
Badge

Hi Gabriel,

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

 

Userlevel 7
Badge +12

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.

 

 

Userlevel 1
Badge

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

Userlevel 7
Badge +12

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.

 

 

 

 

 

 

Userlevel 1
Badge

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?

 

 

Userlevel 7
Badge +12

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


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2022  Acumatica, Inc. All rights reserved