Hi,
I'd like to know if there is a way to enforce that there must be ONE Marketing Source specified in the Order Contact list for a ProForm order.
In our case, users sometime mistakenly delete the Marketing Source or add more than one MS. We want to constrain that there need to be one MS when user edit the order and save.
Thanks.
Kevin
Enforce rule on Marketing Source in Order Contacts
Moderator: Phil Barton
-
- Posts: 89
- Joined: Wed Nov 16, 2011 11:51 am
Re: Enforce rule on Marketing Source in Order Contacts
In our next major release of Select, we're going to add the ability to tie into the OrderSaving event in server side code so that you can enforce any custom save validations you might need.
-
- Posts: 411
- Joined: Thu Sep 11, 2008 11:35 am
- Location: Raleigh, NC, USA
- Contact:
Re: Enforce rule on Marketing Source in Order Contacts
This can also be done using "custom order rules" written using an order module (i.e. IronPython). This is ability is covered in the SDK documentation. The rule looks like this:
Code: Select all
def Order_Contacts_Validate(args):
count = 0
for c in args.Context.Contacts:
if c.IsMarketingSource:
count = count + 1
if count == 0:
args.RaiseError("Order must contain a marketing source.")
if count > 1:
args.RaiseError("Only one marketing source should be marked.")
John Morris
Sr. Software Architect
SoftPro
Sr. Software Architect
SoftPro
Re: Enforce rule on Marketing Source in Order Contacts
I'm trying to do something similar to the Proform custom validation code that is detailed in this thread, but based on ContactType of Other Contacts. I'm using "if c.ContactType == 'CLIENT':" as my condition, but it's not catching the use case.
1.) Am I not accessing the ContactType value correctly?
2.) When I right click on Order in the project explorer, I don't have an option to "Set Global Default Rule", I get “Set as Default Order". Are they the same?
I'm using:
def Order_Contacts_Validate(args):
count = 0
for c in args.Context.Contacts:
if c.ContactType == 'CLIENT':
count = count + 1
if count > 1:
args.RaiseError("Custom Validation (Code OC001)! More than 1 'Client' contact type listed.")
1.) Am I not accessing the ContactType value correctly?
2.) When I right click on Order in the project explorer, I don't have an option to "Set Global Default Rule", I get “Set as Default Order". Are they the same?
I'm using:
def Order_Contacts_Validate(args):
count = 0
for c in args.Context.Contacts:
if c.ContactType == 'CLIENT':
count = count + 1
if count > 1:
args.RaiseError("Custom Validation (Code OC001)! More than 1 'Client' contact type listed.")
-
- Posts: 1382
- Joined: Wed Jan 15, 2014 3:50 pm
- Location: Raleigh, NC
- Contact:
Re: Enforce rule on Marketing Source in Order Contacts
If what you meant by a "Client" is "Others" contact types, this examples shows a quick way to get the number of items in a collection.
And yes - “Set as Default Order" is the same as "Set Global Default Rule".
Code: Select all
def Order_Contacts_Validate(args):
# Make sure Others collection exists before continuing
if args.Context.Others is None:
return
# Can use "Count" to get total number of contacts in specific Contact type.
if args.Context.Others.Count > 0:
args.RaiseWarning("Custom Validation (Code OC001)! More than 1 'Other' contact type listed.")
Bob Richards, Senior Software Developer, SoftPro