IronPython Read Custom Field

Discussions related to writing and managing custom business rules.

Moderator: Phil Barton

Post Reply
danvanf
Posts: 54
Joined: Fri Nov 07, 2008 10:45 am
Location: Dayton, Ohio
Contact:

IronPython Read Custom Field

Post by danvanf »

Hello, I have successfully hooked up to a custom field in IronPython,

Code: Select all

def PreliminaryTitleOpinion_HST_FS_35LandVal(args):
    args.Value = args.Context.HST_FS_100LandVal * 0.35
    #HST_FS_100LandVal## is the custom field name
    
# Redefine Custom Field Rule names to allow mapping to any field name.
PreliminaryTitleOpinion_HST_FS_35LandVal.__name__ = "PreliminaryTitleOpinion_HST_FS_35LandVal##_Value"
How do I set the Value to the results of another Custom Field like in the above line 2?

If I might toss another question on this about circular references, which don't seem to annoy formulas, but might crush Business Rules. So I have 2 Fields, let's call them Land100## and Land35##. I setup formulas so that a user can enter data in either field and the other one calculates. In super short code they are defined like this.

Code: Select all

Land100##.Value = Land35## / 0.35
Land35##.Value = Land100## * 0.35
The user can enter a value in either field and the other one calculates.
So how bad of an idea is that? It does work in formulas, although there is an understandable latent issue the user can get into that remembers values until they are removed by entering a zero in the field. To see the (rather non) issue enter values in both fields, then F2 them out, the previous values remain turning black on the F2, until one of the field is forced to zero. Then it all works again. I'm ok with that, I just don't want to inadvertently cause wasteful loopy behavior with an IronPython Business Rule.

Thanks for the direction!
-Dan
I blog at http://DanVanFleet.com on SoftPro and other things
John Morris
Posts: 411
Joined: Thu Sep 11, 2008 11:35 am
Location: Raleigh, NC, USA
Contact:

Re: IronPython Read Custom Field

Post by John Morris »

The new rule engine in Select has support for loops like that. It is normal. If it generates an "infinite" loop at runtime, the app will detect it and throw an error (not crash). You scenario is valid and ok.

As for the custom field value in COR, does this help?

Code: Select all

def Context_Field_Aspect(args):
    x = IOrderItem.GetProperty(args.Context, "MyCustomField##")
John Morris
Sr. Software Architect
SoftPro
danvanf
Posts: 54
Joined: Fri Nov 07, 2008 10:45 am
Location: Dayton, Ohio
Contact:

Re: IronPython Read Custom Field

Post by danvanf »

Thanks John, It does indeed, works great! It also helps with other bewilderment's. The simplicity of the complex is somewhat astounding. I need more time to play in IronPython, so much fun!
Thanks,
-Dan
I blog at http://DanVanFleet.com on SoftPro and other things
Post Reply