Setting BillCode or SplitTo

Questions about and code samples for custom order rules and validation within Select.
Post Reply
DanChapin
Posts: 16
Joined: Thu Sep 24, 2015 10:40 am

Setting BillCode or SplitTo

Post by DanChapin »

Hi Everyone,

I am trying to set the BillCode dropdown field and the SplitTo dropdown based upon the value entered into a custom field (TEXT). If the User enters T in the SplitTo custom field, I want the SplitTo dropdown in the order to set to the T Contact. I am using the code below to do this and get the following errors:

Error encountered during rule execution. expected IBillCode, got str
Error encountered during rule execution. expected Contact, got str

Here is my code: (Any Help would be appreciated!!)

def DefaultSplit_SplitTo_Value(args):
defaultsplit = args.Context
defaultsplit1 = defaultsplit.Parent.Split1
defaultsplit2 = defaultsplit.Parent.Split2
policy = defaultsplit.Parent.Parent
Order = args.Context.Root
#if (((str(policy).StartsWith('Loan')) or (str(policy).StartsWith('Own'))) and (Order.TitleCompanies)):
if defaultsplit.Guid == defaultsplit1.Guid:
args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'tcoSplitDefaultsSplit1SplitTo_150451##')

if defaultsplit.Guid == defaultsplit2.Guid:
args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'tcoSplitDefaultsSplit2SplitTo_150451##')


def DefaultSplit_BillCode_Value(args):
defaultsplit = args.Context
defaultsplit1 = defaultsplit.Parent.Split1
defaultsplit2 = defaultsplit.Parent.Split2
policy = defaultsplit.Parent.Parent
Order = args.Context.Root
#if (((str(policy).StartsWith('Loan')) or (str(policy).StartsWith('Own'))) and (Order.TitleCompanies)):
if defaultsplit.Guid == defaultsplit1.Guid:
args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'tcoSplitDefaultsSplit1BillCode_150451##')

if defaultsplit.Guid == defaultsplit2.Guid:
args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'tcoSplitDefaultsSplit2BillCode_150451##')
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Setting BillCode or SplitTo

Post by BobRichards »

I think we covered your issues off-line. For others, here is how you would search for a bill code or any other property that uses the enumeration manager:

Code: Select all

# I picked a CDF charge and set the Description to "TestLine" (without the quotes!).  This rule will find it then write to the bill code.
def CDFCharge_BillCode_Value(args):
	charge = args.Context
	if not charge.Description or charge.Description != 'TestLine':
		return
	
	# Get the billcode enumeration with the IEnum manager.
	enumMgr = args.GetService(IEnumManager)
	billCodes = enumMgr.GetEnum[IBillCode]()
	
	# Look through all the bill codes to find the target name.
	matches = [b for b in billCodes.Values if b.Name == 'END']
	
	# If we found a match, update the current bill code.
	if matches:
		args.Value = matches[0]
Bob Richards, Senior Software Developer, SoftPro
Post Reply