Question: How do I call a function from within a contact event in SalesLogix? What I’ve done is written a string manipulation function in Visual Studio to format Contact phone numbers, and I have compiled the function into a DLL. What I would like to happen is to have the function called in the OnBeforeUpdate event of the Contact entity. Unfortunately, I don’t know how to reference the DLL inside the Application Architect so that it can be called within the OnBeforeUpdate event.
The function signature is like this:
public static int FormatNumber(Country country, string numberToFormat, out string countryCode, out string areaCode, out string mainNumber, out string extension)
Answer: The first suggestion would be to do the formatting in a business rule, not an event. This is because in the future you may have other fields that you want to validate, and doing this in a business rule or a C# snippet can make it easier to maintain. That said, to do what you are asking you will need to add the DLL to your portal’s SupportFiles/bin directory. Next, open up the Contact entity in Application Architect, go to events, and open OnBeforeUpdate. Most likely there is already a primary step defined that you don’t want to modify, so a good place to put it is in the Pre-Execute Steps. Choose this tab and click Add. Now pick the External Assembly radio button, click “Choose type and method from assembly”. When the Class Browser opens, select the File menu and open your DLL. Expand the namespace down to your function, highlight, and click OK.