from System import *
from SoftPro.ClientModel import *
from SoftPro.OrderTracking.Client import *
from SoftPro.OrderTracking.Client.Orders import *
from SoftPro.Select.Client.Security import *
from System.Collections.Generic import IEnumerable, List
from System.Linq import Enumerable
import clr
clr.ImportExtensions(Linq)
def Order_IsCashSale_ReadOnly(args):
secMgr = args.GetService(ISecurityManager)
userSecId = ISecurityManager.CurrentSecurityIdentityID.GetValue(secMgr)
secUser = ISecurityManager.GetUser(secMgr, userSecId)
groups = List[ISecurityIdentity](secUser.Groups)
foundUser = Enumerable.Any(groups, lambda t: t.IsGroup and t.Name == 'Administrators')
if not foundUser:
args.Value = True
Glad it's working for you. Be aware that this method will make a call to the server then to the SQL database and can be costly in terms of the user experience resulting in slower order load times.
Best practice is that you don't call server code in CORs. However if you can't avoid it, make sure order load time is still acceptable in your production environment.