Discussions related to SoftPro Select Server development.
Moderator: Phil Barton
- Posts: 10
- Joined: Wed Apr 15, 2015 8:49 am
I’m trying to add logic to my server side validation package to prevent users from saving orders that don’t have a specific Other Contact “OtherType” value of "CLIENT". The below logic works, but for ALL of the Other Contact types not just the ones with a specific OtherType . I can't figure out the correct syntax to either filter the list or loop through the list. Please advise…
IList otherContacts = (IList)iOrder["Others"];
if (otherContacts.Count == 0)
e.Cancel = true;
e.Reason = "Validation Error! Order can't be saved without a Contact Type of CLIENT.";
- Posts: 1009
- Joined: Wed Jan 15, 2014 3:50 pm
- Location: Raleigh, NC
Try this to evaluate each Other contact in the order. By the way, only Other contacts have an "OtherType" property - so it won't work with other contacts.
Code: Select all
# Loop over each Other contact that is present in the order.
IList others = (IList)iOrder["Others"];
foreach (var other in others)
string type = (string)((IOrderItem)other).GetProperty("OtherType");
// Error: OtherType is not specified.
else if (type != "CLIENT")
// Error: Wrong value for OtherType
// OtherType value is correct.
Bob Richards, Software Developer, SoftPro