In this post I discussed how the SalesLogix 7.5 web client modifies close probability different than the LAN client. I now want to talk about how you can change this behavior to match the LAN client.
The first thing we need to understand is how the SalesLogix web client is setting the close probability. Since we know that the close probability is set when the status changes, there are only two places that this can happen:
1 In code on the form
2 In rules in place within the entity model
I know by digging that there is no code that is setting this value on any of the standard opportunity screens. That leaves us with something in the entity model itself. If we look at the rules under the Opportunity entity, we will find there isn’t a rule that does what we are looking for:
Again, I know this because I examined what each of the rules is doing. So where else can this logic be built into? Well it turns out that every property in an entity can have, at present, two custom events tied to it, an “OnBeforeChange”, and an “OnAfterChange”. If we look at the Opportunity entity we can see the status property has a custom event by default called “OnBeforeStatusChanged”.
Ah, ha! So now we are getting somewhere. So if we double click on the event, the event page will open in the Application Architect.
Now, you will notice there is an event described called “onBeforeStatusChanged” as the primary step of the event. For those that have worked with many events, you will notice there is no ability to edit the event code. If you notice, the type name is in the Sage.SalesLogix.BusinessRules class, which is a core un-customizable area. That stinks. But lets take a look any ways. Using reflector we can examine what this event in the BusinessRules class is doing.
OK, so it is calling another event “setOppValues”. Again using Reflector we can see this is a protected member of the BusinessRules class:
OK. So now we know how it is getting called. However because it is in the core BusinessRules class, we can’t modify this action. This is one of those things that bugs me about how some of the code in the SalesLogix web client is designed. They say it is open, but a lot of it is not really open the way you might think. What we need to do is to add a later step to basically “undo” what the core code is doing wrong (or differently than what we might like).
So what we can do is to add a new event on the Status property of the Opportunity entity. We do this by right clicking on “Status” and choosing “New AfterChange Event”
Once we do that, we can then write new code during this event. This event will run after the before change event, and essentially undo what we want.
Since this is custom code, we have the ability to Add new code under the Primary Steps tab. Click on the Add hyperlink and then choose C# code snippet.
When you click OK, you can then choose to edit the code by clicking the “Edit Code Snippet” hyperlink.
Now we can add our preferred rule, such as:
if (args.NewValue.ToString() == “Closed – Lost”)
opportunity.CloseProbability = 0;
With this added we now will negate what SalesLogix is doing OOTB and we can match the behavior of the LAN based SalesLogix client.
Please note that custom events on Entity Properties did not work quite right in SalesLogix 7.5. SalesLogix 7.5.1 addressed the issues to this area. You will be unable to add new events to Properties in 7.5. You also will not be able to install a manifest that has custom events contained in it in a 7.5 system.