Skip to main content

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

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.


Hi Gabriel,

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

 


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.

 

 


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


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.

 

 

 

 

 

 


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?

 

 


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