IsCashSale

Questions about and code samples for custom order rules and validation within Select.
Post Reply
tmeisinger
Posts: 75
Joined: Fri Apr 24, 2015 10:33 am

IsCashSale

Post by tmeisinger »

I want to make Order.IsCashSale Read Only but can't get this Module to fire? Help me please.

Code: Select all

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
tmeisinger
Posts: 75
Joined: Fri Apr 24, 2015 10:33 am

Re: IsCashSale

Post by tmeisinger »

Not sure why, but the code is firing, it just wont break in Debug mode. I don't need to understand why...
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: IsCashSale

Post by BobRichards »

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.

Code: Select all

secUser = ISecurityManager.GetUser(secMgr, userSecId)
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.
Bob Richards, Senior Software Developer, SoftPro
tmeisinger
Posts: 75
Joined: Fri Apr 24, 2015 10:33 am

Re: IsCashSale

Post by tmeisinger »

Thanks for the advice, is there a better way to allow "someone" the ability to access a field that I'm going to make Read Only for the masses?
Post Reply