<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://customerfx.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">Jason Buss&amp;#39; Blog</title><subtitle type="html">Jason Buss on SalesLogix development &amp;amp; customization, SQL, and more.</subtitle><id>http://customerfx.com/pages/customization/atom.aspx</id><link rel="alternate" type="text/html" href="http://customerfx.com/pages/customization/default.aspx" /><link rel="self" type="application/atom+xml" href="http://customerfx.com/pages/customization/atom.aspx" /><generator uri="http://communityserver.org" version="3.0.20611.960">Community Server</generator><updated>2010-04-12T09:21:00Z</updated><entry><title>Updating text within Textblob fields in SalesLogix</title><link rel="alternate" type="text/html" href="http://customerfx.com/pages/customization/2012/04/19/updating-text-within-textblob-fields-in-saleslogix.aspx" /><id>http://customerfx.com/pages/customization/2012/04/19/updating-text-within-textblob-fields-in-saleslogix.aspx</id><published>2012-04-19T15:16:00Z</published><updated>2012-04-19T15:16:00Z</updated><content type="html">&lt;p&gt;I had a request to post on how you could replace characters within a Blob field in the SalesLogix database.  Blob fields are database fields that hold any sort of binary information (such as text, images, audio, etc..), but SalesLogix uses them primarily for holding large amounts of text, since you don&amp;#39;t have to define a field length.  The Longnotes field in the History table is a good example.
&lt;/p&gt;

&lt;p&gt;Updating these types of fields is simple.  You can perform a SQL update statement like you would on any other type of field in the database.  The only caveat is that you need to perform a cast on the blob field so that it is evaluated as a VarChar, otherwise you will get an error regarding the Blob datatype.
&lt;/p&gt;

&lt;p&gt;The update will only be performed for the length you specify in your cast, therefore you&amp;#39;ll need to cast it large enough to encompass the largest amount of data you may have in that field.&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;If you wanted to replace any instance of the &amp;quot;pipe&amp;quot; symbol ( | ) with the &amp;quot;at&amp;quot; symbol ( @ ) for example, you could perform the following update:
&lt;/p&gt;

&lt;table style="table-layout:fixed;width:600px;" cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt; &lt;span style="color:Blue;"&gt;update&lt;/span&gt; HISTORY &lt;span style="color:Blue;"&gt;set&lt;/span&gt; LONGNOTES = REPLACE(&lt;span style="color:Blue;"&gt;cast&lt;/span&gt;(LONGNOTES &lt;span style="color:Blue;"&gt;as&lt;/span&gt; &lt;span style="color:Blue;"&gt;varchar&lt;/span&gt;(5000)), &lt;span style="color:Navy;"&gt;&amp;#39;|&amp;#39;&lt;/span&gt;, &lt;span style="color:Navy;"&gt;&amp;#39;@&amp;#39;&lt;/span&gt;)&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;  
  
&lt;p&gt;Note that I am casting the Longnotes field to a VarChar with a length of 5000.&amp;nbsp; In most cases, that should be plenty of space to include all text, but your situation may require a larger cast.&lt;/p&gt;
&lt;p&gt;This statement can be ran directly in the SQL Server Management Studio or Query Analyzer, or if you have a LAN system and need to consider synchronization, you can run this in the Execute SQL functionality under the &lt;i&gt;Tools&lt;/i&gt; menu in the SalesLogix Workgroup Administrator.&amp;nbsp; Since the data is being updated directly in the SQL database, this will work for both LAN and Web implementations.&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Keep in mind that the History.Notes field contains the first 255 characters of the History.Longnotes field for display purposes, so you would want to perform the same update on both fields. &lt;/p&gt;
&lt;p&gt;Thanks for reading! &lt;br /&gt;&lt;/p&gt;
&lt;img src="http://customerfx.com/aggbug.aspx?PostID=45600" width="1" height="1"&gt;</content><author><name>Jason Buss</name><uri>http://customerfx.com/members/Jason-Buss.aspx</uri></author><category term="How-To" scheme="http://customerfx.com/pages/customization/archive/tags/How-To/default.aspx" /><category term="SQL" scheme="http://customerfx.com/pages/customization/archive/tags/SQL/default.aspx" /></entry><entry><title>Summary and GroupBy of data using IRepository and projections</title><link rel="alternate" type="text/html" href="http://customerfx.com/pages/customization/2012/04/05/Summary-and-GroupBy-of-data-using-IRepository-and-Projections.aspx" /><id>http://customerfx.com/pages/customization/2012/04/05/Summary-and-GroupBy-of-data-using-IRepository-and-Projections.aspx</id><published>2012-04-05T11:13:00Z</published><updated>2012-04-05T11:13:00Z</updated><content type="html">&lt;p&gt;In the SalesLogix web client, you don&amp;#39;t really have the same old options regarding Queries and Datasets.&amp;nbsp; However, by using IRepository you can create similar functionality by using projections to define groups and other calculations.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;In this case, I needed to present a dialog displaying a breakdown of completed ticket activity rates for a ticket.&amp;nbsp; This was previously set up in the LAN client using this query:&lt;br /&gt;&lt;/p&gt;

&lt;pre&gt;&lt;span style="color:Blue;"&gt;select&lt;/span&gt; 
    b.typedesc, 
    &lt;span style="color:Blue;"&gt;sum&lt;/span&gt;(a.elapsedunits) &lt;span style="color:Blue;"&gt;as&lt;/span&gt; hourtime 
&lt;span style="color:Blue;"&gt;from&lt;/span&gt; 
    ticketactivity a 
&lt;span style="color:Blue;"&gt;left&lt;/span&gt; &lt;span style="color:Blue;"&gt;join&lt;/span&gt; 
    ticketactivityrate b 
&lt;span style="color:Blue;"&gt;on&lt;/span&gt; 
    a.ratetypedesc=b.ticketactivityrateid 
&lt;span style="color:Blue;"&gt;where&lt;/span&gt; 
    a.ticketid=&lt;span style="color:Navy;"&gt;&lt;span&gt;&amp;#39;12&lt;a style="cursor:pointer;"&gt;3456789012&lt;/a&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt; 
&lt;span style="color:Blue;"&gt;group&lt;/span&gt; &lt;span style="color:Blue;"&gt;by&lt;/span&gt; b.typedesc&lt;/pre&gt;  
&lt;p&gt;Basically, this query was used to create a recordset which was looped through to build a string that was then displayed in a Messagebox. &lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;



&lt;p&gt;In order to implement this in the web, I added a button to the Ticket Detail quickform, and added a C# Code Snippet to the OnClick event of that button.&lt;/p&gt;

&lt;p&gt;First of all, I created a reference to the ITicket interface for the current record.&amp;nbsp; I also used the repository helper to create a repository for Ticket Activity&lt;/p&gt;

&lt;table style="table-layout:fixed;width:600px;" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre&gt; Sage.Entity.Interfaces.ITicket ticket &lt;span style="color:Navy;"&gt;=&lt;/span&gt; &lt;span style="color:Blue;"&gt;this&lt;/span&gt;.BindingSource.Current as Sage.Entity.Interfaces.ITicket;
Sage.Platform.RepositoryHelper&amp;lt;Sage.Entity.Interfaces.ITicketActivity&amp;gt; repository &lt;span style="color:Navy;"&gt;=&lt;/span&gt; Sage.Platform.EntityFactory.GetRepositoryHelper&amp;lt;Sage.Entity.Interfaces.ITicketActivity&amp;gt;();&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
  
&lt;p&gt;Next, after setting a couple variables holding the TicketNumber and TicketID, I started building my Criteria for IRepository.&amp;nbsp;&amp;nbsp;&amp;nbsp; Using a Projectionlist, I added a sum of the ElapsedUnits property, and grouped by the RateTypeDesc property from the TicketActivity entity. (These properties need to be visible in the entity model, otherwise this will not work.&amp;nbsp; Out of the box, RateTypeDesc is not visible, so I had to modify the entity)&lt;/p&gt;

&lt;table style="table-layout:fixed;width:600px;" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre&gt;&lt;span style="color:Blue;"&gt;string&lt;/span&gt; sTicketNumber;
&lt;span style="color:Blue;"&gt;string&lt;/span&gt; sTicketID;
&lt;span style="color:Blue;"&gt;string&lt;/span&gt; sMessage;
sTicketNumber &lt;span style="color:Navy;"&gt;=&lt;/span&gt; ticket.TicketNumber.ToString();
sTicketID &lt;span style="color:Navy;"&gt;=&lt;/span&gt; ticket.Id.ToString();
Sage.Platform.Repository.ICriteria criteria &lt;span style="color:Navy;"&gt;=&lt;/span&gt; repository.CreateCriteria();
criteria.Add(repository.EF.Eq(&lt;span&gt;&amp;quot;Ticket.Id&amp;quot;&lt;/span&gt;, sTicketID));&lt;/pre&gt;&lt;pre&gt;criteria.SetProjection(repository.PF.ProjectionList().Add(repository.PF.Sum(&lt;span&gt;&amp;quot;ElapsedUnits&amp;quot;&lt;/span&gt;)).Add(repository.PF.GroupProperty(&lt;span&gt;&amp;quot;RateTypeDesc&amp;quot;&lt;/span&gt;)));&lt;/pre&gt;&lt;pre&gt;System.Collections.IList result &lt;span style="color:Navy;"&gt;=&lt;/span&gt; criteria.List();&lt;/pre&gt;&lt;pre&gt;&lt;span style="color:Blue;"&gt;if&lt;/span&gt; (result.Count == 0) 
{
    sMessage &lt;span style="color:Navy;"&gt;=&lt;/span&gt; &lt;span&gt;&amp;quot;No Time logged against ticket &amp;quot;&lt;/span&gt; &lt;span style="color:Navy;"&gt;+&lt;/span&gt; sTicketNumber;
}
&lt;span style="color:Blue;"&gt;else&lt;/span&gt;
{
    sMessage &lt;span style="color:Navy;"&gt;=&lt;/span&gt; &lt;span&gt;&amp;quot;Time summary for ticket &amp;quot;&lt;/span&gt; &lt;span style="color:Navy;"&gt;+&lt;/span&gt; sTicketNumber &lt;span style="color:Navy;"&gt;+&lt;/span&gt; &lt;span&gt;&amp;quot;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;quot;&lt;/span&gt;;
}&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
  
&lt;p&gt;As you can see, I get my result and check the count to see what message I want to display.&amp;nbsp; Finally, I loop through the IList to build my string.&amp;nbsp; Since RateTypeDesc holds an ID for the rate found in the TicketActivityRate entity, I use the GetByID function in the EntityFactory to return the actual Rate description.&lt;/p&gt;

&lt;table style="table-layout:fixed;width:600px;" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre&gt;&lt;span style="color:Blue;"&gt;foreach&lt;/span&gt; (IList i &lt;span style="color:Blue;"&gt;in&lt;/span&gt; result)
{
    &lt;span style="color:Blue;"&gt;if&lt;/span&gt; (Convert.ToDouble(i[0])!=0) 
    {
    Sage.Entity.Interfaces.ITicketActivityRate rate &lt;span style="color:Navy;"&gt;=&lt;/span&gt; Sage.Platform.EntityFactory.GetById&amp;lt;Sage.Entity.Interfaces.ITicketActivityRate&amp;gt;(i[1]);
    sMessage &lt;span style="color:Navy;"&gt;=&lt;/span&gt; sMessage &lt;span style="color:Navy;"&gt;+&lt;/span&gt; (rate == &lt;span style="color:Blue;"&gt;null&lt;/span&gt; ? &lt;span style="color:#008080;"&gt;&amp;quot;None Defined&amp;quot;&lt;/span&gt;: rate.TypeDescription.ToString()) &lt;span style="color:Navy;"&gt;+&lt;/span&gt; &lt;span style="color:#008080;"&gt;&amp;quot; - &amp;quot;&lt;/span&gt; &lt;span style="color:Navy;"&gt;+&lt;/span&gt; Math.Round(Convert.ToDouble(i[0]), 2).ToString() &lt;span style="color:Navy;"&gt;+&lt;/span&gt; &lt;span style="color:#008080;"&gt;&amp;quot; hours&amp;lt;br&amp;gt;&amp;quot;&lt;/span&gt;;
    }
}&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
  
&lt;p&gt;Once I have my string,&amp;nbsp; I simply raise a ValidationException and pass the sMessage string variable.&amp;nbsp; I ended up using the ValidationException because it allows you to include HTML code, which I used to include breaks after each rate.&lt;/p&gt;
&lt;table style="table-layout:fixed;width:600px;" cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt; throw &lt;span style="color:Blue;"&gt;new&lt;/span&gt; Sage.Platform.Application.ValidationException(sMessage);&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;  
&lt;p&gt;&lt;a href="http://customerfx.com/blogs/customization/SLXWeb_TicketHoursValidation.JPG"&gt;&lt;img src="http://customerfx.com/blogs/customization/SLXWeb_TicketHoursValidation.JPG" border="0" alt="" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;That&amp;#39;s all there was to it.&amp;nbsp; Ultimately, it ended up not being that difficult to accomplish once I started to understand Projections in IRepository.&amp;nbsp; &lt;/p&gt;&lt;p&gt;Thanks for reading! &lt;br /&gt;&lt;/p&gt;
&lt;img src="http://customerfx.com/aggbug.aspx?PostID=45565" width="1" height="1"&gt;</content><author><name>Jason Buss</name><uri>http://customerfx.com/members/Jason-Buss.aspx</uri></author><category term="How-To" scheme="http://customerfx.com/pages/customization/archive/tags/How-To/default.aspx" /><category term="SalesLogix Web" scheme="http://customerfx.com/pages/customization/archive/tags/SalesLogix+Web/default.aspx" /><category term="Projections" scheme="http://customerfx.com/pages/customization/archive/tags/Projections/default.aspx" /><category term="IRepository" scheme="http://customerfx.com/pages/customization/archive/tags/IRepository/default.aspx" /></entry><entry><title>(not quite as) Easily Increasing the Height of the Picklist Dropdown in SalesLogix Web</title><link rel="alternate" type="text/html" href="http://customerfx.com/pages/customization/2012/03/22/_2800_not-quite-as_2900_-Easily-Increasing-the-Height-of-the-Picklist-Dropdown-in-SalesLogix-Web.aspx" /><id>http://customerfx.com/pages/customization/2012/03/22/_2800_not-quite-as_2900_-Easily-Increasing-the-Height-of-the-Picklist-Dropdown-in-SalesLogix-Web.aspx</id><published>2012-03-22T19:28:00Z</published><updated>2012-03-22T19:28:00Z</updated><content type="html">&lt;p&gt;My colleague Ryan just &lt;a href="http://customerfx.com/pages/crmdeveloper/2012/03/22/easily-increasing-the-height-of-the-picklist-dropdown-in-saleslogix-web.aspx"&gt;posted &lt;/a&gt;about a simple method to increase the height of picklist dropdowns in the SalesLogix web client. &lt;/p&gt;

&lt;p&gt;I have a slightly different way to accomplish the same thing for individual picklists, so while not really more difficult to do, would require you to do it for as many picklists you want to modify.&amp;nbsp; Ryan&amp;#39;s solution modifies a stylesheet to affect all picklists in the system at once.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;In order to alter a specific picklist on a quickform, add a new C# Snippet action item to the Load event of the form, and add the following code to the action item: &lt;br /&gt;&lt;/p&gt;

&lt;pre&gt;&lt;span style="color:Blue;"&gt;string&lt;/span&gt; script &lt;span style="color:Navy;"&gt;=&lt;/span&gt; &lt;span style="color:#008080;"&gt;&amp;quot;var btn = document.getElementById(&amp;#39;&amp;quot;&lt;/span&gt; &lt;span style="color:Navy;"&gt;+&lt;/span&gt; pklType.ClientID +&lt;span style="color:#008080;"&gt;&amp;quot;_Items&amp;#39;); if(btn) btn.size=&amp;#39;8&amp;#39;;&amp;quot;&lt;/span&gt;; 
ScriptManager.RegisterStartupScript(Page, GetType(), &lt;span style="color:#008080;"&gt;&amp;quot;FXSetPickListSize&amp;quot;&lt;/span&gt;, script, &lt;span style="color:Blue;"&gt;true&lt;/span&gt;);&lt;/pre&gt;

&lt;p&gt;This particular code sample will modify the Account Type picklist on the AccountDetails quickform to a height of eight lines. Make sure you set the On Repaint Event and Refresh Data properties to True for the C# Code snippet, otherwise the change will not persist.&lt;/p&gt;&lt;p&gt;&amp;nbsp;If you want to see how to do this for all picklists at once, see Ryan&amp;#39;s post &lt;a href="http://customerfx.com/pages/crmdeveloper/2012/03/22/easily-increasing-the-height-of-the-picklist-dropdown-in-saleslogix-web.aspx" title="Easily Increasing the Height of the Picklist Dropdown in SalesLogix Web"&gt;here&lt;/a&gt;. &lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;img src="http://customerfx.com/aggbug.aspx?PostID=45525" width="1" height="1"&gt;</content><author><name>Jason Buss</name><uri>http://customerfx.com/members/Jason-Buss.aspx</uri></author><category term="SalesLogix" scheme="http://customerfx.com/pages/customization/archive/tags/SalesLogix/default.aspx" /><category term="SalesLogix Web" scheme="http://customerfx.com/pages/customization/archive/tags/SalesLogix+Web/default.aspx" /><category term="Customization" scheme="http://customerfx.com/pages/customization/archive/tags/Customization/default.aspx" /></entry><entry><title>Exporting Table data via the SalesLogix web client</title><link rel="alternate" type="text/html" href="http://customerfx.com/pages/customization/2012/02/22/exporting-table-data-via-the-saleslogix-web-client.aspx" /><link rel="enclosure" type="application/x-zip-compressed" length="1503" href="http://customerfx.com/pages/customization/attachment/45461.ashx" /><id>http://customerfx.com/pages/customization/2012/02/22/exporting-table-data-via-the-saleslogix-web-client.aspx</id><published>2012-02-22T13:00:00Z</published><updated>2012-02-22T13:00:00Z</updated><content type="html">&lt;p&gt;Recently, I had a request to create export functionality for a datagrid in the SalesLogix web client. &amp;nbsp; I had a little difficulty exporting data from the actual grid, but as an alternative, we put together functionality to export data based on a provided SQL query. (Thanks to &lt;a href="http://customerfx.com/pages/crmdeveloper/default.aspx" title="Ryan Farley&amp;#39;s Blog" target="_blank"&gt;Ryan &lt;/a&gt;for working out the SmartPart code)&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;By creating a new custom smartpart, we can simply export the results of a SQL query to a CSV file, save it on the webserver and download it to an individual client.&lt;/p&gt;
&lt;p&gt;First, you&amp;#39;ll want to create a folder on the web server to hold the exported file.&amp;nbsp; In this case, I&amp;#39;m exporting contact data based on the current account, so I created an export folder under the SupportFiles/SmartParts/Account folder in the portal manager.&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://customerfx.com/blogs/customization/SLXWeb%20Project%20Exporer.JPG"&gt;&lt;img src="http://customerfx.com/blogs/customization/SLXWeb%20Project%20Exporer.JPG" border="0" alt="" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Once we have a location for our file, we need to add the SmartPart files.&amp;nbsp; I&amp;#39;ve attached the files I created to this post.&amp;nbsp; They can be added by right-clicking on the entity folder and selecting &amp;quot;Add Existing Files...&amp;quot;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://customerfx.com/blogs/customization/SLXWeb%20Add%20Files.JPG"&gt;&lt;img src="http://customerfx.com/blogs/customization/SLXWeb%20Add%20Files.JPG" border="0" alt="" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;The page I created simply pulls in a few different contact table fields.&amp;nbsp; This can be easily modified.&amp;nbsp; On the code page for the Smart Part, there are a couple functions you&amp;#39;ll need to understand in order to customize this to pull in the data you want.&amp;nbsp; First of all, the CreateFile function is where you define the SQL script and fields you would like to return.&lt;br /&gt;&lt;/p&gt;

&lt;table style="table-layout:fixed;width:600px;" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre&gt; &lt;span style="color:Blue;"&gt;private&lt;/span&gt; &lt;span style="color:Blue;"&gt;void&lt;/span&gt; CreateFile(&lt;span style="color:Blue;"&gt;string&lt;/span&gt; file)
{
    &lt;span style="color:Green;"&gt;//First, we&amp;#39;re checking to see if the file already exists, deleting it if found.
&lt;/span&gt;    &lt;span style="color:Blue;"&gt;if&lt;/span&gt; (File.Exists(file))
        File.Delete(file);
    &lt;span style="color:Blue;"&gt;using&lt;/span&gt; (&lt;span style="color:Blue;"&gt;var&lt;/span&gt; writer &lt;span style="color:Navy;"&gt;=&lt;/span&gt; &lt;span style="color:Blue;"&gt;new&lt;/span&gt; StreamWriter(file, &lt;span style="color:Blue;"&gt;false&lt;/span&gt;))
    {
        &lt;span style="color:Green;"&gt;//This line defines the column headers in the CSV file.
&lt;/span&gt;        writer.WriteLine(&lt;span style="color:#008080;"&gt;&amp;quot;\&amp;quot;ContactID\&amp;quot;,\&amp;quot;FirstName\&amp;quot;,\&amp;quot;LastName\&amp;quot;,\&amp;quot;Workphone\&amp;quot;&amp;quot;&lt;/span&gt;);
        &lt;span style="color:Blue;"&gt;using&lt;/span&gt; (&lt;span style="color:Blue;"&gt;var&lt;/span&gt; conn &lt;span style="color:Navy;"&gt;=&lt;/span&gt; &lt;span style="color:Blue;"&gt;new&lt;/span&gt; OleDbConnection(ConnectionString))
        {
            conn.Open();
            &lt;span style="color:Green;"&gt;//Using an OleDBCommand, we pass the query defining the data we want to return.  For this example, 
&lt;/span&gt;            &lt;span style="color:Green;"&gt;//we&amp;#39;re just returning data from the contact table where the accountid is what is passed when calling the page.
&lt;/span&gt;            &lt;span style="color:Blue;"&gt;using&lt;/span&gt; (&lt;span style="color:Blue;"&gt;var&lt;/span&gt; cmd &lt;span style="color:Navy;"&gt;=&lt;/span&gt; &lt;span style="color:Blue;"&gt;new&lt;/span&gt; OleDbCommand(&lt;span style="color:Blue;"&gt;string&lt;/span&gt;.Format(&lt;span style="color:#008080;"&gt;&amp;quot;SELECT * FROM CONTACT WHERE ACCOUNTID = &amp;#39;{0}&amp;#39;&amp;quot;&lt;/span&gt;, AccountId), conn))
            {
                &lt;span style="color:Green;"&gt;//Now we create a reader object to loop through the returned records.
&lt;/span&gt;                &lt;span style="color:Blue;"&gt;var&lt;/span&gt; reader &lt;span style="color:Navy;"&gt;=&lt;/span&gt; cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
                &lt;span style="color:Blue;"&gt;while&lt;/span&gt; (reader.Read())
                {
                    &lt;span style="color:Green;"&gt;//Finally, we&amp;#39;re defining the fields from the Database to return.  Obviously, these should match the column headers previously defined.
&lt;/span&gt;                    writer.WriteLine(&lt;span style="color:Blue;"&gt;string&lt;/span&gt;.Format(&lt;span style="color:#008080;"&gt;&amp;quot;\&amp;quot;{0}\&amp;quot;,\&amp;quot;{1}\&amp;quot;,\&amp;quot;{2}\&amp;quot;,\&amp;quot;{3}\&amp;quot;&amp;quot;&lt;/span&gt;, reader[&lt;span style="color:#008080;"&gt;&amp;quot;CONTACTID&amp;quot;&lt;/span&gt;], reader[&lt;span style="color:#008080;"&gt;&amp;quot;FIRSTNAME&amp;quot;&lt;/span&gt;], reader[&lt;span style="color:#008080;"&gt;&amp;quot;LASTNAME&amp;quot;&lt;/span&gt;], reader[&lt;span style="color:#008080;"&gt;&amp;quot;WORKPHONE&amp;quot;&lt;/span&gt;]));
                }
            }
        }
    }
}
&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
  
  
&lt;p&gt;The Page load event calls the CreateFile function and handles pushing the CSV file to the requesting user.&amp;nbsp; Also, you could modify this to create other types of files, such as an excel spreadsheet.&amp;nbsp; We chose a CSV in this case to reduce potential overhead on the webserver. &lt;br /&gt;&lt;/p&gt;

&lt;table style="table-layout:fixed;width:600px;" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre&gt; &lt;span style="color:Blue;"&gt;protected&lt;/span&gt; &lt;span style="color:Blue;"&gt;void&lt;/span&gt; Page_Load(object sender, EventArgs e)
{
    &lt;span style="color:Green;"&gt;//The page_load event calls the CreateFile function, saving it to the Export folder 
&lt;/span&gt;    &lt;span style="color:Green;"&gt;//and pushes it to the requesting user.  The file is saved on the server with the
&lt;/span&gt;    &lt;span style="color:Green;"&gt;//name of (userid).csv.  This way there will only be as many files saved on the 
&lt;/span&gt;    &lt;span style="color:Green;"&gt;//server as there are users in SalesLogix.
&lt;/span&gt;            
    &lt;span style="color:Blue;"&gt;var&lt;/span&gt; file &lt;span style="color:Navy;"&gt;=&lt;/span&gt; &lt;span style="color:Blue;"&gt;string&lt;/span&gt;.Format(&lt;span style="color:#008080;"&gt;&amp;quot;{0}\\SmartParts\\Account\\Export\\{1}.csv&amp;quot;&lt;/span&gt;, GetSlxClientBaseUrl(), UserId);
    CreateFile(file);
    Response.Buffer &lt;span style="color:Navy;"&gt;=&lt;/span&gt; &lt;span style="color:Blue;"&gt;false&lt;/span&gt;;
    Response.Clear();
    Response.ClearContent();
    Response.ClearHeaders();
    Response.ContentType &lt;span style="color:Navy;"&gt;=&lt;/span&gt; &lt;span style="color:#008080;"&gt;&amp;quot;application/csv&amp;quot;&lt;/span&gt;;
    &lt;span style="color:Green;"&gt;//This line defines the file name in the Save dialog for the user.  In this case, (accountid)-contacts.csv.
&lt;/span&gt;    Response.AppendHeader(&lt;span style="color:#008080;"&gt;&amp;quot;Content-Disposition&amp;quot;&lt;/span&gt;, &lt;span style="color:Blue;"&gt;string&lt;/span&gt;.Format(&lt;span style="color:#008080;"&gt;&amp;quot;attachment;filename={0}-Contacts.csv&amp;quot;&lt;/span&gt;, AccountId));
    Response.AppendHeader(&lt;span style="color:#008080;"&gt;&amp;quot;Content-Length&amp;quot;&lt;/span&gt;, (&lt;span style="color:Blue;"&gt;new&lt;/span&gt; FileInfo(file).Length.ToString()));
    &lt;span style="color:Green;"&gt;//Finally, the file is transmitted to the end-user.
&lt;/span&gt;    Response.TransmitFile(file);
    Response.End();
}
&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
  
&lt;p&gt;Now that the SmartPart is set up, we just need some code to navigate to the page and pass the current accountID.&amp;nbsp; You can launch this from pretty much anywhere.&amp;nbsp; Since I&amp;#39;m calling this from within the account entity, I added a button to call a C# code Snippet.&amp;nbsp; The code is pretty simple: &lt;br /&gt;&lt;/p&gt;
&lt;table style="table-layout:fixed;width:600px;" cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt; &lt;span style="color:Blue;"&gt;var&lt;/span&gt; account &lt;span style="color:Navy;"&gt;=&lt;/span&gt; &lt;span style="color:Blue;"&gt;this&lt;/span&gt;.BindingSource.Current as Sage.Entity.Interfaces.IAccount;
Response.Redirect(&lt;span style="color:Blue;"&gt;string&lt;/span&gt;.Format(&lt;span style="color:#008080;"&gt;&amp;quot;/SlxClient/SmartParts/Account/TestExport.aspx?accountid={0}&amp;quot;&lt;/span&gt;, account.Id));&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;  
&lt;p&gt;As you can see, I&amp;#39;m getting the current accountid from the current binding source, and performing a redirect to the SmartPart while appending the accountID.&lt;/p&gt;&lt;p&gt;That&amp;#39;s all there is to it. &amp;nbsp; With this in place, your end users can simply push a button and download a file containing any data that you can define in a SQL query.&lt;/p&gt;&lt;p&gt;I hope you find this helpful.&amp;nbsp; Thanks for reading! &lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;img src="http://customerfx.com/aggbug.aspx?PostID=45461" width="1" height="1"&gt;</content><author><name>Jason Buss</name><uri>http://customerfx.com/members/Jason-Buss.aspx</uri></author><category term="How-To" scheme="http://customerfx.com/pages/customization/archive/tags/How-To/default.aspx" /><category term="SalesLogix Web" scheme="http://customerfx.com/pages/customization/archive/tags/SalesLogix+Web/default.aspx" /><category term="C#" scheme="http://customerfx.com/pages/customization/archive/tags/C_2300_/default.aspx" /><category term="ASP" scheme="http://customerfx.com/pages/customization/archive/tags/ASP/default.aspx" /></entry><entry><title>Missing Properties/Toolbox window in SalesLogix LAN</title><link rel="alternate" type="text/html" href="http://customerfx.com/pages/customization/2012/01/25/Missing-Properties_2F00_Toolbox-window-in-SalesLogix-LAN.aspx" /><id>http://customerfx.com/pages/customization/2012/01/25/Missing-Properties_2F00_Toolbox-window-in-SalesLogix-LAN.aspx</id><published>2012-01-25T20:56:00Z</published><updated>2012-01-25T20:56:00Z</updated><content type="html">&lt;p&gt;If you work on SalesLogix across a number of remote desktop connections and a number of different workstations as I do, you may occasionally run into an issue where the Properties or Toolbox windows cannot be made visible.&amp;nbsp; This happens when you first start a Remote session from a machine with a greater screen resolution, move one of those windows to the far right of the screen, then start a Remote session on a machine with a smaller resolution.&amp;nbsp; You can then end up in a situation where the propertes and/or toolbars views are technically &amp;quot;visible&amp;quot; but are in a position outside of the current screen resolution.&lt;/p&gt;&lt;p&gt;This can be remedied pretty easily by closing Architect, deleting the registry key: HKEY_CURRENT_USER\Software\SalesLogix\Architect and then reopening Architect.&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;a href="http://customerfx.com/blogs/customization/ArchitectRegistryEntry.JPG"&gt;&lt;img src="http://customerfx.com/blogs/customization/ArchitectRegistryEntry.JPG" border="0" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt; The registry key will be recreated upon reopening architect, and the Properties and Toolbar windows should be reset to their default positions.&lt;br /&gt;&lt;/p&gt;&lt;img src="http://customerfx.com/aggbug.aspx?PostID=45428" width="1" height="1"&gt;</content><author><name>Jason Buss</name><uri>http://customerfx.com/members/Jason-Buss.aspx</uri></author><category term="SalesLogix" scheme="http://customerfx.com/pages/customization/archive/tags/SalesLogix/default.aspx" /><category term="How-To" scheme="http://customerfx.com/pages/customization/archive/tags/How-To/default.aspx" /><category term="Properties" scheme="http://customerfx.com/pages/customization/archive/tags/Properties/default.aspx" /><category term="Toolbox" scheme="http://customerfx.com/pages/customization/archive/tags/Toolbox/default.aspx" /></entry><entry><title>Populating fields from a lookup result set in the SalesLogix web client</title><link rel="alternate" type="text/html" href="http://customerfx.com/pages/customization/2012/01/11/Populating-fields-from-a-lookup-result-set-in-the-SalesLogix-web-client.aspx" /><id>http://customerfx.com/pages/customization/2012/01/11/Populating-fields-from-a-lookup-result-set-in-the-SalesLogix-web-client.aspx</id><published>2012-01-11T11:30:00Z</published><updated>2012-01-11T11:30:00Z</updated><content type="html">&lt;p&gt;Recently, I needed to create an account tab in the web client which would show a number of values from a stand-alone entity in SalesLogix.&amp;nbsp; Using child relationships, SalesLogix web makes this easy to do. &lt;br /&gt;&lt;/p&gt;&lt;p&gt;In this example, I&amp;#39;m creating a simple Product tab at the account level.  This tab contains a Product Lookup to select a product for the account, and then also shows a number of product fields on the view.  These product fields are read only, and I wanted them to update based on what was selected in the Lookup.

&lt;/p&gt;&lt;p&gt;Using relationships in the web client makes this easy.  First of all, I created added a ProductID field in the account table, and added that as a property to the account entity.  Once I had that property, I created a new child relationship to the Product entity under account.
&lt;/p&gt;&lt;p&gt;&lt;a href="http://customerfx.com/blogs/customization/SLXWeb%20ProductRelationship.jpg"&gt;&lt;img src="http://customerfx.com/blogs/customization/SLXWeb%20ProductRelationship.jpg" border="0" alt="" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Now that we have this relationship, I created a new QuickForm to hold the product information.&amp;nbsp; On the quick form, I added a Lookup as well as a couple other fields.&lt;/p&gt;&lt;p&gt;&lt;a href="http://customerfx.com/blogs/customization/SLXWebClient_NewProductView.png"&gt;&lt;img src="http://customerfx.com/blogs/customization/SLXWebClient_NewProductView.png" border="0" alt="" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;On the lookup control, I set the bindings property to the Products relationship I created.&amp;nbsp; In addition, I needed to set the Lookup Binding Mode property to &amp;quot;Object&amp;quot; and the Lookup Entity Name property to &amp;quot;Product&amp;quot;.&lt;/p&gt;&lt;p&gt;&lt;a href="http://customerfx.com/blogs/customization/SLXWeb_ProductLookupProperties.png"&gt;&lt;img src="http://customerfx.com/blogs/customization/SLXWeb_ProductLookupProperties.png" height="368" border="0" width="691" alt="" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;For the other fields, the bind property just needs to be set to MainEntity.Products.&lt;i&gt;FieldName&lt;/i&gt;, as well as setting the ReadOnly properties to &amp;quot;True&amp;quot;.&lt;/p&gt;&lt;p&gt;That&amp;#39;s it!&amp;nbsp; On this view, when you use the product Lookup and select a product, the appropriate values will be displayed in the other fields on the form. &lt;br /&gt;&lt;/p&gt;&lt;img src="http://customerfx.com/aggbug.aspx?PostID=45413" width="1" height="1"&gt;</content><author><name>Jason Buss</name><uri>http://customerfx.com/members/Jason-Buss.aspx</uri></author><category term="How-To" scheme="http://customerfx.com/pages/customization/archive/tags/How-To/default.aspx" /><category term="SalesLogix Web" scheme="http://customerfx.com/pages/customization/archive/tags/SalesLogix+Web/default.aspx" /><category term="Lookups" scheme="http://customerfx.com/pages/customization/archive/tags/Lookups/default.aspx" /></entry><entry><title>Modifying the QuickFind Lookup in the SalesLogix LAN client</title><link rel="alternate" type="text/html" href="http://customerfx.com/pages/customization/2011/11/02/modifying-the-quickfind-lookup-in-the-saleslogix-lan-client.aspx" /><id>http://customerfx.com/pages/customization/2011/11/02/modifying-the-quickfind-lookup-in-the-saleslogix-lan-client.aspx</id><published>2011-11-02T07:30:00Z</published><updated>2011-11-02T07:30:00Z</updated><content type="html">&lt;p&gt;The Quick Find functionality in the SalesLogix web client is a fast and easy way to look up information from many different areas in SalesLogix, but did you know you could modify the layout of the various lookups displayed in that interface?&amp;nbsp; The functionality is a little hard to find if you don&amp;#39;t know where to look, but this post will explain how you can modify the Quick Find lookups.&lt;/p&gt;&lt;p&gt;&lt;a href="http://customerfx.com/blogs/customization/SLXLan%20Quick%20Find.JPG"&gt;&lt;img src="http://customerfx.com/blogs/customization/SLXLan%20Quick%20Find.JPG" border="0" alt="" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;For this example, I&amp;#39;ll look at the Account Details Quick Find.&amp;nbsp; All the lookups for this functionality are found with all the others under the Manage|Lookups menu in SalesLogix Architect.&amp;nbsp; For the Quick Find for Account Details, it is the Account.Account lookup.&lt;/p&gt;&lt;p&gt;&lt;a href="http://customerfx.com/blogs/customization/SLXLan%20AccountAccountLookup.JPG"&gt;&lt;img src="http://customerfx.com/blogs/customization/SLXLan%20AccountAccountLookup.JPG" border="0" alt="" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Once you have the lookup, it&amp;#39;s a simple matter of changing the layout to include whatever fields you want to include.&amp;nbsp; The only problem is this... there are many lookups defined under account, as there are for contacts, opportunities, leads, etc.&amp;nbsp; How are you supposed to know which of those lookups are utilized in the Quick Find view for each entity?&lt;/p&gt;&lt;p&gt;The answer to that lays in the properties for the Main View for each of the areas.&amp;nbsp; If you look at the Account Details Main View, you will see a property called &amp;quot;QuickFindLookup&amp;quot;.&amp;nbsp; This property defines which lookup is used for that entity.&lt;/p&gt;&lt;p&gt;&lt;a href="http://customerfx.com/blogs/customization/SLXLan%20Account%20MainView%20Properties.JPG"&gt;&lt;img src="http://customerfx.com/blogs/customization/SLXLan%20Account%20MainView%20Properties.JPG" border="0" alt="" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Once you have that information, you know which of the lookups you want to modify.&amp;nbsp; You also have the option to define a different lookup to be used for the Quick Find for that entity.&lt;/p&gt;&lt;p&gt;That&amp;#39;s all there is to it.&amp;nbsp; Once you know where to look, it&amp;#39;s easy to change the Quick Find functionality for each entity.&lt;/p&gt;&lt;p&gt;Thanks for reading!&lt;/p&gt;&lt;p&gt;Jason &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://customerfx.com/aggbug.aspx?PostID=45282" width="1" height="1"&gt;</content><author><name>Jason Buss</name><uri>http://customerfx.com/members/Jason-Buss.aspx</uri></author><category term="SalesLogix LAN Client" scheme="http://customerfx.com/pages/customization/archive/tags/SalesLogix+LAN+Client/default.aspx" /><category term="Customizations" scheme="http://customerfx.com/pages/customization/archive/tags/Customizations/default.aspx" /><category term="Development" scheme="http://customerfx.com/pages/customization/archive/tags/Development/default.aspx" /><category term="How-To" scheme="http://customerfx.com/pages/customization/archive/tags/How-To/default.aspx" /><category term="Main Views" scheme="http://customerfx.com/pages/customization/archive/tags/Main+Views/default.aspx" /><category term="Lookups" scheme="http://customerfx.com/pages/customization/archive/tags/Lookups/default.aspx" /><category term="Quick Find" scheme="http://customerfx.com/pages/customization/archive/tags/Quick+Find/default.aspx" /></entry><entry><title>Launching Schedule Activity functionality in the SLX Web client</title><link rel="alternate" type="text/html" href="http://customerfx.com/pages/customization/2011/10/27/Launching-Schedule-Activity-functionality-in-the-SLX-Web-client.aspx" /><id>http://customerfx.com/pages/customization/2011/10/27/Launching-Schedule-Activity-functionality-in-the-SLX-Web-client.aspx</id><published>2011-10-27T12:31:00Z</published><updated>2011-10-27T12:31:00Z</updated><content type="html">&lt;p&gt;On a recent project, I worked on emulating functionality similar to what is found in the LAN client where a user is presented a dialog asking them to choose between different activity types then launching into the Schedule Activity functionality.&amp;nbsp; I found this was fairly easy to duplicate in the web client, and in this post, I&amp;#39;ll quickly go through the steps for creating that type of functionality.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;First of all, we need to create a quick from which will give users a choice of what type of activity to create.&amp;nbsp; Since this form contains no bound controls, it doesn&amp;#39;t matter where we save it.&amp;nbsp; For the sake of consistency, I&amp;#39;d recommend saving it under SalesLogix Activity Support.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;Under SalesLogix Activity Support in the Project Explorer, expand the Activity node, right-click the Forms folder and select &amp;quot;Add Form&amp;quot;.&amp;nbsp; &lt;/p&gt;

&lt;p&gt;The important elements of this view are the radio group control and the button.&amp;nbsp; The radio group will provide users the choice of what type of activity to create, and the button will handle launching the appropriate schedule activity dialog based on the option selected.&lt;/p&gt;&lt;p&gt;Once you have the blank form, add a radio group and control&amp;nbsp; In the radio group control, I have added choices for Phone Calls, Meetings and ToDos.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://customerfx.com/blogs/customization/SLXWeb%20Activity%20Quickform.JPG"&gt;&lt;img src="http://customerfx.com/blogs/customization/SLXWeb%20Activity%20Quickform.JPG" border="0" alt="" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;On the button I added to the form, I added a C# Snippet Action item to the click event of the button and added the following code: &lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;table style="table-layout:fixed;width:600px;" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre&gt; LinkHandler Link &lt;span style="color:Navy;"&gt;=&lt;/span&gt; &lt;span style="color:Blue;"&gt;new&lt;/span&gt; LinkHandler(Page);
&lt;span style="color:Blue;"&gt;if&lt;/span&gt; (rgActivityType.SelectedIndex == 0)
{
    Link.SchedulePhoneCall();
}
&lt;span style="color:Blue;"&gt;else&lt;/span&gt; &lt;span style="color:Blue;"&gt;if&lt;/span&gt; (rgActivityType.SelectedIndex == 1)
{
    Link.ScheduleMeeting();
}
&lt;span style="color:Blue;"&gt;else&lt;/span&gt; &lt;span style="color:Blue;"&gt;if&lt;/span&gt; (rgActivityType.SelectedIndex == 2)
{
    Link.ScheduleToDo();
}
&lt;span style="color:Blue;"&gt;else&lt;/span&gt;
{
    throw &lt;span style="color:Blue;"&gt;new&lt;/span&gt; Sage.Platform.Application.ValidationException(&lt;span style="color:#008080;"&gt;&amp;quot;You must select a activity type to continue&amp;quot;&lt;/span&gt;);
}&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;Creating a LinkHandler object gives you access to the various Schedule Activity forms.&amp;nbsp; An IF...Else statement calls the right schedule form based on what was selected.&amp;nbsp; I also added a Validation Exception in case no activity type was selected before clicking the Next button.&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;Once you have saved the new quick form, it is ready to go.&amp;nbsp; To use this form, you will need to add it to the available smartparts for whatever portal page you plan on calling the interface from.&amp;nbsp; To add the form, expand the Portal Manager-Sage SalesLogix-Pages nodes, and double click on whichever page you want to use.&lt;/p&gt;&lt;p&gt;When the page has opened, select the SmartParts tab and add the new form.&amp;nbsp; You will need to set the Target Workspace value to &amp;quot;DialogWorkspace&amp;quot;. &lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://customerfx.com/blogs/customization/SLXWebPortalPage.JPG"&gt;&lt;img src="http://customerfx.com/blogs/customization/SLXWebPortalPage.JPG" border="0" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;Now that the QuickForm has been added, you will need to add code to launch the form.&amp;nbsp; This could be from a button on a detail view, or wherever you can add a C# Snippit action.&lt;br /&gt;&lt;p&gt;I&amp;#39;m simply using the Dialog service to call the new QuickForm.&amp;nbsp; The SetSpecs function I&amp;#39;m using allows you to set the dimensions of the form you launch.&amp;nbsp; You may have to experiment with the settings to make things the appropriate size. &lt;br /&gt;&lt;/p&gt;
&lt;table style="table-layout:fixed;width:600px;" cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt; {
    &lt;span style="color:Green;"&gt;//create dialog for activity type to launch...
&lt;/span&gt;    &lt;span style="color:Blue;"&gt;if&lt;/span&gt; (DialogService !&lt;span style="color:Navy;"&gt;=&lt;/span&gt; &lt;span style="color:Blue;"&gt;null&lt;/span&gt;)
    {
        DialogService.SetSpecs(110, 318, &lt;span style="color:#008080;"&gt;&amp;quot;ScheduleActivity&amp;quot;&lt;/span&gt;, &lt;span style="color:#008080;"&gt;&amp;quot;Schedule Followup Activity&amp;quot;&lt;/span&gt;);
        DialogService.ShowDialog();
    }
}&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;&amp;nbsp; &lt;br /&gt;That&amp;#39;s about all there is to it!&amp;nbsp; I hope you find this example useful.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Thanks for reading!&lt;/p&gt;&lt;p&gt;&amp;nbsp;Jason &lt;br /&gt;&lt;/p&gt;&lt;img src="http://customerfx.com/aggbug.aspx?PostID=45269" width="1" height="1"&gt;</content><author><name>Jason Buss</name><uri>http://customerfx.com/members/Jason-Buss.aspx</uri></author><category term="SalesLogix" scheme="http://customerfx.com/pages/customization/archive/tags/SalesLogix/default.aspx" /><category term="Development" scheme="http://customerfx.com/pages/customization/archive/tags/Development/default.aspx" /><category term="How-To" scheme="http://customerfx.com/pages/customization/archive/tags/How-To/default.aspx" /><category term="SalesLogix Web" scheme="http://customerfx.com/pages/customization/archive/tags/SalesLogix+Web/default.aspx" /><category term="C#" scheme="http://customerfx.com/pages/customization/archive/tags/C_2300_/default.aspx" /><category term="Forms" scheme="http://customerfx.com/pages/customization/archive/tags/Forms/default.aspx" /><category term="DialogWorkspace" scheme="http://customerfx.com/pages/customization/archive/tags/DialogWorkspace/default.aspx" /></entry><entry><title>Hiding tabs in the web client using Roles</title><link rel="alternate" type="text/html" href="http://customerfx.com/pages/customization/2011/10/17/hiding-tabs-in-the-web-client-using-roles.aspx" /><id>http://customerfx.com/pages/customization/2011/10/17/hiding-tabs-in-the-web-client-using-roles.aspx</id><published>2011-10-17T14:32:00Z</published><updated>2011-10-17T14:32:00Z</updated><content type="html">&lt;p&gt;If you had a tab you wanted to hide in the LAN client, all you have to do is remove the current release.  Once that was done, the Admin user will continue to see the tab, but no other users will have access to it.  This is something that you can do in the Web client fairly easily as well, although you have to go about it slightly differently.

&lt;/p&gt;&lt;p&gt;In this post, I&amp;#39;ll do a quick walk-through of hiding the Products tab in the Opportunities area of the Web Client.

&lt;/p&gt;&lt;p&gt;The first step would be to create a new Role in the Web client.  This Role will be used on any tab you want to hide from users.  First, login to the web client as Admin, right-click the Roles button in the Administration section of the Navbar and select &amp;quot;New Role&amp;quot;.




&lt;/p&gt;&lt;p&gt;&lt;a href="http://customerfx.com/blogs/customization/SLXWebClient_CreatingNewRole.JPG"&gt;&lt;img src="http://customerfx.com/blogs/customization/SLXWebClient_CreatingNewRole.JPG" border="0" height="322" width="475" alt="" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;On the Insert Role screen, give the new role a name (and description if desired) and click the &amp;quot;Save&amp;quot; button.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;a href="http://customerfx.com/blogs/customization/SLXWebClient_InsertRoleView.JPG"&gt;&lt;img src="http://customerfx.com/blogs/customization/SLXWebClient_InsertRoleView.JPG" border="0" height="226" width="538" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;When the Role is created, you will have access to a &amp;quot;Users&amp;quot; and &amp;quot;Actions&amp;quot; tabs for this Role.&amp;nbsp; Since we are only using it to hide tabs to all users, there&amp;#39;s no need to define anything in either of these tabs.&amp;nbsp; If you did want particular users to still see the tab you were trying to hide, simply add them under the Users tab.&amp;nbsp; The Admin user is exempted from the Roles functionality and will continue to see the tab.&lt;/p&gt;&lt;p&gt;With the Role created, launch the Application Architect.&amp;nbsp; In the Project Explorer, expand Portal Manager-&amp;gt;Sage SalesLogix-&amp;gt;Pages and double-click &amp;quot;Opportunity Detail&amp;quot; to open the page.&amp;nbsp; With the page open, Select the OpportunityProductEX(Custom) smartpart from under the Smart Parts tab.&amp;nbsp; In the &amp;quot;Allow Roles&amp;quot; dropdown for the smartpart, simply select the Role you just created.&lt;/p&gt;&lt;p&gt;&lt;a href="http://customerfx.com/blogs/customization/SLXWebClient_OpportunityPage.JPG"&gt;&lt;img src="http://customerfx.com/blogs/customization/SLXWebClient_OpportunityPage.JPG" border="0" height="225" width="543" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;After a rebuild, and redeploy, that&amp;#39;s it!&amp;nbsp; The Opportunity Products tab should now be hidden for all but the Admin user.&lt;/p&gt;&lt;p&gt;*Note, this will only work on smart parts in the TabControl target workspace.&amp;nbsp; In the case of the Opportunity Products tab, this is also shown on the Insert Opportunity view, but in the MainContent workspace.&amp;nbsp; To remove products from the Insert Opportunity view, you would need to actually delete the Smart Part from the Page itself.&lt;/p&gt;&lt;p&gt;&lt;a href="http://customerfx.com/blogs/customization/SLXWebClient_InsertOpportunityPage.JPG"&gt;&lt;img src="http://customerfx.com/blogs/customization/SLXWebClient_InsertOpportunityPage.JPG" border="0" height="209" width="443" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;I hope you found this post helpful.&amp;nbsp; Thanks for reading! &amp;nbsp;&lt;img src="http://customerfx.com/emoticons/emotion-1.gif" alt="Smile" /&gt; &lt;br /&gt;&lt;/p&gt;&lt;img src="http://customerfx.com/aggbug.aspx?PostID=45246" width="1" height="1"&gt;</content><author><name>Jason Buss</name><uri>http://customerfx.com/members/Jason-Buss.aspx</uri></author><category term="Customizations" scheme="http://customerfx.com/pages/customization/archive/tags/Customizations/default.aspx" /><category term="How-To" scheme="http://customerfx.com/pages/customization/archive/tags/How-To/default.aspx" /><category term="SalesLogix Web" scheme="http://customerfx.com/pages/customization/archive/tags/SalesLogix+Web/default.aspx" /><category term="Roles" scheme="http://customerfx.com/pages/customization/archive/tags/Roles/default.aspx" /><category term="Tabs" scheme="http://customerfx.com/pages/customization/archive/tags/Tabs/default.aspx" /></entry><entry><title>Modifying the Insert Contact/Account view in the SalesLogix Web client</title><link rel="alternate" type="text/html" href="http://customerfx.com/pages/customization/2011/08/22/modifying-the-insert-account-contact-view-in-the-saleslogix-web-client.aspx" /><id>http://customerfx.com/pages/customization/2011/08/22/modifying-the-insert-account-contact-view-in-the-saleslogix-web-client.aspx</id><published>2011-08-22T14:08:00Z</published><updated>2011-08-22T14:08:00Z</updated><content type="html">&lt;p&gt;Most of the time, it is a simple process to add or subtract fields from views in SalesLogix, but on occasion, it is necessary to perform those changes by modifying custom smartparts rather than making changes directly to a view.&amp;nbsp; A good example of this in the Insert Contact/Account screen in the web client.&lt;/p&gt;&lt;p&gt;If you&amp;#39;re not familiar with ASP or C#, this can be a little intimidating, but hopefully this post will show the areas you need to modify when making changes to the custom smart part.&lt;/p&gt;&lt;p&gt;First of all, you need to find the custom smartpart.&amp;nbsp; The easiest way to do this is to look at the Project Explorer in Application Architect.&amp;nbsp; Expand the Portal manager, Sage SalesLogix, and Pages.&amp;nbsp; Scroll down to the Insert Contact/Account page and double-click on it.&amp;nbsp; This will open the page, and show all the smart parts used.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;a href="http://customerfx.com/blogs/customization/InsertAccountContactPage.JPG"&gt;&lt;img src="http://customerfx.com/blogs/customization/InsertAccountContactPage.JPG" border="0" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;We&amp;#39;re interested in the InsertContact custom smart part, so highlight that and click the Edit button.&amp;nbsp; &lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;a href="http://customerfx.com/blogs/customization/InsertAccountContactCode.JPG"&gt;&lt;img src="http://customerfx.com/blogs/customization/InsertAccountContactCode.JPG" border="0" alt="" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;As you can see, this is all code.&amp;nbsp; If you&amp;#39;ve worked with ASP before, this should be pretty easy to navigate.&amp;nbsp; If not, you&amp;#39;ll have to do some looking around to find what it is you want to change.&amp;nbsp; Say for example, you wanted to remove the standard &amp;quot;Business Description&amp;quot; field from this form.&amp;nbsp; You should find ASP code referring to the the control on the form.&amp;nbsp; You can then comment out or remove that code entirely.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;a href="http://customerfx.com/blogs/customization/InsertAccountContactBusinessDescription.JPG"&gt;&lt;img src="http://customerfx.com/blogs/customization/InsertAccountContactBusinessDescription.JPG" border="0" alt="" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Here you can see the code defining the Business Description field along with the code defining the Account Fax field.&amp;nbsp; The placement of these fields is accomplished by using the standard &amp;lt;td&amp;gt; (cell) and &amp;lt;tr&amp;gt; (row) tags that are used in HTML.&amp;nbsp; You&amp;#39;ll want to keep these tags in mind when removing fields, otherwise you might mess up your layout of the screen.&amp;nbsp; For removing business Description, you&amp;#39;d want to remove everything including the &amp;lt;td&amp;gt; tags, but leave the closing &amp;lt;/tr&amp;gt; tag in place.&lt;/p&gt;&lt;p&gt;After removing the control, you&amp;#39;ll want to run a search of the code to remove any reference to the &amp;quot;txtAccountBusinessDescription&amp;quot; control.&amp;nbsp; Otherwise errors could be thrown when trying to reference a control that no longer exists.&lt;/p&gt;&lt;p&gt;For adding a new control, there are a couple other code items you will need to have in place to control things like control behavior, data bindings, etc... &amp;nbsp; For this example, we&amp;#39;re going to replace the Business Description field we just removed with the Division field in the Account Table.&lt;/p&gt;&lt;p&gt;&amp;nbsp;The first step you&amp;#39;ll want to take is to add the binding code for the new field.&amp;nbsp; If you scroll down a ways, you&amp;#39;ll find the code change from ASP to C#. (Look for the line that reads &amp;quot;&lt;i&gt;&amp;lt;script runat=&amp;quot;server&amp;quot; type=&amp;quot;text/C#&amp;quot;&amp;gt;&lt;/i&gt;&amp;quot;&amp;nbsp; Everything below this line is the C# code.&lt;/p&gt;&lt;p&gt;Find the function named&amp;nbsp; &lt;i&gt;IsAccountBinding&lt;/i&gt;.&amp;nbsp; This function indicates that the field we are binding is an account level field.&amp;nbsp; Within the case statement in this function, we&amp;#39;ll want to add a reference to the Division field like this:&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case &amp;quot;Account.Division&amp;quot;:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return true;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;This can be added anywhere in the case statement BEFORE the case else at the end.&lt;/p&gt;&lt;p&gt;&amp;nbsp;The next function in the script is named &lt;i&gt;OnAddEntityBindings()&lt;/i&gt;.&amp;nbsp; This is where the actual binding takes place.&amp;nbsp; Within this code, you&amp;#39;ll need to add a line binding the Division field to a new text control we&amp;#39;ll call &amp;quot;txtDivision&amp;quot;.&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;i&gt;&lt;b&gt;&amp;nbsp;BindingSource.Bindings.Add(new WebEntityBinding(&amp;quot;Account.Division&amp;quot;, txtDivision, &amp;quot;Text&amp;quot;));&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&amp;nbsp;Next, add a reference to the new control in the function Named &amp;quot;&lt;i&gt;lueUseExistingAccount_ChangeAction&lt;/i&gt;&amp;quot;.&amp;nbsp; This function just disables the account controls on the form and uses the values from the selected account to set certain contact fields.&amp;nbsp; We&amp;#39;ll just need to add a line to disable our new control.&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;i&gt;&lt;b&gt;&amp;nbsp;ownAccountOwner.Enabled = false;&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&amp;nbsp;Next, on the LoadView() method, you&amp;#39;ll need to add a reference to the control in the area where the other account level controls are referenced.&amp;nbsp; It&amp;#39;s within the If statement looking to see if account != null.&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;i&gt;&lt;b&gt;&amp;nbsp;txtDivision.Enabled = changeEnable;&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&amp;nbsp;That is all the changes we need to make in terms of the C# code, however we haven&amp;#39;t yet placed the control itself of the form.&lt;/p&gt;&lt;p&gt;We can replace the code defining Business Description with the code for our new control (everything including the &amp;lt;td&amp;gt; tags: &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;i&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt; &amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;span class=&amp;quot;lbl&amp;quot;&amp;gt;&amp;lt;asp:Label ID=&amp;quot;txtDivision_lz&amp;quot; AssociatedControlID=&amp;quot;txtDivision&amp;quot; runat=&amp;quot;server&amp;quot; Text=&amp;quot;Division&amp;quot;&amp;gt;&amp;lt;/asp:Label&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;span class=&amp;quot;textcontrol&amp;quot;&amp;gt;&amp;lt;asp:TextBox runat=&amp;quot;server&amp;quot; ID=&amp;quot;txtDivision&amp;quot;&amp;nbsp; /&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;/td&amp;gt;&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;And that is all there is to it!&amp;nbsp; We now have a brand new Division field on the Insert Contact/Account view in the web client.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://customerfx.com/aggbug.aspx?PostID=45126" width="1" height="1"&gt;</content><author><name>Jason Buss</name><uri>http://customerfx.com/members/Jason-Buss.aspx</uri></author><category term="How-To" scheme="http://customerfx.com/pages/customization/archive/tags/How-To/default.aspx" /><category term="scripting" scheme="http://customerfx.com/pages/customization/archive/tags/scripting/default.aspx" /><category term="Smartparts" scheme="http://customerfx.com/pages/customization/archive/tags/Smartparts/default.aspx" /></entry><entry><title>Basics - Ticket Activity Support - SalesLogix LAN</title><link rel="alternate" type="text/html" href="http://customerfx.com/pages/customization/2011/06/03/basics-ticket-activity-support-saleslogix-lan.aspx" /><id>http://customerfx.com/pages/customization/2011/06/03/basics-ticket-activity-support-saleslogix-lan.aspx</id><published>2011-06-03T12:08:00Z</published><updated>2011-06-03T12:08:00Z</updated><content type="html">&lt;p&gt;In this post I&amp;#39;ll outline some of the functionality available to you in the Standard Ticket Activity support script for SalesLogix LAN.&amp;nbsp; As with the other built in SalesLogix scripts, access to this functionality allows you the ability to control the various processes regarding ticket activities.&lt;/p&gt;&lt;p&gt;Most of these functions and methods deal with populating the activity and history tables. &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;CompleteCurrentUserTicketActivities(TicketID)&lt;/b&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;This function completes all tickets for a given ticket for the current logged in user.&lt;br /&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;b&gt;CloseTicketActivity(strTicketActivityID, strTicketID, blnSilent)&lt;/b&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;The CloseTicketActivity function completes a named ticket activity (by ID).&amp;nbsp; The blnSilent boolean is used to complete the activity without displaying the Complete Ticket Activity dialog if the boolean is True.&lt;br /&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;b&gt;&amp;nbsp;GetElapsedTime(dteFromDate, dteToDate)&lt;/b&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;This function returns an Integer derived from a difference between two dates.&lt;br /&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;b&gt;GetElapsedHours(intElapsedTime)&lt;/b&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;Used in conjunction with the previous function, this one returns an integer of the elapsed time.&lt;br /&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;b&gt;&amp;nbsp;CreateTicketHistoryEntry(strActivityType, strTicketID)&lt;/b&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;This function populates the TicketHistory table.&amp;nbsp; The strActivityType variable is used to fill the Notes field in that table.&lt;br /&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;b&gt;CreateTicketActivity(objActivity, strAccessCode, strFollowUp, strShortDesc, blnSendSLX)&lt;/b&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;This Method generates a new Ticket Activity resulting from the completion of a Activity. This method is currently invoked from the Global Activity script, in which case the Activity type is not generated from an Email or from the Ticket Main View, in which case the Activity was generated from an Email drop.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;b&gt;SaveTimedTicketActivity(TicketActivityID, TicketID, strTime)&lt;/b&gt; &lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;This method&amp;nbsp; saves a record to the TicketActivity table.&amp;nbsp; Use the strTime variable to pass a date which is used in the date fields in the table and also in the description field.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;There are more functionality in this script, including Contract functionality and various other update scripts.&amp;nbsp; Reviewing this and other SalesLogix system scripts can provide a lot of information about how things are done in SalesLogix, and what sort of processes are available for you to use in your customizations.&amp;nbsp; I cover more functionality in future posts.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Thanks for reading!&amp;nbsp; &lt;br /&gt;&lt;/p&gt;&lt;img src="http://customerfx.com/aggbug.aspx?PostID=44922" width="1" height="1"&gt;</content><author><name>Jason Buss</name><uri>http://customerfx.com/members/Jason-Buss.aspx</uri></author><category term="SalesLogix LAN Client" scheme="http://customerfx.com/pages/customization/archive/tags/SalesLogix+LAN+Client/default.aspx" /><category term="Basics" scheme="http://customerfx.com/pages/customization/archive/tags/Basics/default.aspx" /><category term="scripting" scheme="http://customerfx.com/pages/customization/archive/tags/scripting/default.aspx" /></entry><entry><title>Adding Billing and Shipping addresses to SageCRM merge forms</title><link rel="alternate" type="text/html" href="http://customerfx.com/pages/customization/2011/05/10/adding-billing-and-shipping-addresses-to-sagecrm-merge-forms.aspx" /><link rel="enclosure" type="application/octet-stream" length="6505" href="http://customerfx.com/pages/customization/attachment/44832.ashx" /><id>http://customerfx.com/pages/customization/2011/05/10/adding-billing-and-shipping-addresses-to-sagecrm-merge-forms.aspx</id><published>2011-05-10T15:28:00Z</published><updated>2011-05-10T15:28:00Z</updated><content type="html">&lt;p&gt;I was recently doing some work on merge forms in SageCRM and discovered that for Cases, SageCRM didn&amp;#39;t take into account different address types in the OOTB Case merge fields.&amp;nbsp; Normally, Address information is derived by joining the case_PrimaryCompanyID to the Company table, and then joining from Comp_PrimaryAddressID to the address tables.&amp;nbsp; With these joins, you could only include the primary address for the Case&amp;#39;s account, however I wanted to display both Shipping and Billing addresses as well.&lt;/p&gt;&lt;p&gt;In this post, I&amp;#39;ll go through the view changes I made to include Billing and Shipping Addresses on this merge form. &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;Sage CRM has a table named&amp;nbsp; Address_Link which holds the address type as well as IDs for Company and Person records.&amp;nbsp; We&amp;#39;re going to create 2 new views, one for the billing address, and one for the shipping address.&amp;nbsp; These are defined simply as:&lt;br /&gt;&lt;/p&gt;

&lt;table style="table-layout:fixed;width:600px;" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre&gt; &lt;span style="color:Blue;"&gt;CREATE&lt;/span&gt; &lt;span style="color:Blue;"&gt;View&lt;/span&gt; [dbo].[vCompanyBillingAddress_Link] &lt;span style="color:Blue;"&gt;as&lt;/span&gt;
&lt;span style="color:Blue;"&gt;select&lt;/span&gt; * &lt;span style="color:Blue;"&gt;from&lt;/span&gt; dbo.Address_link
&lt;span style="color:Blue;"&gt;where&lt;/span&gt; AdLi_PersonID &lt;span style="color:Blue;"&gt;is&lt;/span&gt; &lt;span style="color:Blue;"&gt;null&lt;/span&gt; &lt;span style="color:Blue;"&gt;and&lt;/span&gt; AdLi_Type = &lt;span style="color:Navy;"&gt;&amp;#39;Billing&amp;#39;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
  
 and 
&lt;table style="table-layout:fixed;width:600px;" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre&gt;&lt;span style="color:Blue;"&gt;CREATE&lt;/span&gt; &lt;span style="color:Blue;"&gt;View&lt;/span&gt; [dbo].[vCompanyShippingAddress_Link] &lt;span style="color:Blue;"&gt;as&lt;/span&gt;
&lt;span style="color:Blue;"&gt;select&lt;/span&gt; * &lt;span style="color:Blue;"&gt;from&lt;/span&gt; dbo.Address_link
&lt;span style="color:Blue;"&gt;where&lt;/span&gt; AdLi_PersonID &lt;span style="color:Blue;"&gt;is&lt;/span&gt; &lt;span style="color:Blue;"&gt;null&lt;/span&gt; &lt;span style="color:Blue;"&gt;and&lt;/span&gt; AdLi_Type = &lt;span style="color:Navy;"&gt;&amp;#39;Shipping&amp;#39;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;By grabbing records where the PersonID is null, we should only be getting Company address records.&amp;nbsp; Once these views are created, then we&amp;#39;ll need to modify the Case merge view (named vMailMergeCase) to include the new views and fields.&amp;nbsp; This needs to be defined in the case view definitions, but I find it easier to figure out what I am doing in SQL Management Studio and then copy the code over to SageCRM.&amp;nbsp; We will make two changes to the VMailMergeCase view.&amp;nbsp; first of all, we need to join to the new views we created:&lt;br /&gt;&lt;br /&gt;
&lt;/p&gt;&lt;table style="table-layout:fixed;width:600px;" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre&gt; &lt;span style="color:Blue;"&gt;LEFT&lt;/span&gt; &lt;span style="color:Blue;"&gt;OUTER&lt;/span&gt; &lt;span style="color:Blue;"&gt;JOIN&lt;/span&gt;
dbo.vCompanyBillingAddress_Link &lt;span style="color:Blue;"&gt;ON&lt;/span&gt; dbo.Company.Comp_CompanyID = dbo.vCompanyBillingAddress_Link.AdLi_CompanyID &lt;span style="color:Blue;"&gt;LEFT&lt;/span&gt; &lt;span style="color:Blue;"&gt;OUTER&lt;/span&gt; &lt;span style="color:Blue;"&gt;JOIN&lt;/span&gt;
dbo.Address Adr2 &lt;span style="color:Blue;"&gt;on&lt;/span&gt; dbo.vCompanyBillingAddress_Link.AdLi_AddressID = Adr2.Addr_AddressID &lt;span style="color:Blue;"&gt;LEFT&lt;/span&gt; &lt;span style="color:Blue;"&gt;OUTER&lt;/span&gt; &lt;span style="color:Blue;"&gt;JOIN&lt;/span&gt;
dbo.vCompanyShippingAddress_Link &lt;span style="color:Blue;"&gt;ON&lt;/span&gt; dbo.Company.Comp_CompanyID = dbo.vCompanyShippingAddress_Link.AdLi_CompanyID &lt;span style="color:Blue;"&gt;LEFT&lt;/span&gt; &lt;span style="color:Blue;"&gt;OUTER&lt;/span&gt; &lt;span style="color:Blue;"&gt;JOIN&lt;/span&gt;
dbo.Address Adr3 &lt;span style="color:Blue;"&gt;on&lt;/span&gt; dbo.vCompanyShippingAddress_Link.AdLi_AddressID = Adr3.Addr_AddressID&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
  &lt;br /&gt;Once the joins are included, we want to add the new address fields.&amp;nbsp; I used a CASE statement so that if there was not a billing or shipping address defined, it would just present the companies primary address as it was before.&lt;br /&gt;&lt;table style="table-layout:fixed;width:600px;" cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt;BillingAddress1 = &lt;span style="color:Blue;"&gt;CASE&lt;/span&gt; &lt;span style="color:Blue;"&gt;WHEN&lt;/span&gt; Adr2.Addr_AddressID &lt;span style="color:Blue;"&gt;is&lt;/span&gt; &lt;span style="color:Blue;"&gt;null&lt;/span&gt; &lt;span style="color:Blue;"&gt;Then&lt;/span&gt; dbo.Address.Addr_Address1 &lt;span style="color:Blue;"&gt;else&lt;/span&gt; Adr2.Addr_Address1 &lt;span style="color:Blue;"&gt;END&lt;/span&gt;,
BillingAddress2 = &lt;span style="color:Blue;"&gt;CASE&lt;/span&gt; &lt;span style="color:Blue;"&gt;WHEN&lt;/span&gt; Adr2.Addr_AddressID &lt;span style="color:Blue;"&gt;is&lt;/span&gt; &lt;span style="color:Blue;"&gt;null&lt;/span&gt; &lt;span style="color:Blue;"&gt;Then&lt;/span&gt; dbo.Address.Addr_Address2 &lt;span style="color:Blue;"&gt;else&lt;/span&gt; Adr2.Addr_Address2 &lt;span style="color:Blue;"&gt;END&lt;/span&gt;,
BillingAddress3 = &lt;span style="color:Blue;"&gt;CASE&lt;/span&gt; &lt;span style="color:Blue;"&gt;WHEN&lt;/span&gt; Adr2.Addr_AddressID &lt;span style="color:Blue;"&gt;is&lt;/span&gt; &lt;span style="color:Blue;"&gt;null&lt;/span&gt; &lt;span style="color:Blue;"&gt;Then&lt;/span&gt; dbo.Address.Addr_Address3 &lt;span style="color:Blue;"&gt;else&lt;/span&gt; Adr2.Addr_Address3 &lt;span style="color:Blue;"&gt;END&lt;/span&gt;,
BillingAddress4 = &lt;span style="color:Blue;"&gt;CASE&lt;/span&gt; &lt;span style="color:Blue;"&gt;WHEN&lt;/span&gt; Adr2.Addr_AddressID &lt;span style="color:Blue;"&gt;is&lt;/span&gt; &lt;span style="color:Blue;"&gt;null&lt;/span&gt; &lt;span style="color:Blue;"&gt;Then&lt;/span&gt; dbo.Address.Addr_Address4 &lt;span style="color:Blue;"&gt;else&lt;/span&gt; Adr2.Addr_Address4 &lt;span style="color:Blue;"&gt;END&lt;/span&gt;,
BillingAddress5 = &lt;span style="color:Blue;"&gt;CASE&lt;/span&gt; &lt;span style="color:Blue;"&gt;WHEN&lt;/span&gt; Adr2.Addr_AddressID &lt;span style="color:Blue;"&gt;is&lt;/span&gt; &lt;span style="color:Blue;"&gt;null&lt;/span&gt; &lt;span style="color:Blue;"&gt;Then&lt;/span&gt; dbo.Address.Addr_Address5 &lt;span style="color:Blue;"&gt;else&lt;/span&gt; Adr2.Addr_Address5 &lt;span style="color:Blue;"&gt;END&lt;/span&gt;,
BillingCity = &lt;span style="color:Blue;"&gt;CASE&lt;/span&gt; &lt;span style="color:Blue;"&gt;WHEN&lt;/span&gt; Adr2.Addr_AddressID &lt;span style="color:Blue;"&gt;is&lt;/span&gt; &lt;span style="color:Blue;"&gt;null&lt;/span&gt; &lt;span style="color:Blue;"&gt;Then&lt;/span&gt; dbo.Address.Addr_City &lt;span style="color:Blue;"&gt;else&lt;/span&gt; Adr2.Addr_City &lt;span style="color:Blue;"&gt;END&lt;/span&gt;,
BillingState = &lt;span style="color:Blue;"&gt;CASE&lt;/span&gt; &lt;span style="color:Blue;"&gt;WHEN&lt;/span&gt; Adr2.Addr_AddressID &lt;span style="color:Blue;"&gt;is&lt;/span&gt; &lt;span style="color:Blue;"&gt;null&lt;/span&gt; &lt;span style="color:Blue;"&gt;Then&lt;/span&gt; dbo.Address.Addr_State &lt;span style="color:Blue;"&gt;else&lt;/span&gt; Adr2.Addr_State &lt;span style="color:Blue;"&gt;END&lt;/span&gt;,
BillingCountry = &lt;span style="color:Blue;"&gt;CASE&lt;/span&gt; &lt;span style="color:Blue;"&gt;WHEN&lt;/span&gt; Adr2.Addr_AddressID &lt;span style="color:Blue;"&gt;is&lt;/span&gt; &lt;span style="color:Blue;"&gt;null&lt;/span&gt; &lt;span style="color:Blue;"&gt;Then&lt;/span&gt; dbo.Address.Addr_Country &lt;span style="color:Blue;"&gt;else&lt;/span&gt; Adr2.Addr_Country &lt;span style="color:Blue;"&gt;END&lt;/span&gt;,
BillingPostCode = &lt;span style="color:Blue;"&gt;CASE&lt;/span&gt; &lt;span style="color:Blue;"&gt;WHEN&lt;/span&gt; Adr2.Addr_AddressID &lt;span style="color:Blue;"&gt;is&lt;/span&gt; &lt;span style="color:Blue;"&gt;null&lt;/span&gt; &lt;span style="color:Blue;"&gt;Then&lt;/span&gt; dbo.Address.Addr_PostCode &lt;span style="color:Blue;"&gt;else&lt;/span&gt; Adr2.Addr_PostCode &lt;span style="color:Blue;"&gt;END&lt;/span&gt;,&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;  &lt;br /&gt;after the billing information fields, I do the same with the Shipping address fields from the Adr3 alias. Once these view changes are done in SageCRM, you should have the billing and shipping address available in the case merge fields.&lt;/p&gt;&lt;p&gt;I&amp;#39;ve attached the entire modified MergeView so you can see how I incorporated everything together.&amp;nbsp; Again, any changes to the Merge view must be defined within SageCRM, under&amp;nbsp; Administration-&amp;gt;Customization-&amp;gt;Cases-&amp;gt;Views tab.&amp;nbsp; &lt;/p&gt;&lt;p&gt;Thanks for reading!&amp;nbsp;&lt;img src="http://customerfx.com/emoticons/emotion-15.gif" alt="Geeked" /&gt; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;img src="http://customerfx.com/aggbug.aspx?PostID=44832" width="1" height="1"&gt;</content><author><name>Jason Buss</name><uri>http://customerfx.com/members/Jason-Buss.aspx</uri></author><category term="How-To" scheme="http://customerfx.com/pages/customization/archive/tags/How-To/default.aspx" /><category term="Sage CRM" scheme="http://customerfx.com/pages/customization/archive/tags/Sage+CRM/default.aspx" /><category term="Merge Forms" scheme="http://customerfx.com/pages/customization/archive/tags/Merge+Forms/default.aspx" /></entry><entry><title>Simple Insert Trigger Example</title><link rel="alternate" type="text/html" href="http://customerfx.com/pages/customization/2011/03/01/simple-insert-trigger-example.aspx" /><id>http://customerfx.com/pages/customization/2011/03/01/simple-insert-trigger-example.aspx</id><published>2011-03-01T19:01:00Z</published><updated>2011-03-01T19:01:00Z</updated><content type="html">&lt;p&gt;I previously posted about using an &lt;a href="http://customerfx.com/pages/customization/2010/02/05/using-sql-triggers-to-enforce-data-rules-in-saleslogix.aspx" title="UpdateTriggers" target="_blank"&gt;update trigger&lt;/a&gt; to enforce data rules in SalesLogix.&amp;nbsp; Since I was working on another trigger now, I also wanted to post a simple example of an Insert Trigger.&lt;/p&gt;

&lt;p&gt;Basically, I have a table called TriggerTest containing a State and also three of Manager fields.&amp;nbsp; When inserting a record for a particular state, I needed to also populate the Manager fields with the current managers defined for each state.&amp;nbsp;&amp;nbsp; I&amp;#39;m using a table called CRMManagers to store a list of each state and the three manager values for that state: (State, Manager1, Manager2, Manager3)&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s how I created the trigger: &lt;br /&gt;&lt;/p&gt;
&lt;table style="table-layout:fixed;width:600px;" cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt; &lt;span style="color:Green;"&gt;--First, I create the trigger, naming it trUpdateManagers against the &lt;br /&gt;--TriggerTest Table.&lt;br /&gt;&lt;/span&gt;&lt;span style="color:Blue;"&gt;Create&lt;/span&gt; &lt;span style="color:Blue;"&gt;Trigger&lt;/span&gt; dbo.trUpdateManagers &lt;span style="color:Blue;"&gt;on&lt;/span&gt; dbo.TriggerTest&lt;br /&gt;&lt;span style="color:Green;"&gt;--The trigger is created for Insert, which will fire whenever a row is &lt;br /&gt;--inserted to the TriggerTest table.&lt;br /&gt;&lt;/span&gt;&lt;span style="color:Blue;"&gt;for&lt;/span&gt; &lt;span style="color:Blue;"&gt;Insert&lt;/span&gt; &lt;br /&gt;&lt;span style="color:Blue;"&gt;as&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;&lt;span style="color:Green;"&gt;--Now I Declare an ID and State variable and populate them with the new&lt;br /&gt;--values inserted into the TriggerTest table.&lt;br /&gt;&lt;/span&gt;&lt;span style="color:Blue;"&gt;Declare&lt;/span&gt; @ID &lt;span style="color:Blue;"&gt;nchar&lt;/span&gt;(10)&lt;br /&gt;&lt;span style="color:Blue;"&gt;Declare&lt;/span&gt; @STATE &lt;span style="color:Blue;"&gt;nvarchar&lt;/span&gt;(50)&lt;br /&gt;&lt;span style="color:Green;"&gt;--When setting the ID and State variables, I&amp;#39;m referencing &amp;quot;Inserted&amp;quot; &lt;br /&gt;--which is an internal SQL table which basically contains a copy of &lt;br /&gt;--the currently inserted row.&lt;br /&gt;&lt;/span&gt;&lt;span style="color:Blue;"&gt;select&lt;/span&gt; @ID = [ID], @STATE = STATE &lt;span style="color:Blue;"&gt;from&lt;/span&gt; inserted&lt;br /&gt;&lt;br /&gt;&lt;span style="color:Green;"&gt;--Next I Declare variables for each of the Manager Values&lt;br /&gt;&lt;/span&gt;&lt;span style="color:Blue;"&gt;Declare&lt;/span&gt; @MGR1 &lt;span style="color:Blue;"&gt;nvarchar&lt;/span&gt;(50)&lt;br /&gt;&lt;span style="color:Blue;"&gt;Declare&lt;/span&gt; @MGR2 &lt;span style="color:Blue;"&gt;nvarchar&lt;/span&gt;(50)&lt;br /&gt;&lt;span style="color:Blue;"&gt;Declare&lt;/span&gt; @MGR3 &lt;span style="color:Blue;"&gt;nvarchar&lt;/span&gt;(50)&lt;br /&gt;&lt;br /&gt;&lt;span style="color:Green;"&gt;--And now set the Manager variables with the appropreate values &lt;br /&gt;--based on the State inserted to TriggerTest&lt;br /&gt;&lt;/span&gt;&lt;span style="color:Blue;"&gt;Select&lt;/span&gt; &lt;br /&gt;    @MGR1 = [Manager1]&lt;br /&gt;,    @MGR2 = [Manager2]&lt;br /&gt;,    @MGR3 = [Manager3]&lt;br /&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;from&lt;/span&gt; dbo.CRMManagers &lt;span style="color:Blue;"&gt;where&lt;/span&gt; STATE = @STATE&lt;br /&gt;&lt;br /&gt;&lt;span style="color:Green;"&gt;--Finally, I run an update statement to udpate the newly inserted&lt;br /&gt;--TriggerTest record with the Manager values.&lt;br /&gt;&lt;/span&gt;&lt;span style="color:Blue;"&gt;update&lt;/span&gt; dbo.TriggerTest &lt;span style="color:Blue;"&gt;set&lt;/span&gt; Manager1 = @MGR1, &lt;br /&gt;Manager2 = @MGR2, Manager3 = @MGR3 &lt;span style="color:Blue;"&gt;where&lt;/span&gt; ID = @ID&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;  
  
&lt;p&gt;&amp;nbsp;That&amp;#39;s about it.&amp;nbsp; Pretty simple!&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;br /&gt;&lt;/p&gt;
&lt;img src="http://customerfx.com/aggbug.aspx?PostID=44598" width="1" height="1"&gt;</content><author><name>Jason Buss</name><uri>http://customerfx.com/members/Jason-Buss.aspx</uri></author><category term="How-To" scheme="http://customerfx.com/pages/customization/archive/tags/How-To/default.aspx" /><category term="SQL" scheme="http://customerfx.com/pages/customization/archive/tags/SQL/default.aspx" /><category term="SQL Functions" scheme="http://customerfx.com/pages/customization/archive/tags/SQL+Functions/default.aspx" /><category term="Trigger" scheme="http://customerfx.com/pages/customization/archive/tags/Trigger/default.aspx" /></entry><entry><title>Running Sql Server Integration services package from a C Sharp application</title><link rel="alternate" type="text/html" href="http://customerfx.com/pages/customization/2011/01/19/running-sql-server-integration-services-package-from-a-c-application.aspx" /><link rel="enclosure" type="application/x-zip-compressed" length="49184" href="http://customerfx.com/pages/customization/attachment/44480.ashx" /><id>http://customerfx.com/pages/customization/2011/01/19/running-sql-server-integration-services-package-from-a-c-application.aspx</id><published>2011-01-19T16:04:00Z</published><updated>2011-01-19T16:04:00Z</updated><content type="html">&lt;p&gt;If you&amp;#39;ve ever created a SSIS package and wanted to provide a way for end users to run that package without having to run the Business Intelligence Development studio, you can compile the package into a dtsx file for them to run.&amp;nbsp; This would require them to manually alter connections and variables, which can get complicated for an average end user. Alternatively, it is pretty simple to put together an application which can be used to run the package.&amp;nbsp; This would allow you to handle modifications to package variables in a much more user-friendly manner.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;I have a relatively simple SSIS package which queries data from a view based on a date range, and exports the returned data to a CSV file. &lt;/p&gt;&lt;p&gt;First of all, you will need to add a reference to the Microsoft.SQLServer.ManagedDTS.dll as well as a reference to the Microsoft.SqlServer.DTS.Runtime namespace.&amp;nbsp; Once that is done, you can reference the namespace to create objects referencing the package, and any other items you need to reference such as connections and variables.&lt;br /&gt;&lt;/p&gt;This is a simple method I created in Visual Studio 2010 which calls the provided compiled DTS package and updates the connections and variables. (see the attached ZIP file to see the full application)&lt;br /&gt;&lt;table style="table-layout:fixed;width:600px;" cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt; &lt;br /&gt;&lt;span style="color:Blue;"&gt;using&lt;/span&gt; Microsoft.SqlServer.Dts.Runtime;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;namespace&lt;/span&gt; CFX_ExportPortalEmailLeads&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color:Blue;"&gt;public&lt;/span&gt; partial &lt;span style="color:Blue;"&gt;class&lt;/span&gt; frmExportData : Form&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        &lt;span style="color:Blue;"&gt;private&lt;/span&gt; &lt;span style="color:Blue;"&gt;void&lt;/span&gt; cmdRun_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            Execute_Package(String.Format(&lt;span&gt;&amp;quot;{0:yyyy-MM-dd}&amp;quot;&lt;/span&gt;, dtpStartDate.Value), String.Format(&lt;span&gt;&amp;quot;{0:yyyy-MM-dd}&amp;quot;&lt;/span&gt;, dtpEndDate.Value));&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span style="color:Blue;"&gt;private&lt;/span&gt; &lt;span style="color:Blue;"&gt;void&lt;/span&gt; Execute_Package(&lt;span style="color:Blue;"&gt;string&lt;/span&gt; StartDate, &lt;span style="color:Blue;"&gt;string&lt;/span&gt; EndDate)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color:Blue;"&gt;string&lt;/span&gt; pkgLocation &lt;span style="color:Navy;"&gt;=&lt;/span&gt; txtUsePackage.Text;&lt;br /&gt;&lt;br /&gt;            Package pkg;&lt;br /&gt;            Microsoft.SqlServer.Dts.Runtime.Application app;&lt;br /&gt;            DTSExecResult pkgResults;&lt;br /&gt;            Variables vars;&lt;br /&gt;            Connections conns;&lt;br /&gt;            &lt;br /&gt;            app &lt;span style="color:Navy;"&gt;=&lt;/span&gt; &lt;span style="color:Blue;"&gt;new&lt;/span&gt; Microsoft.SqlServer.Dts.Runtime.Application();&lt;br /&gt;            pkg &lt;span style="color:Navy;"&gt;=&lt;/span&gt; app.LoadPackage(pkgLocation, &lt;span style="color:Blue;"&gt;null&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;            &lt;span style="color:Green;"&gt;//Set Connection Settings&lt;br /&gt;&lt;/span&gt;            conns &lt;span style="color:Navy;"&gt;=&lt;/span&gt; pkg.Connections;&lt;br /&gt;            conns[&lt;span&gt;&amp;quot;DestinationConnectionFlatFile&amp;quot;&lt;/span&gt;].ConnectionString &lt;span style="color:Navy;"&gt;=&lt;/span&gt; txtOutputFolder.Text &lt;span style="color:Navy;"&gt;+&lt;/span&gt; &lt;span&gt;&amp;quot;\\ExportFile.csv&amp;quot;&lt;/span&gt;;&lt;br /&gt;            conns[&lt;span&gt;&amp;quot;SourceConnectionOLEDB&amp;quot;&lt;/span&gt;].ConnectionString &lt;span style="color:Navy;"&gt;=&lt;/span&gt; &lt;span&gt;&amp;quot;Data Source=DataServer;User ID=sa;Password=1234567;Initial Catalog=DTSDatabase;Provider=SQLOLEDB;Auto Translate=false;&amp;quot;&lt;/span&gt;;&lt;br /&gt;            &lt;br /&gt;            &lt;span style="color:Green;"&gt;//Set SSIS Variables&lt;br /&gt;&lt;/span&gt;            &lt;span style="color:Green;"&gt;//**Note** - Variables MUST be package level variables in the SSIS package, otherwise an error will result when trying to set the variable  &lt;br /&gt;&lt;/span&gt;            vars &lt;span style="color:Navy;"&gt;=&lt;/span&gt; pkg.Variables;&lt;br /&gt;            vars[&lt;span&gt;&amp;quot;StartDate&amp;quot;&lt;/span&gt;].Value &lt;span style="color:Navy;"&gt;=&lt;/span&gt; StartDate;&lt;br /&gt;            vars[&lt;span&gt;&amp;quot;EndDate&amp;quot;&lt;/span&gt;].Value &lt;span style="color:Navy;"&gt;=&lt;/span&gt; EndDate;&lt;br /&gt;            &lt;br /&gt;            pkgResults &lt;span style="color:Navy;"&gt;=&lt;/span&gt; pkg.Execute(&lt;span style="color:Blue;"&gt;null&lt;/span&gt;, vars, &lt;span style="color:Blue;"&gt;null&lt;/span&gt;, &lt;span style="color:Blue;"&gt;null&lt;/span&gt;, &lt;span style="color:Blue;"&gt;null&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;            &lt;span style="color:Blue;"&gt;if&lt;/span&gt; (pkgResults == DTSExecResult.Success)&lt;br /&gt;                MessageBox.Show(&lt;span&gt;&amp;quot;Package Ran Successfully&amp;quot;&lt;/span&gt;);&lt;br /&gt;            &lt;span style="color:Blue;"&gt;else&lt;/span&gt;&lt;br /&gt;                MessageBox.Show(&lt;span&gt;&amp;quot;Package Failed&amp;quot;&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;             &lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;  
&lt;p&gt;As you can see, this method is pretty simple, but provides a much simpler user interface than the compiled SSIS package.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Thanks for reading!&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;img src="http://customerfx.com/aggbug.aspx?PostID=44480" width="1" height="1"&gt;</content><author><name>Jason Buss</name><uri>http://customerfx.com/members/Jason-Buss.aspx</uri></author><category term="SQL" scheme="http://customerfx.com/pages/customization/archive/tags/SQL/default.aspx" /><category term="C#" scheme="http://customerfx.com/pages/customization/archive/tags/C_2300_/default.aspx" /><category term="SSIS" scheme="http://customerfx.com/pages/customization/archive/tags/SSIS/default.aspx" /></entry><entry><title>Advanced Pivoting in MSSQL</title><link rel="alternate" type="text/html" href="http://customerfx.com/pages/customization/2011/01/06/advanced-pivoting-in-mssql.aspx" /><link rel="enclosure" type="application/octet-stream" length="5917" href="http://customerfx.com/pages/customization/attachment/44439.ashx" /><id>http://customerfx.com/pages/customization/2011/01/06/advanced-pivoting-in-mssql.aspx</id><published>2011-01-06T15:13:00Z</published><updated>2011-01-06T15:13:00Z</updated><content type="html">&lt;p&gt;Using pivot queries in SQL is a great tool for rotating data, but what if you need to do something more complicated with multiple data sources and multiple columns?&amp;nbsp; Recently, I had a request to pivot some data from multiple similar tables and to rotate that data into a columnar format.&lt;/p&gt;

&lt;p&gt;I hadn&amp;#39;t played much with pivot queries in MSSQL, so initially I thought I could accomplish it simply using that type of query.&amp;nbsp; However, with the number of columns to include in the pivot, and the potential for an unknown number of columns, I found that I had to create a couple of stored procedures to process the data.&amp;nbsp; Here&amp;#39;s a simplified version of what I did:&lt;/p&gt;

&lt;p&gt;I started out with three different tables&amp;nbsp; Test1, Test2 and Test3.&amp;nbsp; Each table contains the same number of fields:&lt;/p&gt;

&lt;p&gt;PrimaryKey&lt;br /&gt;ForeignKey&lt;br /&gt;Description&lt;br /&gt;Amount&lt;br /&gt;&lt;br /&gt;The goal was to rotate and combine the values so that we would end up with a dataset containing a column for each Description and Amount row in each table.&amp;nbsp; This becomes complicated because you have no way of knowing just how many columns you would eventually end up with.&lt;/p&gt;

&lt;p&gt;As a first step, I created a view to join the data from all three tables:&lt;/p&gt;

&lt;table style="table-layout:fixed;width:600px;" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre&gt; &lt;span style="color:Blue;"&gt;CREATE&lt;/span&gt; &lt;span style="color:Blue;"&gt;VIEW&lt;/span&gt; [dbo].[vUnionTestTables]&lt;br /&gt;&lt;span style="color:Blue;"&gt;AS&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;SELECT&lt;/span&gt;     PrimaryKey, ForeignKey, &lt;span style="color:Navy;"&gt;&amp;#39;Test1&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;AS&lt;/span&gt; FromTable, description, amount&lt;br /&gt;&lt;span style="color:Blue;"&gt;FROM&lt;/span&gt;         dbo.Test1&lt;br /&gt;&lt;span style="color:Blue;"&gt;UNION&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;SELECT&lt;/span&gt;     PrimaryKey, ForeignKey, &lt;span style="color:Navy;"&gt;&amp;#39;Test2&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;AS&lt;/span&gt; FromTable, description, amount&lt;br /&gt;&lt;span style="color:Blue;"&gt;FROM&lt;/span&gt;         dbo.Test2&lt;br /&gt;&lt;span style="color:Blue;"&gt;UNION&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;SELECT&lt;/span&gt;     PrimaryKey, ForeignKey, &lt;span style="color:Navy;"&gt;&amp;#39;Test3&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;AS&lt;/span&gt; FromTable, description, amount&lt;br /&gt;&lt;span style="color:Blue;"&gt;FROM&lt;/span&gt;         dbo.Test3&lt;br /&gt;&lt;span style="color:Blue;"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
  


&lt;p&gt;After the view is created, I created a stored Procedure that does that uses temporary tables to process the current data and stuff the data into additional tables created by the procedure:&lt;br /&gt;&lt;/p&gt;
 
&lt;table style="table-layout:fixed;width:600px;" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre&gt; &lt;span style="color:Blue;"&gt;CREATE&lt;/span&gt; &lt;span style="color:Blue;"&gt;procedure&lt;/span&gt; [dbo].[sp_TablesSnapshot] @DataPart &lt;span style="color:Blue;"&gt;varchar&lt;/span&gt;(30) &lt;span style="color:Blue;"&gt;as&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;DECLARE&lt;/span&gt; @FromShort &lt;span style="color:Blue;"&gt;char&lt;/span&gt;(3)&lt;br /&gt;&lt;span style="color:Blue;"&gt;If&lt;/span&gt; @DataPart = &lt;span style="color:Navy;"&gt;&amp;#39;Test1&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;set&lt;/span&gt; @FromShort = &lt;span style="color:Navy;"&gt;&amp;#39;T1&amp;#39;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;else&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;If&lt;/span&gt; @DataPart = &lt;span style="color:Navy;"&gt;&amp;#39;Test2&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;set&lt;/span&gt; @FromShort = &lt;span style="color:Navy;"&gt;&amp;#39;T2&amp;#39;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;else&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;If&lt;/span&gt; @DataPart = &lt;span style="color:Navy;"&gt;&amp;#39;Test3&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;set&lt;/span&gt; @FromShort = &lt;span style="color:Navy;"&gt;&amp;#39;T3&amp;#39;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;declare&lt;/span&gt; @PivotTableX &lt;span style="color:Blue;"&gt;TABLE&lt;/span&gt;&lt;br /&gt;(&lt;br /&gt;    ID &lt;span style="color:Blue;"&gt;Int&lt;/span&gt;,&lt;br /&gt;    RECORDID &lt;span style="color:Blue;"&gt;VARCHAR&lt;/span&gt;(30),&lt;br /&gt;    FROMTABLE &lt;span style="color:Blue;"&gt;VARCHAR&lt;/span&gt;(50),&lt;br /&gt;    DESCRIPTION &lt;span style="color:Blue;"&gt;NCHAR&lt;/span&gt;(100),&lt;br /&gt;    AMOUNT &lt;span style="color:Blue;"&gt;NVARCHAR&lt;/span&gt;(4000),&lt;br /&gt;    Processed &lt;span style="color:Blue;"&gt;NCHAR&lt;/span&gt;(1)&lt;br /&gt;)&lt;br /&gt;&lt;span style="color:Blue;"&gt;declare&lt;/span&gt; @&lt;span style="color:Blue;"&gt;RowCount&lt;/span&gt; &lt;span style="color:Blue;"&gt;Int&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;Set&lt;/span&gt; @&lt;span style="color:Blue;"&gt;RowCount&lt;/span&gt; = (&lt;span style="color:Blue;"&gt;Select&lt;/span&gt; &lt;span style="color:Blue;"&gt;Count&lt;/span&gt;(ForeignKey) &lt;span style="color:Blue;"&gt;from&lt;/span&gt; dbo.vUnionTestTables)&lt;br /&gt;&lt;span style="color:Blue;"&gt;Declare&lt;/span&gt; @I &lt;span style="color:Blue;"&gt;INT&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;Set&lt;/span&gt; @I = 1&lt;br /&gt;&lt;span style="color:Blue;"&gt;WHILE&lt;/span&gt; (@I &amp;lt;= @&lt;span style="color:Blue;"&gt;RowCount&lt;/span&gt;)&lt;br /&gt;&lt;span style="color:Blue;"&gt;BEGIN&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:Blue;"&gt;DECLARE&lt;/span&gt; @PrimaryKey &lt;span style="color:Blue;"&gt;INT&lt;/span&gt;, @ForeignKey &lt;span style="color:Blue;"&gt;INT&lt;/span&gt;, @FromTable &lt;span style="color:Blue;"&gt;VARCHAR&lt;/span&gt;(3), @Description &lt;span style="color:Blue;"&gt;VARCHAR&lt;/span&gt;(100), @Amount &lt;span style="color:Blue;"&gt;NVARCHAR&lt;/span&gt;(4000)&lt;br /&gt;    &lt;span style="color:Blue;"&gt;SELECT&lt;/span&gt;    @PrimaryKey = PrimaryKey&lt;br /&gt;            , @ForeignKey = ForeignKey&lt;br /&gt;            , @FromTable =&lt;br /&gt;                &lt;span style="color:Blue;"&gt;Case&lt;/span&gt; FromTable&lt;br /&gt;                &lt;span style="color:Blue;"&gt;WHEN&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;Test1&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;Then&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;T1&amp;#39;&lt;/span&gt;&lt;br /&gt;                &lt;span style="color:Blue;"&gt;WHEN&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;Test2&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;Then&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;T2&amp;#39;&lt;/span&gt;&lt;br /&gt;                &lt;span style="color:Blue;"&gt;WHEN&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;Test3&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;Then&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;T3&amp;#39;&lt;/span&gt;&lt;br /&gt;                &lt;span style="color:Blue;"&gt;END&lt;/span&gt;&lt;br /&gt;            , @Description = description&lt;br /&gt;            , @Amount = Amount&lt;br /&gt;            &lt;br /&gt;    &lt;span style="color:Blue;"&gt;FROM&lt;/span&gt; (&lt;span style="color:Blue;"&gt;SELECT&lt;/span&gt; *, ROW_NUMBER() &lt;span style="color:Blue;"&gt;OVER&lt;/span&gt;(&lt;span style="color:Blue;"&gt;ORDER&lt;/span&gt; &lt;span style="color:Blue;"&gt;BY&lt;/span&gt; ForeignKey) &lt;span style="color:Blue;"&gt;AS&lt;/span&gt; [RowNo] &lt;span style="color:Blue;"&gt;FROM&lt;/span&gt; dbo.vUnionTestTables) t1&lt;br /&gt;    &lt;span style="color:Blue;"&gt;WHERE&lt;/span&gt; t1.RowNo = @I&lt;br /&gt;    &lt;span style="color:Blue;"&gt;And&lt;/span&gt;&lt;br /&gt;    FromTable = @DataPart&lt;br /&gt;    &lt;span style="color:Blue;"&gt;Insert&lt;/span&gt; &lt;span style="color:Blue;"&gt;into&lt;/span&gt; @PivotTableX (ID, RECORDID, FROMTABLE, DESCRIPTION, AMOUNT, Processed)&lt;br /&gt;    &lt;span style="color:Blue;"&gt;values&lt;/span&gt; (@PrimaryKey, @ForeignKey, @FromTable, @Description, @Amount, &lt;span style="color:Navy;"&gt;&amp;#39;F&amp;#39;&lt;/span&gt;)&lt;br /&gt;    &lt;span style="color:Blue;"&gt;Set&lt;/span&gt; @I = @I + 1&lt;br /&gt;&lt;span style="color:Blue;"&gt;END&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;declare&lt;/span&gt; @PivotTable &lt;span style="color:Blue;"&gt;TABLE&lt;/span&gt;&lt;br /&gt;(&lt;br /&gt;    ID &lt;span style="color:Blue;"&gt;Int&lt;/span&gt;,&lt;br /&gt;    RECORDID &lt;span style="color:Blue;"&gt;VARCHAR&lt;/span&gt;(30),&lt;br /&gt;    FROMTABLE &lt;span style="color:Blue;"&gt;VARCHAR&lt;/span&gt;(50),&lt;br /&gt;    DESCRIPTION &lt;span style="color:Blue;"&gt;NCHAR&lt;/span&gt;(100),&lt;br /&gt;    AMOUNT &lt;span style="color:Blue;"&gt;NVARCHAR&lt;/span&gt;(4000),&lt;br /&gt;    Processed &lt;span style="color:Blue;"&gt;NCHAR&lt;/span&gt;(1)&lt;br /&gt;)&lt;br /&gt;&lt;span style="color:Blue;"&gt;insert&lt;/span&gt; &lt;span style="color:Blue;"&gt;into&lt;/span&gt; @PivotTable (ID,RECORDID,FROMTABLE,DESCRIPTION,AMOUNT,PROCESSED) &lt;span style="color:Blue;"&gt;select&lt;/span&gt; &lt;span style="color:Blue;"&gt;distinct&lt;/span&gt; * &lt;span style="color:Blue;"&gt;from&lt;/span&gt; @PivotTableX &lt;span style="color:Blue;"&gt;where&lt;/span&gt; ID &lt;span style="color:Blue;"&gt;is&lt;/span&gt; &lt;span style="color:Blue;"&gt;not&lt;/span&gt; &lt;span style="color:Blue;"&gt;null&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;Declare&lt;/span&gt; @MaxCount &lt;span style="color:Blue;"&gt;int&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;declare&lt;/span&gt; @CountTable &lt;span style="color:Blue;"&gt;table&lt;/span&gt;&lt;br /&gt;(&lt;br /&gt;    RecordID &lt;span style="color:Blue;"&gt;int&lt;/span&gt;,&lt;br /&gt;    FromTable &lt;span style="color:Blue;"&gt;nchar&lt;/span&gt;(3),&lt;br /&gt;    idCount &lt;span style="color:Blue;"&gt;int&lt;/span&gt;&lt;br /&gt;)&lt;br /&gt;&lt;span style="color:Blue;"&gt;insert&lt;/span&gt; &lt;span style="color:Blue;"&gt;into&lt;/span&gt; @CountTable&lt;br /&gt;(RecordID,FromTable,idCount)&lt;br /&gt;&lt;span style="color:Blue;"&gt;select&lt;/span&gt; RECORDID, FromTable, &lt;span style="color:Blue;"&gt;COUNT&lt;/span&gt;(ID) &lt;span style="color:Blue;"&gt;from&lt;/span&gt; @PivotTable&lt;br /&gt;&lt;span style="color:Blue;"&gt;GROUP&lt;/span&gt; &lt;span style="color:Blue;"&gt;by&lt;/span&gt; RECORDID, FromTable &lt;span style="color:Blue;"&gt;order&lt;/span&gt; &lt;span style="color:Blue;"&gt;by&lt;/span&gt; RECORDID&lt;br /&gt;&lt;span style="color:Blue;"&gt;Set&lt;/span&gt; @MaxCount = (&lt;span style="color:Blue;"&gt;select&lt;/span&gt; &lt;span style="color:Blue;"&gt;MAX&lt;/span&gt;(idcount) &lt;span style="color:Blue;"&gt;from&lt;/span&gt; @CountTable &lt;span style="color:Blue;"&gt;where&lt;/span&gt; FromTable = @FromShort &lt;span style="color:Blue;"&gt;and&lt;/span&gt; RecordID &lt;span style="color:Blue;"&gt;is&lt;/span&gt; &lt;span style="color:Blue;"&gt;not&lt;/span&gt; &lt;span style="color:Blue;"&gt;null&lt;/span&gt;)&lt;br /&gt;&lt;span style="color:Blue;"&gt;Declare&lt;/span&gt; @ColumnsErString &lt;span style="color:Blue;"&gt;varchar&lt;/span&gt;(5000)&lt;br /&gt;&lt;span style="color:Blue;"&gt;Declare&lt;/span&gt; @ColumnsMeString &lt;span style="color:Blue;"&gt;varchar&lt;/span&gt;(5000)&lt;br /&gt;&lt;span style="color:Blue;"&gt;Declare&lt;/span&gt; @ColumnsQmrString &lt;span style="color:Blue;"&gt;varchar&lt;/span&gt;(5000)&lt;br /&gt;&lt;span style="color:Blue;"&gt;Declare&lt;/span&gt; @BuildColumnsString &lt;span style="color:Blue;"&gt;varchar&lt;/span&gt;(5000)&lt;br /&gt;&lt;span style="color:Blue;"&gt;Set&lt;/span&gt; @BuildColumnsString = &lt;span style="color:Navy;"&gt;&amp;#39;CREATE table &amp;#39;&lt;/span&gt; + rtrim(@FromShort) + &lt;span style="color:Navy;"&gt;&amp;#39;Temp (&amp;#39;&lt;/span&gt; + ltrim(rtrim(@FromShort)) + &lt;span style="color:Navy;"&gt;&amp;#39;_ForeignKey varchar(30), &amp;#39;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;Set&lt;/span&gt; @I = 1&lt;br /&gt;&lt;span style="color:Blue;"&gt;WHILE&lt;/span&gt; (@I &amp;lt;= @MaxCount)&lt;br /&gt;&lt;span style="color:Blue;"&gt;Begin&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:Blue;"&gt;If&lt;/span&gt; @I &amp;lt;&amp;gt; 1 &lt;span style="color:Blue;"&gt;set&lt;/span&gt; @BuildColumnsString = @BuildColumnsString + &lt;span style="color:Navy;"&gt;&amp;#39;, &amp;#39;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:Blue;"&gt;Set&lt;/span&gt; @BuildColumnsString = @BuildColumnsString + rtrim(@FromShort) + &lt;span style="color:Navy;"&gt;&amp;#39;Desc&amp;#39;&lt;/span&gt; + ltrim(str(@I)) + &lt;span style="color:Navy;"&gt;&amp;#39; nchar(100), &amp;#39;&lt;/span&gt; + rtrim(@FromShort) + &lt;span style="color:Navy;"&gt;&amp;#39;Amt&amp;#39;&lt;/span&gt; + ltrim(str(@I)) + &lt;span style="color:Navy;"&gt;&amp;#39; nvarchar(4000)&amp;#39;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:Blue;"&gt;Set&lt;/span&gt; @I = @I + 1&lt;br /&gt;&lt;span style="color:Blue;"&gt;End&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;Set&lt;/span&gt; @BuildColumnsString = @BuildColumnsString + &lt;span style="color:Navy;"&gt;&amp;#39;)&amp;#39;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;Exec&lt;/span&gt;(@BuildColumnsString)&lt;br /&gt;&lt;span style="color:Blue;"&gt;Declare&lt;/span&gt; @TableIDStep &lt;span style="color:Blue;"&gt;varchar&lt;/span&gt;(30), @RecIDStep &lt;span style="color:Blue;"&gt;varchar&lt;/span&gt;(30), @RecID &lt;span style="color:Blue;"&gt;varchar&lt;/span&gt;(30)&lt;br /&gt;&lt;span style="color:Blue;"&gt;Declare&lt;/span&gt; @CurrentFrom &lt;span style="color:Blue;"&gt;varchar&lt;/span&gt;(3), @CurrentDesc &lt;span style="color:Blue;"&gt;nchar&lt;/span&gt;(100), @CurrentAmt &lt;span style="color:Blue;"&gt;nvarchar&lt;/span&gt;(4000)&lt;br /&gt;&lt;span style="color:Blue;"&gt;Declare&lt;/span&gt; @InsertStr &lt;span style="color:Blue;"&gt;varchar&lt;/span&gt;(5000), @InsertStep &lt;span style="color:Blue;"&gt;int&lt;/span&gt;, @CurrentStep &lt;span style="color:Blue;"&gt;varchar&lt;/span&gt;(30)&lt;br /&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;Select&lt;/span&gt; @RecIDStep = &lt;span style="color:Blue;"&gt;min&lt;/span&gt;(ID) &lt;span style="color:Blue;"&gt;from&lt;/span&gt; @PivotTable &lt;span style="color:Blue;"&gt;where&lt;/span&gt; FROMTABLE = @FromShort&lt;br /&gt;&lt;span style="color:Blue;"&gt;Set&lt;/span&gt; @TableIDStep = 1&lt;br /&gt;&lt;span style="color:Blue;"&gt;Set&lt;/span&gt; @InsertStep = 1&lt;br /&gt;&lt;span style="color:Blue;"&gt;while&lt;/span&gt; @TableIDStep &amp;lt;= @MaxCount&lt;br /&gt;&lt;span style="color:Blue;"&gt;begin&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:Blue;"&gt;while&lt;/span&gt; @RecIDStep &lt;span style="color:Blue;"&gt;is&lt;/span&gt; &lt;span style="color:Blue;"&gt;not&lt;/span&gt; &lt;span style="color:Blue;"&gt;null&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:Blue;"&gt;Begin&lt;/span&gt;    &lt;br /&gt;        &lt;span style="color:Blue;"&gt;select&lt;/span&gt;&lt;br /&gt;            @RecID = RECORDID,&lt;br /&gt;            @CurrentFrom = Fromtable,&lt;br /&gt;            @CurrentDesc = replace(DESCRIPTION,&lt;span style="color:Blue;"&gt;char&lt;/span&gt;(39),&lt;span style="color:Blue;"&gt;char&lt;/span&gt;(39)+&lt;span style="color:Blue;"&gt;char&lt;/span&gt;(39)),&lt;br /&gt;            @CurrentAmt = AMOUNT&lt;br /&gt;        &lt;span style="color:Blue;"&gt;from&lt;/span&gt; @PivotTable &lt;span style="color:Blue;"&gt;where&lt;/span&gt; FromTable = @FromShort &lt;span style="color:Blue;"&gt;and&lt;/span&gt; ID = @RecIDStep&lt;br /&gt;        &lt;br /&gt;        &lt;span style="color:Blue;"&gt;If&lt;/span&gt; @CurrentStep &amp;lt;&amp;gt; @RecID &lt;span style="color:Blue;"&gt;Set&lt;/span&gt; @InsertStep = 1&lt;br /&gt;        &lt;span style="color:Blue;"&gt;Set&lt;/span&gt; @CurrentStep = @RecID&lt;br /&gt;        &lt;span style="color:Blue;"&gt;Declare&lt;/span&gt; @CheckInsertStr &lt;span style="color:Blue;"&gt;nvarchar&lt;/span&gt;(100)&lt;br /&gt;        &lt;span style="color:Blue;"&gt;Declare&lt;/span&gt; @CheckInsertParam &lt;span style="color:Blue;"&gt;nvarchar&lt;/span&gt;(100)&lt;br /&gt;        &lt;span style="color:Blue;"&gt;Declare&lt;/span&gt; @ReturnCount &lt;span style="color:Blue;"&gt;int&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:Blue;"&gt;select&lt;/span&gt; @CheckInsertStr = &lt;span style="color:Navy;"&gt;&amp;#39;select @ReturnCount = count (*) from &amp;#39;&lt;/span&gt; + ltrim(rtrim(@FromShort)) + &lt;span style="color:Navy;"&gt;&amp;#39;Temp where &amp;#39;&lt;/span&gt; + ltrim(rtrim(@FromShort)) + &lt;span style="color:Navy;"&gt;&amp;#39;_ForeignKey = &amp;#39;&lt;/span&gt; + @RecID&lt;br /&gt;        &lt;span style="color:Blue;"&gt;select&lt;/span&gt; @CheckInsertParam = &lt;span style="color:Navy;"&gt;&amp;#39;@ReturnCount int OUTPUT&amp;#39;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:Blue;"&gt;exec&lt;/span&gt; sp_ExecuteSql @CheckInsertStr, @CheckInsertParam, @ReturnCount &lt;span style="color:Blue;"&gt;output&lt;/span&gt;&lt;br /&gt;            &lt;br /&gt;        &lt;span style="color:Blue;"&gt;If&lt;/span&gt; @ReturnCount = 0                         &lt;br /&gt;            &lt;span style="color:Blue;"&gt;Set&lt;/span&gt; @InsertStr = &lt;span style="color:Navy;"&gt;&amp;#39;insert into &amp;#39;&lt;/span&gt; + @CurrentFrom + &lt;span style="color:Navy;"&gt;&amp;#39;Temp (&amp;#39;&lt;/span&gt; + ltrim(rtrim(@FromShort)) + &lt;span style="color:Navy;"&gt;&amp;#39;_ForeignKey,&amp;#39;&lt;/span&gt; + @CurrentFrom + &lt;span style="color:Navy;"&gt;&amp;#39;Desc&amp;#39;&lt;/span&gt; + ltrim(STR(@InsertStep)) + &lt;span style="color:Navy;"&gt;&amp;#39;,&amp;#39;&lt;/span&gt; + @CurrentFrom + &lt;span style="color:Navy;"&gt;&amp;#39;Amt&amp;#39;&lt;/span&gt; + ltrim(STR(@InsertStep)) + &lt;span style="color:Navy;"&gt;&amp;#39;) values (&amp;#39;&lt;/span&gt; + &lt;span style="color:Blue;"&gt;CHAR&lt;/span&gt;(39) + @RecID + &lt;span style="color:Blue;"&gt;CHAR&lt;/span&gt;(39) + &lt;span style="color:Navy;"&gt;&amp;#39;,&amp;#39;&lt;/span&gt; + &lt;span style="color:Blue;"&gt;CHAR&lt;/span&gt;(39) + ltrim(rtrim(@CurrentDesc)) + &lt;span style="color:Blue;"&gt;CHAR&lt;/span&gt;(39) + &lt;span style="color:Navy;"&gt;&amp;#39;,&amp;#39;&lt;/span&gt; + &lt;span style="color:Blue;"&gt;char&lt;/span&gt;(39) + ltrim(rtrim(isnull(@CurrentAmt, 0.00))) + &lt;span style="color:Blue;"&gt;CHAR&lt;/span&gt;(39) + &lt;span style="color:Navy;"&gt;&amp;#39;)&amp;#39;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:Blue;"&gt;Else&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:Blue;"&gt;Set&lt;/span&gt; @InsertStr = &lt;span style="color:Navy;"&gt;&amp;#39;update &amp;#39;&lt;/span&gt; + @CurrentFrom + &lt;span style="color:Navy;"&gt;&amp;#39;Temp set &amp;#39;&lt;/span&gt; + @CurrentFrom + &lt;span style="color:Navy;"&gt;&amp;#39;Desc&amp;#39;&lt;/span&gt; + ltrim(STR(@InsertStep)) + &lt;span style="color:Navy;"&gt;&amp;#39; = &amp;#39;&lt;/span&gt; + &lt;span style="color:Blue;"&gt;CHAR&lt;/span&gt;(39) + ltrim(rtrim(@CurrentDesc)) + &lt;span style="color:Blue;"&gt;CHAR&lt;/span&gt;(39) + &lt;span style="color:Navy;"&gt;&amp;#39;,&amp;#39;&lt;/span&gt; + @CurrentFrom + &lt;span style="color:Navy;"&gt;&amp;#39;Amt&amp;#39;&lt;/span&gt; + ltrim(STR(@InsertStep)) + &lt;span style="color:Navy;"&gt;&amp;#39; = &amp;#39;&lt;/span&gt; + &lt;span style="color:Blue;"&gt;CHAR&lt;/span&gt;(39) + ltrim(rtrim(@CurrentAmt)) + &lt;span style="color:Blue;"&gt;CHAR&lt;/span&gt;(39) + &lt;span style="color:Navy;"&gt;&amp;#39; where &amp;#39;&lt;/span&gt; + ltrim(rtrim(@FromShort)) + &lt;span style="color:Navy;"&gt;&amp;#39;_ForeignKey = &amp;#39;&lt;/span&gt; + @RecID&lt;br /&gt;    &lt;br /&gt;        &lt;br /&gt;        &lt;span style="color:Blue;"&gt;exec&lt;/span&gt;(@InsertStr)&lt;br /&gt;        &lt;br /&gt;        &lt;span style="color:Blue;"&gt;update&lt;/span&gt; @PivotTable &lt;span style="color:Blue;"&gt;set&lt;/span&gt; Processed = &lt;span style="color:Navy;"&gt;&amp;#39;T&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;where&lt;/span&gt; ID = @RecIDStep&lt;br /&gt;        &lt;span style="color:Blue;"&gt;Select&lt;/span&gt; @RecIDStep = &lt;span style="color:Blue;"&gt;MIN&lt;/span&gt;(ID) &lt;span style="color:Blue;"&gt;from&lt;/span&gt; @PivotTable &lt;span style="color:Blue;"&gt;where&lt;/span&gt; FROMTABLE = @CurrentFrom &lt;span style="color:Blue;"&gt;and&lt;/span&gt; ID &amp;lt;&amp;gt; @RecIDStep &lt;span style="color:Blue;"&gt;and&lt;/span&gt; Processed &amp;lt;&amp;gt; &lt;span style="color:Navy;"&gt;&amp;#39;T&amp;#39;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:Blue;"&gt;Set&lt;/span&gt; @InsertStep = @InsertStep + 1&lt;br /&gt;    &lt;span style="color:Blue;"&gt;End&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:Blue;"&gt;Set&lt;/span&gt; @TableIDStep = @TableIDStep + 1&lt;br /&gt;&lt;span style="color:Blue;"&gt;End&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;&lt;br /&gt;&lt;p&gt;Finally, a second stored procedure is used to drop the temp tables if they already exist, and fill them with values derived from the previous stored procedure:&lt;/p&gt;
 &lt;table style="table-layout:fixed;width:600px;" cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt; &lt;span style="color:Blue;"&gt;CREATE&lt;/span&gt; &lt;span style="color:Blue;"&gt;procedure&lt;/span&gt; [dbo].[sp_BuildRotatedTempData] &lt;span style="color:Blue;"&gt;as&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;DECLARE&lt;/span&gt; @RC &lt;span style="color:Blue;"&gt;int&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;DECLARE&lt;/span&gt; @DataPart &lt;span style="color:Blue;"&gt;varchar&lt;/span&gt;(30)&lt;br /&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;IF&lt;/span&gt;  &lt;span style="color:Blue;"&gt;EXISTS&lt;/span&gt; (&lt;span style="color:Blue;"&gt;SELECT&lt;/span&gt; * &lt;span style="color:Blue;"&gt;FROM&lt;/span&gt; sys.objects &lt;span style="color:Blue;"&gt;WHERE&lt;/span&gt; object_id = OBJECT_ID(N&lt;span style="color:Navy;"&gt;&amp;#39;[dbo].[T1Temp]&amp;#39;&lt;/span&gt;) &lt;span style="color:Blue;"&gt;AND&lt;/span&gt; type &lt;span style="color:Blue;"&gt;in&lt;/span&gt; (N&lt;span style="color:Navy;"&gt;&amp;#39;U&amp;#39;&lt;/span&gt;))&lt;br /&gt;&lt;span style="color:Blue;"&gt;DROP&lt;/span&gt; &lt;span style="color:Blue;"&gt;TABLE&lt;/span&gt; [dbo].[T1Temp]&lt;br /&gt;&lt;span style="color:Blue;"&gt;EXECUTE&lt;/span&gt; @RC = [dbo].[sp_TablesSnapshot]&lt;br /&gt;   &lt;span style="color:Navy;"&gt;&amp;#39;Test1&amp;#39;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;IF&lt;/span&gt;  &lt;span style="color:Blue;"&gt;EXISTS&lt;/span&gt; (&lt;span style="color:Blue;"&gt;SELECT&lt;/span&gt; * &lt;span style="color:Blue;"&gt;FROM&lt;/span&gt; sys.objects &lt;span style="color:Blue;"&gt;WHERE&lt;/span&gt; object_id = OBJECT_ID(N&lt;span style="color:Navy;"&gt;&amp;#39;[dbo].[T2Temp]&amp;#39;&lt;/span&gt;) &lt;span style="color:Blue;"&gt;AND&lt;/span&gt; type &lt;span style="color:Blue;"&gt;in&lt;/span&gt; (N&lt;span style="color:Navy;"&gt;&amp;#39;U&amp;#39;&lt;/span&gt;))&lt;br /&gt;&lt;span style="color:Blue;"&gt;DROP&lt;/span&gt; &lt;span style="color:Blue;"&gt;TABLE&lt;/span&gt; [dbo].[T2Temp]&lt;br /&gt;&lt;span style="color:Blue;"&gt;EXECUTE&lt;/span&gt; @RC = [dbo].[sp_TablesSnapshot]&lt;br /&gt;   &lt;span style="color:Navy;"&gt;&amp;#39;Test2&amp;#39;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;IF&lt;/span&gt;  &lt;span style="color:Blue;"&gt;EXISTS&lt;/span&gt; (&lt;span style="color:Blue;"&gt;SELECT&lt;/span&gt; * &lt;span style="color:Blue;"&gt;FROM&lt;/span&gt; sys.objects &lt;span style="color:Blue;"&gt;WHERE&lt;/span&gt; object_id = OBJECT_ID(N&lt;span style="color:Navy;"&gt;&amp;#39;[dbo].[T3Temp]&amp;#39;&lt;/span&gt;) &lt;span style="color:Blue;"&gt;AND&lt;/span&gt; type &lt;span style="color:Blue;"&gt;in&lt;/span&gt; (N&lt;span style="color:Navy;"&gt;&amp;#39;U&amp;#39;&lt;/span&gt;))&lt;br /&gt;&lt;span style="color:Blue;"&gt;DROP&lt;/span&gt; &lt;span style="color:Blue;"&gt;TABLE&lt;/span&gt; [dbo].[T3Temp]&lt;br /&gt;&lt;span style="color:Blue;"&gt;EXECUTE&lt;/span&gt; @RC = [dbo].[sp_TablesSnapshot]&lt;br /&gt;   &lt;span style="color:Navy;"&gt;&amp;#39;Test3&amp;#39;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;  


&lt;p&gt;Now it&amp;#39;s just a matter of running the second procedure each time the data changes to get a current snapshot of the data in the current format.&amp;nbsp; It is then a simple matter of creating a view joining the each of the newly created temp tables to their parent table to return everything in a columnar format.&lt;/p&gt;&lt;p&gt;I hope you find this helpful.&amp;nbsp; I&amp;#39;ve attached the scripts to create the Stored Procedures so that you can modify them for your own purposes.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Thanks for reading! &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;img src="http://customerfx.com/aggbug.aspx?PostID=44439" width="1" height="1"&gt;</content><author><name>Jason Buss</name><uri>http://customerfx.com/members/Jason-Buss.aspx</uri></author><category term="Development" scheme="http://customerfx.com/pages/customization/archive/tags/Development/default.aspx" /><category term="How-To" scheme="http://customerfx.com/pages/customization/archive/tags/How-To/default.aspx" /><category term="SQL" scheme="http://customerfx.com/pages/customization/archive/tags/SQL/default.aspx" /><category term="scripting" scheme="http://customerfx.com/pages/customization/archive/tags/scripting/default.aspx" /></entry><entry><title>Web Basics - Using the UserService in a Code Snippet Action Item.</title><link rel="alternate" type="text/html" href="http://customerfx.com/pages/customization/2010/11/15/Web-Basics-_2D00_-Using-the-UserService-in-a-Code-Snippet-Action-Item_2E00_.aspx" /><id>http://customerfx.com/pages/customization/2010/11/15/Web-Basics-_2D00_-Using-the-UserService-in-a-Code-Snippet-Action-Item_2E00_.aspx</id><published>2010-11-15T09:16:00Z</published><updated>2010-11-15T09:16:00Z</updated><content type="html">&lt;p&gt;It&amp;#39;s easy to access the UserService interface from a&amp;nbsp; Code Snippet Action item in the SalesLogix web client.&amp;nbsp; For this example, I&amp;#39;m just going to add a button on account detail which will launch a&amp;nbsp; DialogService message with the current user.&lt;/p&gt;&lt;p&gt;After adding the button to the AccountDetails form,&amp;nbsp; I added a new CodeSnippet action item to the onclick event of the button, creating it as a C# Code snippet.&lt;/p&gt;&lt;p&gt;Since we&amp;#39;re using a code snippet action item, we&amp;#39;ll need to actually get the IUserService with the following code:&lt;br /&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;i&gt;Sage.Platform.Security.IUSerService user = form.Services.Get&amp;lt;Sage.Platform.Security.IUserService&amp;gt;; &lt;/i&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;That&amp;#39;s really all you need to do to access the IUserService.&amp;nbsp; Once we have that, we have access to the CurrentUserID, if we wanted to do something with that in code.&amp;nbsp; Since I&amp;#39;m displaying this in a Dialog, we&amp;#39;ll need to get the IWebDialogService to be able to call the dialog: &lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;i&gt;Sage.Platform.WebPortal.Services.IWebDialogService dlg = form.WorkITem.Services.Get&amp;lt;Sage.PLatform.WebPortal.Services.IWebDialogService&amp;gt;();&lt;/i&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;Once that is done, calling the dialog itself is a simple matter of calling the dialog&amp;#39;s ShowMessage function: &lt;br /&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;i&gt;dlg.ShowMessage(&amp;quot;Current User: &amp;quot; + user.PrettyName);&lt;/i&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;That&amp;#39;s all there is to it!&amp;nbsp; Again, we also have access to the current user&amp;#39;s ID if we wanted to use that for some purpose.&amp;nbsp; In future articles, I&amp;#39;ll give some more examples of what we can do with the UserService interface.&lt;/p&gt;&lt;p&gt;&amp;nbsp; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://customerfx.com/aggbug.aspx?PostID=44027" width="1" height="1"&gt;</content><author><name>Jason Buss</name><uri>http://customerfx.com/members/Jason-Buss.aspx</uri></author><category term="Basics" scheme="http://customerfx.com/pages/customization/archive/tags/Basics/default.aspx" /><category term="How-To" scheme="http://customerfx.com/pages/customization/archive/tags/How-To/default.aspx" /><category term="SalesLogix Web" scheme="http://customerfx.com/pages/customization/archive/tags/SalesLogix+Web/default.aspx" /><category term="C#" scheme="http://customerfx.com/pages/customization/archive/tags/C_2300_/default.aspx" /></entry><entry><title>Basics - Setting filters in the OpenDialog common dialog</title><link rel="alternate" type="text/html" href="http://customerfx.com/pages/customization/2010/10/27/Basics-_2D00_-Setting-filters-in-the-OpenDialog-common-dialog.aspx" /><id>http://customerfx.com/pages/customization/2010/10/27/Basics-_2D00_-Setting-filters-in-the-OpenDialog-common-dialog.aspx</id><published>2010-10-27T14:40:00Z</published><updated>2010-10-27T14:40:00Z</updated><content type="html">&lt;p&gt;I wanted to run through quickly how to set filters when using the OpenDialog in the SalesLogix LAN client.&amp;nbsp; When using OpenDialog, it&amp;#39;s nice to be able to define filters so that your users only see the type of file that you want them to open. This is really easy to set up.&lt;/p&gt;&lt;p&gt;The Filter properties of the OpenDialog control displays two columns; Filter Name and Filter.&amp;nbsp; The Filter Name column is what is displayed int he &amp;quot;Files of type&amp;quot; dropdown in the the actual Open form.&amp;nbsp; The filters column defines the filters themselves.&amp;nbsp; You do have to define the file extentions in BOTH columns otherwise the filtering will not work.&amp;nbsp; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;a href="http://customerfx.com/blogs/customization/SalesLogix%20LAN%20-%20OpenDialog%20filter%20properties.JPG"&gt;&lt;img src="http://customerfx.com/blogs/customization/SalesLogix%20LAN%20-%20OpenDialog%20filter%20properties.JPG" border="0" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;In my sample, I am setting a filter for text files, as well as all files. If you want to define multiple file types such as word documents (doc and docx), all you have to do is separate them by semi-colons.&amp;nbsp; In that case, the value in the FilterName column would be &amp;quot;Documents (*.doc;*.docx)&amp;quot; while the Filter column would contain &amp;quot;*.doc;*docx&amp;quot;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;a href="http://customerfx.com/blogs/customization/SalesLogix%20LAN%20-%20OpenDialog%20with%20filters.JPG"&gt;&lt;img src="http://customerfx.com/blogs/customization/SalesLogix%20LAN%20-%20OpenDialog%20with%20filters.JPG" border="0" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;That&amp;#39;s all there is to it! &amp;nbsp;&amp;nbsp;&amp;nbsp; Also, there are a bunch of options listed on the options tab when looking at the filters property for the dialog, which control much of the behavior of the dialog itself. &amp;nbsp; I&amp;#39;d recommend taking a look through those options also to see how you can control the behavior of the OpenDialog.&lt;/p&gt;&lt;p&gt;&amp;nbsp;Thanks for reading! &lt;br /&gt;&lt;/p&gt;&lt;img src="http://customerfx.com/aggbug.aspx?PostID=43912" width="1" height="1"&gt;</content><author><name>Jason Buss</name><uri>http://customerfx.com/members/Jason-Buss.aspx</uri></author><category term="Controls" scheme="http://customerfx.com/pages/customization/archive/tags/Controls/default.aspx" /><category term="Customizations" scheme="http://customerfx.com/pages/customization/archive/tags/Customizations/default.aspx" /><category term="Basics" scheme="http://customerfx.com/pages/customization/archive/tags/Basics/default.aspx" /><category term="How-To" scheme="http://customerfx.com/pages/customization/archive/tags/How-To/default.aspx" /><category term="Dialogs" scheme="http://customerfx.com/pages/customization/archive/tags/Dialogs/default.aspx" /></entry><entry><title>Building a query-based lookup in SalesLogix Lan / Using SLX_Common to build query strings</title><link rel="alternate" type="text/html" href="http://customerfx.com/pages/customization/2010/09/20/using-slx-common-to-build-query-strings.aspx" /><id>http://customerfx.com/pages/customization/2010/09/20/using-slx-common-to-build-query-strings.aspx</id><published>2010-09-20T16:12:00Z</published><updated>2010-09-20T16:12:00Z</updated><content type="html">&lt;p&gt;I&amp;#39;ve &lt;a href="http://customerfx.com/pages/customization/2010/07/19/Useful-Functions-from-the-SLX_5F00_Common-script-_2800_SalesLogix-LAN_2900_.aspx" target="_blank"&gt;previously posed&lt;/a&gt; about a number of useful functions available to you within the SLX_Common script in the LAN version of SalesLogix.&amp;nbsp; I&amp;#39;d like to go a little further in-depth about a couple of functions which are helpful for creating new SQL Query strings.&lt;/p&gt;

&lt;p&gt;In a recent project, I needed to build a query interface similar to what you find in standard opportunity products view.&amp;nbsp; The SLX_Common script holds a couple of functions that I used in building this interface.&amp;nbsp; In this posting, I&amp;#39;m going to go through building a simple account lookup view using this functionality.&lt;/p&gt;

&lt;p&gt;Before I get to any code, we need to build a view containing our search fields and a grid to hold the search results. This view will not be bound in anyway, so I&amp;#39;m going to create this as a manage view.&amp;nbsp; &lt;/p&gt;

&lt;p&gt;&lt;a href="http://customerfx.com/blogs/customization/SalesLogix%20LAN%20-%20New%20Manage%20View.JPG"&gt;&lt;img src="http://customerfx.com/blogs/customization/SalesLogix%20LAN%20-%20New%20Manage%20View.JPG" border="0" alt="" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;First of all, I&amp;#39;m going to get rid of the right panel and the associated buttons.&amp;nbsp; In addition, I&amp;#39;m going to add a datagrid as well as three textboxes to hold search values, and three combo boxes to hold operators for each field.&amp;nbsp; For the purposes of this post, I&amp;#39;ll use the Account, Type and Status fields as the lookup fields.&amp;nbsp; Finally, I&amp;#39;ve added a Search button.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;a href="http://customerfx.com/blogs/customization/SalesLogix%20LAN%20-%20Test%20Account%20Lookup.JPG"&gt;&lt;/a&gt;&lt;a href="http://customerfx.com/blogs/customization/SalesLogix%20LAN%20-%20Test%20Account%20Lookup2.JPG"&gt;&lt;img src="http://customerfx.com/blogs/customization/SalesLogix%20LAN%20-%20Test%20Account%20Lookup2.JPG" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;For Type and Status, I actually set them up as picklists, with their corresponding lists attached.&amp;nbsp; The comboboxes have had their &lt;i&gt;Items&lt;/i&gt; property populated with standard operator values (Starts With, Contains, Equal To, Not Equal To, Less Than or Equal To, Greater Than or Equal To, Less Than, Greater Than).&amp;nbsp; While some of these operators don&amp;#39;t really make sense for a Alpha-numeric comparison, I&amp;#39;ve included them in this example.&amp;nbsp; The available operators and their order are important, which you will see a little later.&lt;/p&gt;

&lt;p&gt;For the Grid itself, we need to include some columns.&amp;nbsp; Since this grid will not actually be bound, it doesn&amp;#39;t really matter which fields we use, but we do need to provide fields so that we can apply formatting for fields that would need it, such as dates, boolean values, phone numbers, etc...&amp;nbsp; I&amp;#39;ve used the userfield 1-6 fields in the account table, setting the caption property of each column to what I would like to display in the datagrid, along with any necessary formatting.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://customerfx.com/blogs/customization/SalesLogix%20LAN%20-%20New%20Columns%20Added.JPG"&gt;&lt;img src="http://customerfx.com/blogs/customization/SalesLogix%20LAN%20-%20New%20Columns%20Added.JPG" border="0" alt="" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;As you can see, the accountid field is included as well.&amp;nbsp; I don&amp;#39;t want to actually show this field, so it will be necessary to go into the columns collection for the grid and make that column invisible.&amp;nbsp; While I am in there, I&amp;#39;m also going to set the other columns to read-only, as well as disabling the editor.&lt;/p&gt;

&lt;p&gt;Now that our view is set up, we can start adding in come code to make this lookup work!&lt;/p&gt;

&lt;p&gt;&amp;nbsp;The first bit of code I&amp;#39;m adding is to define a global variable for each search parameter, which will tell us which fields to include in the search.&amp;nbsp; To populate these global varables, I created a subroutine call &lt;i&gt;ApplyFilterOption&lt;/i&gt; which I attach to the OnExit event of each of the parameter fields:&lt;/p&gt;

&lt;table style="table-layout:fixed;width:600px;" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre&gt;  option explicit&lt;br /&gt;&lt;span style="color:Blue;"&gt;Dim&lt;/span&gt; bIncludeAccount&lt;br /&gt;&lt;span style="color:Blue;"&gt;Dim&lt;/span&gt; bIncludeType&lt;br /&gt;&lt;span style="color:Blue;"&gt;Dim&lt;/span&gt; bIncludeStats&lt;br /&gt;&lt;span style="color:Blue;"&gt;Sub&lt;/span&gt; ApplyFilterOption(Sender)&lt;br /&gt;    bIncludeAccount &lt;span style="color:Navy;"&gt;=&lt;/span&gt; (Trim(txtAccount.Text) &amp;lt;&amp;gt; &amp;quot;&amp;quot;)&lt;br /&gt;    bIncludeType &lt;span style="color:Navy;"&gt;=&lt;/span&gt; (Trim(pklType.Text) &amp;lt;&amp;gt; &amp;quot;&amp;quot;)&lt;br /&gt;    bIncludeStatus &lt;span style="color:Navy;"&gt;=&lt;/span&gt; (Trim(pklStatus.Text) &amp;lt;&amp;gt; &amp;quot;&amp;quot;)&lt;br /&gt;&lt;span style="color:Blue;"&gt;End&lt;/span&gt; &lt;span style="color:Blue;"&gt;Sub&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
   

&lt;p&gt;With this code, if a user enters a value in &amp;quot;Account&amp;quot;, for example, we&amp;#39;ll know to include &amp;quot;Account&amp;quot; in the where clause of our SQL Statement.&lt;/p&gt;

&lt;p&gt;Now we&amp;#39;re ready to do the actual query.&amp;nbsp; I&amp;#39;ve added another couple of functions, to build the actual query string that will search the database.&amp;nbsp; First, I created a function called &lt;i&gt;SearchAccount&lt;/i&gt;.&amp;nbsp; This function is simply a string consisting of a SQL Statement for querying the Account table. &lt;/p&gt;

 
&lt;table style="table-layout:fixed;width:600px;" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre&gt;&lt;span style="color:Blue;"&gt;Function&lt;/span&gt; SearchAccount&lt;br /&gt;    &lt;span style="color:Blue;"&gt;Dim&lt;/span&gt; sSql&lt;br /&gt;    sSql &lt;span style="color:Navy;"&gt;=&lt;/span&gt; &amp;quot;&lt;span style="color:Blue;"&gt;SELECT&lt;/span&gt; ACCOUNTID &lt;span style="color:Blue;"&gt;AS&lt;/span&gt; USERFIELD1, ACCOUNT &lt;span style="color:Blue;"&gt;AND&lt;/span&gt; USERFIELD2, &amp;quot; &amp;amp; _&lt;br /&gt;           &amp;quot;TYPE &lt;span style="color:Blue;"&gt;AS&lt;/span&gt; USERFIELD3, STATUS &lt;span style="color:Blue;"&gt;AS&lt;/span&gt; USERFIELD4, &amp;quot; &amp;amp; _&lt;br /&gt;           &amp;quot;MAINPHONE &lt;span style="color:Blue;"&gt;AS&lt;/span&gt; USERFIELD5, WEBADDRESS &lt;span style="color:Blue;"&gt;AS&lt;/span&gt; USERFIELD6 &amp;quot; &amp;amp; BuildFilter&lt;br /&gt;&lt;span style="color:Blue;"&gt;End&lt;/span&gt; &lt;span style="color:Blue;"&gt;Function&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
  

&lt;p&gt;As you can see, there is no where clause yet.&amp;nbsp; This will be built by another function I added called &lt;i&gt;BuildFilter&lt;/i&gt;.&lt;/p&gt;

 
&lt;table style="table-layout:fixed;width:600px;" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre&gt;&lt;span style="color:Blue;"&gt;Function&lt;/span&gt; BuildFilter&lt;br /&gt;    &lt;span style="color:Blue;"&gt;Dim&lt;/span&gt; sWhere&lt;br /&gt;    sWhere &lt;span style="color:Navy;"&gt;=&lt;/span&gt; &amp;quot;&amp;quot;&lt;br /&gt;    &lt;span style="color:Blue;"&gt;If&lt;/span&gt; bIncludeAccount &lt;span style="color:Blue;"&gt;Then&lt;/span&gt;&lt;br /&gt;        sWhere &lt;span style="color:Navy;"&gt;=&lt;/span&gt; AddToWhereClause(&amp;quot;ACCOUNT&amp;quot;, GetSQLConditionClause(cmbAccount.ItemIndex, txtAccount.Text), sWhere)&lt;br /&gt;    &lt;span style="color:Blue;"&gt;End&lt;/span&gt; &lt;span style="color:Blue;"&gt;If&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:Blue;"&gt;If&lt;/span&gt; bIncludeType &lt;span style="color:Blue;"&gt;Then&lt;/span&gt;&lt;br /&gt;        sWhere &lt;span style="color:Navy;"&gt;=&lt;/span&gt; AddToWhereClause(&amp;quot;TYPE&amp;quot;, GetSqlConditionClause(cmbType.ItemIndex, pklType.Text), sWhere)&lt;br /&gt;    &lt;span style="color:Blue;"&gt;End&lt;/span&gt; &lt;span style="color:Blue;"&gt;If&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:Blue;"&gt;If&lt;/span&gt; bInlcudeStatus &lt;span style="color:Blue;"&gt;Then&lt;/span&gt;&lt;br /&gt;        sWhere &lt;span style="color:Navy;"&gt;=&lt;/span&gt; AddToWhereClause(&amp;quot;STATUS&amp;quot;, GetSqlConditionClause(cmbStatus.ItemIndex, pklStatus.Text), sWhere)&lt;br /&gt;    &lt;span style="color:Blue;"&gt;End&lt;/span&gt; &lt;span style="color:Blue;"&gt;If&lt;/span&gt;&lt;br /&gt;    BuildFilter &lt;span style="color:Navy;"&gt;=&lt;/span&gt; sWhere&lt;br /&gt;&lt;span style="color:Blue;"&gt;End&lt;/span&gt; &lt;span style="color:Blue;"&gt;Function&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
  

&lt;p&gt;In the BuildFilter Function, I am using two different functions from the SLX_Common Script; AddToWhereClause and GetSqlConditionClause. &amp;nbsp; The GetSqlCondition function takes two parameters; The index from the combo box (this is why the order of the operators within the items property of the combobox control is so important) and the value to search for.&amp;nbsp; This is called from within the AddToWhereClause function to append any search parameters from my view into the SQL statement I built.&lt;/p&gt;

&lt;p&gt;All we need to do now is set the SQL property of the results grid to the results of the SearchAccount function.&amp;nbsp; Since we aliased the returned values in that statement with the same fields we used to define the grid, any formatting we set in the grid will carry forward.&amp;nbsp;
&lt;/p&gt;

&lt;table style="table-layout:fixed;width:600px;" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre&gt;&lt;span style="color:Blue;"&gt;Sub&lt;/span&gt; cmdSearchClick(Sender)&lt;br /&gt;    dgSearchResults.SQL &lt;span style="color:Navy;"&gt;=&lt;/span&gt; SearchAccount&lt;br /&gt;    dgSearchResults.Refresh&lt;br /&gt;&lt;span style="color:Blue;"&gt;End&lt;/span&gt; &lt;span style="color:Blue;"&gt;Sub&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;&amp;nbsp;We should now be getting a result set in our grid.&amp;nbsp; The final step will be to navigate to whichever record from the results the user double-clicks, and to close the search view.&amp;nbsp; This can be done very easily in a doubleclick event on the grid: &lt;br /&gt;&lt;/p&gt;&lt;table style="table-layout:fixed;width:600px;" cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt;&lt;span style="color:Blue;"&gt;Sub&lt;/span&gt; dgSearchResultsDblClick(Sender)&lt;br /&gt;    Application.BasicFunctions.ShowDetails &amp;quot;Account&amp;quot;, dgSearchResults.GetCurrentField(&amp;quot;UserField1&amp;quot;)&lt;br /&gt;    frmTestAccountLookup.ModalResult &lt;span style="color:Navy;"&gt;=&lt;/span&gt; mrOK&lt;br /&gt;&lt;span style="color:Blue;"&gt;End&lt;/span&gt; &lt;span style="color:Blue;"&gt;Sub&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;  

&lt;p&gt;So There we go! We&amp;#39;ve just created a simple Account lookup view using a Manage view, and functionality from the SLX_Common script.&amp;#39;&lt;/p&gt;&lt;p&gt;I hope you found this informative.&amp;nbsp; There&amp;#39;s a lot more we could do with this view.&amp;nbsp; Right-click functionality would be nice to have, and you&amp;#39;ll probably need to disable the navigation functionality if there are no results returned. If you are implementing functionality similar to this, I&amp;#39;d encourage you to play with my code an try to figure out what else you can do to make this more complete of a solution.&amp;nbsp;&amp;nbsp; Thanks for reading!&lt;br /&gt;&lt;/p&gt;&lt;img src="http://customerfx.com/aggbug.aspx?PostID=43810" width="1" height="1"&gt;</content><author><name>Jason Buss</name><uri>http://customerfx.com/members/Jason-Buss.aspx</uri></author><category term="Customizations" scheme="http://customerfx.com/pages/customization/archive/tags/Customizations/default.aspx" /><category term="SalesLogix" scheme="http://customerfx.com/pages/customization/archive/tags/SalesLogix/default.aspx" /><category term="Development" scheme="http://customerfx.com/pages/customization/archive/tags/Development/default.aspx" /><category term="Basics" scheme="http://customerfx.com/pages/customization/archive/tags/Basics/default.aspx" /><category term="SQL" scheme="http://customerfx.com/pages/customization/archive/tags/SQL/default.aspx" /></entry><entry><title>Picklist Column types - Dispaying ticket status in the SalesLogix LAN datagrid</title><link rel="alternate" type="text/html" href="http://customerfx.com/pages/customization/2010/08/24/picklist-column-types-dispaying-ticket-status-in-the-saleslogix-lan-datagrid.aspx" /><id>http://customerfx.com/pages/customization/2010/08/24/picklist-column-types-dispaying-ticket-status-in-the-saleslogix-lan-datagrid.aspx</id><published>2010-08-24T10:30:00Z</published><updated>2010-08-24T10:30:00Z</updated><content type="html">&lt;p&gt;I recently had to build a datagrid displaying ticket information, including the current Status value.&amp;nbsp; Under tickets, the Statuscode field contains the itemid from the picklist table rather than the actual text value as is stored for the Account, Contact or Opportunity areas.&amp;nbsp; If you&amp;#39;ve only dealt with picklists in those other areas, it could cause some confusion when trying to determine just how to display the Ticket status text value in a datagird, however using the picklist column type makes this very easy.&lt;/p&gt;&lt;p&gt;When initially building the grid, you&amp;#39;ll want to add the Ticket.Statuscode column within the Layout tab of the query builder for the grid, just as you would any other field.&amp;nbsp; Once that is done, open the Columns collection properties for the grid.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;a href="http://customerfx.com/blogs/customization/Colums%20Collection%20-%20SLX%20LAN.JPG"&gt;&lt;img src="http://customerfx.com/blogs/customization/Colums%20Collection%20-%20SLX%20LAN.JPG" border="0" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;If you right-click the Status column, one of the options will be &amp;quot;Change Column Type...&amp;quot;.&amp;nbsp; Select this and chance the type from &amp;quot;Standard&amp;quot; to &amp;quot;Picklist&amp;quot;.&amp;nbsp; Once this is done, right-click the status column again, but this type select &amp;quot;Properties...&amp;quot;.&lt;/p&gt;&lt;p&gt;&lt;a href="http://customerfx.com/blogs/customization/Picklist%20Column%20Properties%20-%20SalesLogix%20LAN.JPG"&gt;&lt;img src="http://customerfx.com/blogs/customization/Picklist%20Column%20Properties%20-%20SalesLogix%20LAN.JPG" border="0" alt="" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;As you can see, this interface contains a number of properties.&amp;nbsp; In the case of displaying ticket status values, there are two that you have to worry about.&amp;nbsp; First, set the &amp;quot;Picklist&amp;quot; property to contain the appropriate picklist (in this case, Ticket Status).&amp;nbsp; In addition, you&amp;#39;ll need to check the &amp;quot;Store Items IDs&amp;quot; checkbox.&lt;/p&gt;&lt;p&gt;That&amp;#39;s all there is to it.&amp;nbsp; Your grid will now translate the itemid value do display the actual text value stored in the picklist table.&lt;/p&gt;&lt;p&gt;In my next blog post, I&amp;#39;ll go over what this means in the Web client.&lt;/p&gt;&lt;p&gt;Thanks for reading! &amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;Jason &lt;br /&gt;&lt;/p&gt;&lt;img src="http://customerfx.com/aggbug.aspx?PostID=43746" width="1" height="1"&gt;</content><author><name>Jason Buss</name><uri>http://customerfx.com/members/Jason-Buss.aspx</uri></author><category term="SalesLogix" scheme="http://customerfx.com/pages/customization/archive/tags/SalesLogix/default.aspx" /><category term="datagrid" scheme="http://customerfx.com/pages/customization/archive/tags/datagrid/default.aspx" /><category term="How-To" scheme="http://customerfx.com/pages/customization/archive/tags/How-To/default.aspx" /><category term="Picklists" scheme="http://customerfx.com/pages/customization/archive/tags/Picklists/default.aspx" /></entry><entry><title>Useful Functions from the SLX_Common script (SalesLogix LAN)</title><link rel="alternate" type="text/html" href="http://customerfx.com/pages/customization/2010/07/19/Useful-Functions-from-the-SLX_5F00_Common-script-_2800_SalesLogix-LAN_2900_.aspx" /><id>http://customerfx.com/pages/customization/2010/07/19/Useful-Functions-from-the-SLX_5F00_Common-script-_2800_SalesLogix-LAN_2900_.aspx</id><published>2010-07-19T11:58:00Z</published><updated>2010-07-19T11:58:00Z</updated><content type="html">&lt;p&gt;The SLX_Common script included in SalesLogix contains a number of simple, yet useful, functions that you can use within your own functionality to save yourself some time by not having to reinvent the wheel each time you need some simple functionality.&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;GetItemIndex(&lt;/b&gt;&lt;i&gt;Control, Value&lt;/i&gt;&lt;b&gt;)&lt;/b&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;This function returns the index for an item within a control such as a ComboBox, CheckListBox, ListView, ect.&amp;nbsp; Basically, any control with an &amp;quot;Items&amp;quot; property.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;b&gt;SLXIsNumeric(&lt;/b&gt;&lt;i&gt;Value&lt;/i&gt;&lt;b&gt;), NulltoZero(&lt;/b&gt;&lt;i&gt;Value&lt;/i&gt;&lt;b&gt;), CheckForNull(&lt;/b&gt;&lt;i&gt;Value&lt;/i&gt;&lt;b&gt;), CheckForNullDate(&lt;/b&gt;&lt;i&gt;Value&lt;/i&gt;&lt;b&gt;)&lt;/b&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;This series of functions can be used to evaluate a number of different datatype for null or blank values.&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;p&gt;There are a number of functions to provide some basic calulations commonly performed against currency values:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;CalculateAdjustedPrice(&lt;/b&gt;&lt;i&gt;Price, Discount&lt;/i&gt;&lt;b&gt;)&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;CalculateDiscountPercentage(&lt;/b&gt;&lt;i&gt;AdjustedPrice, PriceBase&lt;/i&gt;&lt;b&gt;)&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;CalculateExtendedPrice(&lt;/b&gt;&lt;i&gt;AdjustedPrice, ExchangeRate&lt;/i&gt;&lt;b&gt;)&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;CalculateLocalPrice(&lt;/b&gt;&lt;i&gt;AdjustedPrice, ExchangeRate&lt;b&gt;)&lt;/b&gt;&lt;/i&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;CalculateExtendedPriceLocal(&lt;/b&gt;Quantity, PriceLocal&lt;b&gt;)&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;ExtendedPricetotal(&lt;/b&gt;&lt;i&gt;objRS&lt;/i&gt;&lt;b&gt;)&lt;/b&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;ExtendedPriceTotal will total up all records from the passed recordset, where the fieldname is &amp;quot;Extended&amp;quot;)&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;p&gt;There are also a couple of scripts to help with SQL statements:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&amp;nbsp;&lt;b&gt;GetSQLConditionClause(&lt;/b&gt;&lt;i&gt;Index, strFltText&lt;/i&gt;&lt;b&gt;), GetSLXConditionClauseEx(&lt;/b&gt;&lt;i&gt;Index, strFltText, strField&lt;/i&gt;&lt;b&gt;)&lt;/b&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;The Index number passed corresponds with the type of query to run... (0 = Like &lt;i&gt;with wildcards&lt;/i&gt;, 1 = Like, 2 = Equals To, 3 = Not Equal To, etc...)&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;b&gt;AddToWhereClause(&lt;/b&gt;&lt;i&gt;Field, Clause, Where&lt;/i&gt;&lt;b&gt;), AddToWhereClauseEx(&lt;/b&gt;&lt;i&gt;Field, Clause, Where, Condition&lt;/i&gt;&lt;b&gt;)&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;AddCommaDelimatedTextToWhereClause(&lt;/b&gt;&lt;i&gt;intCauseIndex, strWhere, strText, strField&lt;/i&gt;&lt;b&gt;)&lt;/b&gt;&lt;/li&gt;&lt;/ul&gt;etc...&lt;br /&gt;&lt;p&gt;This is just a short list of some of the functionality available in this particular script.&amp;nbsp; Other useful functionality is available in this, as well as many other scripts which are included within SalesLogix.&amp;nbsp; In addition, if you&amp;#39;re relatively new to VB scripting, these scripts provide some invaluable examples for how Subroutines and Functions can be built within the SalesLogix client.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; Jason &lt;br /&gt;&lt;/p&gt;&lt;img src="http://customerfx.com/aggbug.aspx?PostID=43637" width="1" height="1"&gt;</content><author><name>Jason Buss</name><uri>http://customerfx.com/members/Jason-Buss.aspx</uri></author><category term="SalesLogix LAN Client" scheme="http://customerfx.com/pages/customization/archive/tags/SalesLogix+LAN+Client/default.aspx" /><category term="SalesLogix" scheme="http://customerfx.com/pages/customization/archive/tags/SalesLogix/default.aspx" /><category term="Basics" scheme="http://customerfx.com/pages/customization/archive/tags/Basics/default.aspx" /><category term="SQL" scheme="http://customerfx.com/pages/customization/archive/tags/SQL/default.aspx" /></entry><entry><title>SalesLogix basics - Easy Data access in SalesLogix LAN</title><link rel="alternate" type="text/html" href="http://customerfx.com/pages/customization/2010/06/22/saleslogix-basics-easy-data-access-in-saleslogix-lan.aspx" /><id>http://customerfx.com/pages/customization/2010/06/22/saleslogix-basics-easy-data-access-in-saleslogix-lan.aspx</id><published>2010-06-22T13:30:00Z</published><updated>2010-06-22T13:30:00Z</updated><content type="html">&lt;p&gt;In this basics article, I wanted to outline the use of include scripts within the SalesLogix LAN client.&amp;nbsp; Specifically, I&amp;#39;m going to look at the standard SLX Database Support script.&lt;/p&gt;&lt;p&gt;Adding an Include script to either a VB Script or a Form is easy.&amp;nbsp; On toolbar at the top of the script (or script page for the view), there is a button titled &amp;quot;Include Script&amp;quot;.&amp;nbsp; Clicking this button will open the Included scripts panel to the left of the code window.&amp;nbsp; Click the plus sign and select the Script to include. (There are a number of standard scripts available under the &amp;#39;System&amp;#39; family, beginning with &amp;#39;SLX&amp;#39;.&amp;nbsp; These hold much of the Standard functionality provided by SalesLogix.)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;There are a few simple functions you can use right away.&amp;nbsp; For example, to find a single value from a table, you can use the GetField Function:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;i&gt;Dim sValue&lt;/i&gt;&lt;/p&gt;&lt;p&gt;&lt;i&gt;sValue = GetField(&amp;quot;ACCOUNT&amp;quot;, &amp;quot;ACCOUNT&amp;quot;, &amp;quot;ACCOUNTID = &amp;#39;{valid accountid}&amp;#39;)&lt;/i&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;I&amp;#39;ve written some other articles about using ADO in SalesLogix and have handled creating connections myself, however these functions are already contained within the class defined in the Database Support script.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;After adding the SLX Database Support to your script as an include script:&lt;/p&gt;&lt;p&gt;First, you have in instantiate the Class&lt;br /&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;i&gt;Dim objSLXDB = new SLX_DB&lt;/i&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;Now that you have a DB object, you can reuse the object throughout your script.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;For Example, if you need a new recordset:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;i&gt;Set objRS = objSLXDB.Recordset&lt;/i&gt;&lt;/p&gt;&lt;p&gt;&lt;i&gt;objRS.Open &amp;quot;SQL&amp;quot;, objSLXDB.Connection &lt;/i&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;As you can see, not only did I use my SLX Database object to create my new recordset, I also retrieved a connection through the object. &lt;/p&gt;&lt;p&gt;There&amp;#39;s also an ExecuteSQL function which is handy to&amp;nbsp;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;i&gt;objSLXDB.ExecuteSQL &amp;quot;Update {tablename}...&amp;quot;&lt;/i&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;As you can see, the Database Support script can be very handy for performing simple tasks.&amp;nbsp; Other SLX scripts include Error Support and Debug support along with a lot of other useful functionality.&amp;nbsp; You can also create your own scripts to add your own functionality.&amp;nbsp; Creating your own include script is a great way to encapsulate your custom functionality.&amp;nbsp; I&amp;#39;ll cover class building in a future article, so please keep reading!&lt;/p&gt;&lt;p&gt;Thanks!&lt;/p&gt;&lt;p&gt;Jason &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://customerfx.com/aggbug.aspx?PostID=43517" width="1" height="1"&gt;</content><author><name>Jason Buss</name><uri>http://customerfx.com/members/Jason-Buss.aspx</uri></author><category term="SalesLogix" scheme="http://customerfx.com/pages/customization/archive/tags/SalesLogix/default.aspx" /><category term="Basics" scheme="http://customerfx.com/pages/customization/archive/tags/Basics/default.aspx" /><category term="How-To" scheme="http://customerfx.com/pages/customization/archive/tags/How-To/default.aspx" /><category term="vbscript" scheme="http://customerfx.com/pages/customization/archive/tags/vbscript/default.aspx" /></entry><entry><title>Modifying the 'Copy to E-mail' link in the SalesLogix Web client Opportunity snapshot </title><link rel="alternate" type="text/html" href="http://customerfx.com/pages/customization/2010/06/08/modifying-the-copy-to-e-mail-link-in-the-slx-web-client-opportunity-snapshot.aspx" /><id>http://customerfx.com/pages/customization/2010/06/08/modifying-the-copy-to-e-mail-link-in-the-slx-web-client-opportunity-snapshot.aspx</id><published>2010-06-08T12:50:00Z</published><updated>2010-06-08T12:50:00Z</updated><content type="html">&lt;p&gt;If you&amp;#39;ve ever wanted to modify the email generated from the Opportunity Snapshot in the web client, you&amp;#39;ll find that it is incredibly simple to add new fields to the body of the email.&amp;nbsp; To do so, you will need to modify the OpportunitySnapShot.ascx.cs smart part, found under Portal Manager-&amp;gt;Sage SalesLogix-&amp;gt;SupportFiles-&amp;gt;SmartParts-&amp;gt;Opportunity.&lt;/p&gt;
&lt;p&gt;In this file, you will find a function named &amp;#39;FormatEmailBody&amp;#39;.&amp;nbsp; This function builds a string (emailBody) from available properties in the Opportunity Entity.&amp;nbsp; As long as any new fields you have added to the opportunity table has been added to the entity properties, it is a simple matter to include those fields in the email body.&lt;/p&gt;
&lt;p&gt;Current fields defined in the email are done so with the following code (Example shows description field):&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;emailBody += String.Format(&amp;quot;{0} {1} %0A&amp;quot;, GetLocalResourceObject(&amp;quot;lblEmailOppDesc.Caption&amp;quot;),&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CheckForNullValue(opportunity.Description));&lt;/p&gt;
&lt;p&gt;To add a new field (c_orderno), we&amp;#39;re going to copy this line, replace the GetLocalResourceObject call with the field label we&amp;#39;d like to use, and reference the new field from the opportunity entity in the CheckForNullValue function in this line.&lt;/p&gt;
&lt;p&gt;emailBody += String.Format(&amp;quot;{0} {1} %0A&amp;quot;, &amp;quot;Order No:&amp;quot;,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CheckForNullValue(opportunity.CORDERNO));&amp;nbsp; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;The code is formatted in such a way that it should be pretty simple to figure out where in the email body you are putting the new field.&lt;/p&gt;
&lt;p&gt;If you want to add a date field, the format is slightly different, if you want to use the UTCDateTimeToLocalTime function inline:&lt;/p&gt;
&lt;p&gt;emailBody += String.Format(&amp;quot;{0} {1} %0A&amp;quot;, &amp;quot;Modified:&amp;quot;,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; opportunity.CMODIFIED.HasValue&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ? timeZone.UTCDateTimeToLocalTime((DateTime) opportunity.CMODIFIED).ToString(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datePattern)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : String.Empty); &lt;/p&gt;
&lt;table style="TABLE-LAYOUT:fixed;" cellspacing="0" cellpadding="0"&gt;

&lt;tr&gt;
&lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;p&gt;As you can see, it&amp;#39;s a pretty simple process to add new fields to the Email body in the email produced by the Opportunity snapshot.&lt;/p&gt;
&lt;p&gt;Hope you find this helpful.&amp;nbsp; Thanks for reading! &lt;br /&gt;&lt;/p&gt;&lt;img src="http://customerfx.com/aggbug.aspx?PostID=43464" width="1" height="1"&gt;</content><author><name>Jason Buss</name><uri>http://customerfx.com/members/Jason-Buss.aspx</uri></author><category term="Customizations" scheme="http://customerfx.com/pages/customization/archive/tags/Customizations/default.aspx" /><category term="SalesLogix" scheme="http://customerfx.com/pages/customization/archive/tags/SalesLogix/default.aspx" /><category term="How-To" scheme="http://customerfx.com/pages/customization/archive/tags/How-To/default.aspx" /><category term="SalesLogix Web" scheme="http://customerfx.com/pages/customization/archive/tags/SalesLogix+Web/default.aspx" /><category term="Email" scheme="http://customerfx.com/pages/customization/archive/tags/Email/default.aspx" /><category term="Smartparts" scheme="http://customerfx.com/pages/customization/archive/tags/Smartparts/default.aspx" /></entry><entry><title>SQL Function for parsing name values</title><link rel="alternate" type="text/html" href="http://customerfx.com/pages/customization/2010/05/25/sql-function-for-parsing-name-values.aspx" /><link rel="enclosure" type="application/x-zip-compressed" length="1602" href="http://customerfx.com/pages/customization/attachment/42955.ashx" /><id>http://customerfx.com/pages/customization/2010/05/25/sql-function-for-parsing-name-values.aspx</id><published>2010-05-25T15:13:00Z</published><updated>2010-05-25T15:13:00Z</updated><content type="html">&lt;p&gt;&amp;nbsp;In a recent project, I had to create a SQL Server Integration Services package to basically copy contact information (which was being stored in the Account.Account field) from the Account table into the Contact table.&amp;nbsp; Since the Contact name was being stored in it&amp;#39;s entirety within the account field, I needed a way to parse the Contact information to populate the individual contact name fields in the contact table.&lt;/p&gt;

&lt;p&gt;I created a scalar function called ParseName to accomplish this: (I&amp;#39;ve attached a zip containing the .sql file as well)&lt;br /&gt;&lt;/p&gt;

&lt;table style="table-layout:fixed;width:600px;" cellpadding="0" cellspacing="0"&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt; &lt;span style="color:Blue;"&gt;CREATE&lt;/span&gt; &lt;span style="color:Blue;"&gt;function&lt;/span&gt; [dbo].[ParseName](@NameString &lt;span style="color:Blue;"&gt;varchar&lt;/span&gt;(100), @NameFormat &lt;span style="color:Blue;"&gt;varchar&lt;/span&gt;(20))&lt;br /&gt;&lt;span style="color:Blue;"&gt;returns&lt;/span&gt; &lt;span style="color:Blue;"&gt;varchar&lt;/span&gt;(100) &lt;span style="color:Blue;"&gt;as&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;begin&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:Green;"&gt;--ParseName parses a Name String into its component parts &lt;br /&gt;--and returns it as requested.&lt;br /&gt;--This function assumes the data source maintains a standard format of &lt;br /&gt;--&amp;#39;Prefix Firstname Middlename Lastname Suffix&amp;#39;&lt;br /&gt;--&lt;br /&gt;--@NameString is the raw value to be parsed.&lt;br /&gt;--@NameFormat is a string that defines the output format.  Each letter in the string&lt;br /&gt;--represents a component of the name in the order that it is to be returned.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Green;"&gt;--    P = Full prefix&lt;br /&gt;--    p = Abbreviated prefix&lt;br /&gt;--    F = First name&lt;br /&gt;--    f = First initial&lt;br /&gt;--    M = Middle name&lt;br /&gt;--    m = Middle initial&lt;br /&gt;--    L = Last name&lt;br /&gt;--    l = Last initial&lt;br /&gt;--    S = Full suffix&lt;br /&gt;--    s = Abbreviated suffix&lt;br /&gt;--    . = Period&lt;br /&gt;--    , = Comma&lt;br /&gt;--    [ ] = Space&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Green;"&gt;--Example1: select dbo.Parsename(&amp;#39;Doctor Bobo Lee Brown Esquire&amp;#39;, &amp;#39;L, p. F m. s.&amp;#39;)&lt;br /&gt;--Result: &amp;#39;Brown, Dr. Bobo L. Esq.&amp;#39;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Green;"&gt;--Example2:    (Full contact name stored in SLX Account table)&lt;br /&gt;--                select &lt;br /&gt;--                    dbo.Parsename(ACCOUNT, &amp;#39;F&amp;#39;) as FIRSTNAME&lt;br /&gt;--                ,    dbo.Parsename(ACCOUNT, &amp;#39;L&amp;#39;) as LASTNAME&lt;br /&gt;--                from ACCOUNT&lt;br /&gt;--&lt;br /&gt;--Returns:      FIRSTNAME, LASTNAME&lt;br /&gt;--                --------------------&lt;br /&gt;--                &amp;#39;Bobo&amp;#39;, &amp;#39;Brown&amp;#39;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;Declare&lt;/span&gt;    @Prefix &lt;span style="color:Blue;"&gt;varchar&lt;/span&gt;(20)&lt;br /&gt;&lt;span style="color:Blue;"&gt;Declare&lt;/span&gt;    @FirstName &lt;span style="color:Blue;"&gt;varchar&lt;/span&gt;(20)&lt;br /&gt;&lt;span style="color:Blue;"&gt;Declare&lt;/span&gt;    @MiddleName &lt;span style="color:Blue;"&gt;varchar&lt;/span&gt;(30)&lt;br /&gt;&lt;span style="color:Blue;"&gt;Declare&lt;/span&gt;    @LastName &lt;span style="color:Blue;"&gt;varchar&lt;/span&gt;(30)&lt;br /&gt;&lt;span style="color:Blue;"&gt;Declare&lt;/span&gt;    @Suffix &lt;span style="color:Blue;"&gt;varchar&lt;/span&gt;(20)&lt;br /&gt;&lt;span style="color:Blue;"&gt;Declare&lt;/span&gt;    @TempString &lt;span style="color:Blue;"&gt;varchar&lt;/span&gt;(100)&lt;br /&gt;&lt;br /&gt;&lt;span style="color:Green;"&gt;--String Prep - We want to remove any periods, double spaces and commas&lt;br /&gt;&lt;/span&gt;&lt;span style="color:Blue;"&gt;set&lt;/span&gt;    @NameString = rtrim(ltrim(replace(@NameString, &lt;span style="color:Navy;"&gt;&amp;#39;.&amp;#39;&lt;/span&gt;, &lt;span style="color:Navy;"&gt;&amp;#39;. &amp;#39;&lt;/span&gt;)))&lt;br /&gt;&lt;span style="color:Blue;"&gt;while&lt;/span&gt;  charindex(&lt;span style="color:Navy;"&gt;&amp;#39;  &amp;#39;&lt;/span&gt;, @NameString) &amp;gt; 0 &lt;span style="color:Blue;"&gt;set&lt;/span&gt; @NameString = replace(@NameString, &lt;span style="color:Navy;"&gt;&amp;#39;  &amp;#39;&lt;/span&gt;, &lt;span style="color:Navy;"&gt;&amp;#39; &amp;#39;&lt;/span&gt;)&lt;br /&gt;&lt;span style="color:Blue;"&gt;while&lt;/span&gt;  charindex(&lt;span style="color:Navy;"&gt;&amp;#39;.&amp;#39;&lt;/span&gt;, @NameString) &amp;gt; 0 &lt;span style="color:Blue;"&gt;set&lt;/span&gt; @NameString = replace(@NameString, &lt;span style="color:Navy;"&gt;&amp;#39;.&amp;#39;&lt;/span&gt;, &lt;span style="color:Navy;"&gt;&amp;#39;&amp;#39;&lt;/span&gt;)&lt;br /&gt;&lt;span style="color:Blue;"&gt;while&lt;/span&gt;  charindex(&lt;span style="color:Navy;"&gt;&amp;#39;,&amp;#39;&lt;/span&gt;, @NameString) &amp;gt; 0 &lt;span style="color:Blue;"&gt;set&lt;/span&gt; @NameString = replace(@NameString, &lt;span style="color:Navy;"&gt;&amp;#39;,&amp;#39;&lt;/span&gt;, &lt;span style="color:Navy;"&gt;&amp;#39;&amp;#39;&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span style="color:Green;"&gt;--Get Prefix and strip it out of the string...  Add additional prefixes as needed&lt;br /&gt;&lt;/span&gt;&lt;span style="color:Blue;"&gt;set&lt;/span&gt;  @TempString = rtrim(&lt;span style="color:Blue;"&gt;left&lt;/span&gt;(@NameString, charindex(&lt;span style="color:Navy;"&gt;&amp;#39; &amp;#39;&lt;/span&gt;, @NameString + &lt;span style="color:Navy;"&gt;&amp;#39; &amp;#39;&lt;/span&gt;)))&lt;br /&gt;&lt;span style="color:Blue;"&gt;if&lt;/span&gt;   @TempString &lt;span style="color:Blue;"&gt;in&lt;/span&gt; (&lt;span style="color:Navy;"&gt;&amp;#39;MR&amp;#39;&lt;/span&gt;, &lt;span style="color:Navy;"&gt;&amp;#39;MRS&amp;#39;&lt;/span&gt;, &lt;span style="color:Navy;"&gt;&amp;#39;MS&amp;#39;&lt;/span&gt;, &lt;span style="color:Navy;"&gt;&amp;#39;DR&amp;#39;&lt;/span&gt;, &lt;span style="color:Navy;"&gt;&amp;#39;Doctor&amp;#39;&lt;/span&gt;) &lt;span style="color:Blue;"&gt;set&lt;/span&gt; @Prefix = @TempString&lt;br /&gt;&lt;span style="color:Blue;"&gt;if&lt;/span&gt;   len(@Prefix) &amp;gt; 0 &lt;span style="color:Blue;"&gt;set&lt;/span&gt; @NameString = ltrim(&lt;span style="color:Blue;"&gt;right&lt;/span&gt;(@NameString, len(@NameString) - len(@TempString)))&lt;br /&gt;&lt;br /&gt;&lt;span style="color:Green;"&gt;--Get Suffix and strip it out of the string... Add additional suffixes as needed&lt;br /&gt;&lt;/span&gt;&lt;span style="color:Blue;"&gt;set&lt;/span&gt;  @TempString = ltrim(&lt;span style="color:Blue;"&gt;right&lt;/span&gt;(@NameString, charindex(&lt;span style="color:Navy;"&gt;&amp;#39; &amp;#39;&lt;/span&gt;, Reverse(@NameString) + &lt;span style="color:Navy;"&gt;&amp;#39; &amp;#39;&lt;/span&gt;)))&lt;br /&gt;&lt;span style="color:Blue;"&gt;if&lt;/span&gt;   @TempString &lt;span style="color:Blue;"&gt;in&lt;/span&gt; (&lt;span style="color:Navy;"&gt;&amp;#39;Jr&amp;#39;&lt;/span&gt;, &lt;span style="color:Navy;"&gt;&amp;#39;Sr&amp;#39;&lt;/span&gt;,  &lt;span style="color:Navy;"&gt;&amp;#39;II&amp;#39;&lt;/span&gt;, &lt;span style="color:Navy;"&gt;&amp;#39;III&amp;#39;&lt;/span&gt;, &lt;span style="color:Navy;"&gt;&amp;#39;Esq&amp;#39;&lt;/span&gt;, &lt;span style="color:Navy;"&gt;&amp;#39;Junior&amp;#39;&lt;/span&gt;, &lt;span style="color:Navy;"&gt;&amp;#39;Senior&amp;#39;&lt;/span&gt;) &lt;span style="color:Blue;"&gt;set&lt;/span&gt; @Suffix = @TempString&lt;br /&gt;&lt;span style="color:Blue;"&gt;if&lt;/span&gt;   len(@Suffix) &amp;gt; 0 &lt;span style="color:Blue;"&gt;set&lt;/span&gt; @NameString = rtrim(&lt;span style="color:Blue;"&gt;left&lt;/span&gt;(@NameString, len(@NameString) - len(@TempString)))&lt;br /&gt;&lt;br /&gt;&lt;span style="color:Green;"&gt;--Strip Lastname out of the string&lt;br /&gt;&lt;/span&gt;&lt;span style="color:Blue;"&gt;set&lt;/span&gt;  @LastName = ltrim(&lt;span style="color:Blue;"&gt;right&lt;/span&gt;(@NameString, charindex(&lt;span style="color:Navy;"&gt;&amp;#39; &amp;#39;&lt;/span&gt;, Reverse(@NameString) + &lt;span style="color:Navy;"&gt;&amp;#39; &amp;#39;&lt;/span&gt;)))&lt;br /&gt;&lt;span style="color:Blue;"&gt;set&lt;/span&gt;  @NameString = rtrim(&lt;span style="color:Blue;"&gt;left&lt;/span&gt;(@NameString, len(@NameString) - len(@LastName)))&lt;br /&gt;&lt;br /&gt;&lt;span style="color:Green;"&gt;--Check Last name to see if it has two parts...  Add additional values as needed&lt;br /&gt;&lt;/span&gt;&lt;span style="color:Blue;"&gt;set&lt;/span&gt;  @TempString = ltrim(&lt;span style="color:Blue;"&gt;right&lt;/span&gt;(@NameString, charindex(&lt;span style="color:Navy;"&gt;&amp;#39; &amp;#39;&lt;/span&gt;, Reverse(@NameString) + &lt;span style="color:Navy;"&gt;&amp;#39; &amp;#39;&lt;/span&gt;)))&lt;br /&gt;&lt;span style="color:Blue;"&gt;if&lt;/span&gt;   @TempString &lt;span style="color:Blue;"&gt;in&lt;/span&gt; (&lt;span style="color:Navy;"&gt;&amp;#39;VAN&amp;#39;&lt;/span&gt;, &lt;span style="color:Navy;"&gt;&amp;#39;VON&amp;#39;&lt;/span&gt;, &lt;span style="color:Navy;"&gt;&amp;#39;MC&amp;#39;&lt;/span&gt;, &lt;span style="color:Navy;"&gt;&amp;#39;Mac&amp;#39;&lt;/span&gt;, &lt;span style="color:Navy;"&gt;&amp;#39;DE&amp;#39;&lt;/span&gt;)&lt;br /&gt;     &lt;span style="color:Blue;"&gt;begin&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:Blue;"&gt;set&lt;/span&gt; @LastName = @TempString + &lt;span style="color:Navy;"&gt;&amp;#39; &amp;#39;&lt;/span&gt; + @LastName&lt;br /&gt;     &lt;span style="color:Blue;"&gt;set&lt;/span&gt; @NameString = rtrim(&lt;span style="color:Blue;"&gt;left&lt;/span&gt;(@NameString, len(@NameString) - len(@TempString)))&lt;br /&gt;     &lt;span style="color:Blue;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:Green;"&gt;--Get FirstName and strip it out of the string&lt;br /&gt;&lt;/span&gt;&lt;span style="color:Blue;"&gt;set&lt;/span&gt;    @FirstName = rtrim(&lt;span style="color:Blue;"&gt;left&lt;/span&gt;(@NameString, charindex(&lt;span style="color:Navy;"&gt;&amp;#39; &amp;#39;&lt;/span&gt;, @NameString + &lt;span style="color:Navy;"&gt;&amp;#39; &amp;#39;&lt;/span&gt;)))&lt;br /&gt;&lt;span style="color:Blue;"&gt;set&lt;/span&gt;    @NameString = ltrim(&lt;span style="color:Blue;"&gt;right&lt;/span&gt;(@NameString, len(@NameString) - len(@FirstName)))&lt;br /&gt;&lt;br /&gt;&lt;span style="color:Green;"&gt;--Anything left is MiddleName&lt;br /&gt;&lt;/span&gt;&lt;span style="color:Blue;"&gt;set&lt;/span&gt;    @MiddleName = @NameString&lt;br /&gt;&lt;br /&gt;&lt;span style="color:Green;"&gt;--Build output string&lt;br /&gt;--You will need to add Long/Short versions of Prefixes and Suffixes to the appropreate section&lt;br /&gt;&lt;/span&gt;&lt;span style="color:Blue;"&gt;set&lt;/span&gt;    @TempString = &lt;span style="color:Navy;"&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;while&lt;/span&gt; len(@NameFormat) &amp;gt; 0&lt;br /&gt;&lt;span style="color:Blue;"&gt;begin&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;set&lt;/span&gt; @TempString = @TempString +&lt;br /&gt;    &lt;span style="color:Blue;"&gt;case&lt;/span&gt; ascii(&lt;span style="color:Blue;"&gt;left&lt;/span&gt;(@NameFormat, 1))&lt;br /&gt;        &lt;span style="color:Blue;"&gt;when&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;80&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;then&lt;/span&gt; &lt;span style="color:Blue;"&gt;case&lt;/span&gt; @Prefix&lt;br /&gt;            &lt;span style="color:Blue;"&gt;when&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;Dr&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;then&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;Doctor&amp;#39;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:Blue;"&gt;when&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;Rev&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;then&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;Reverend&amp;#39;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:Blue;"&gt;else&lt;/span&gt; isnull(@Prefix, &lt;span style="color:Navy;"&gt;&amp;#39;&amp;#39;&lt;/span&gt;)&lt;br /&gt;            &lt;span style="color:Blue;"&gt;end&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:Blue;"&gt;when&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;70&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;then&lt;/span&gt; isnull(@FirstName, &lt;span style="color:Navy;"&gt;&amp;#39;&amp;#39;&lt;/span&gt;)&lt;br /&gt;        &lt;span style="color:Blue;"&gt;when&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;77&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;then&lt;/span&gt; isnull(@MiddleName, &lt;span style="color:Navy;"&gt;&amp;#39;&amp;#39;&lt;/span&gt;)&lt;br /&gt;        &lt;span style="color:Blue;"&gt;when&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;76&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;then&lt;/span&gt; isnull(@LastName, &lt;span style="color:Navy;"&gt;&amp;#39;&amp;#39;&lt;/span&gt;)&lt;br /&gt;        &lt;span style="color:Blue;"&gt;when&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;83&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;then&lt;/span&gt; &lt;span style="color:Blue;"&gt;case&lt;/span&gt; @Suffix&lt;br /&gt;            &lt;span style="color:Blue;"&gt;when&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;Jr&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;then&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;Junior&amp;#39;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:Blue;"&gt;when&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;Sr&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;then&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;Senior&amp;#39;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:Blue;"&gt;when&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;Esq&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;then&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;Esquire&amp;#39;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:Blue;"&gt;else&lt;/span&gt; isnull(@Suffix, &lt;span style="color:Navy;"&gt;&amp;#39;&amp;#39;&lt;/span&gt;)&lt;br /&gt;            &lt;span style="color:Blue;"&gt;end&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:Blue;"&gt;when&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;112&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;then&lt;/span&gt; &lt;span style="color:Blue;"&gt;case&lt;/span&gt; @Prefix&lt;br /&gt;            &lt;span style="color:Blue;"&gt;when&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;Doctor&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;then&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;Dr&amp;#39;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:Blue;"&gt;when&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;Reverend&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;then&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;Rev&amp;#39;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:Blue;"&gt;else&lt;/span&gt; isnull(@Prefix, &lt;span style="color:Navy;"&gt;&amp;#39;&amp;#39;&lt;/span&gt;)&lt;br /&gt;            &lt;span style="color:Blue;"&gt;end&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:Blue;"&gt;when&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;102&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;then&lt;/span&gt; isnull(&lt;span style="color:Blue;"&gt;left&lt;/span&gt;(@FirstName, 1), &lt;span style="color:Navy;"&gt;&amp;#39;&amp;#39;&lt;/span&gt;)&lt;br /&gt;        &lt;span style="color:Blue;"&gt;when&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;109&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;then&lt;/span&gt; isnull(&lt;span style="color:Blue;"&gt;left&lt;/span&gt;(@MiddleName, 1), &lt;span style="color:Navy;"&gt;&amp;#39;&amp;#39;&lt;/span&gt;)&lt;br /&gt;        &lt;span style="color:Blue;"&gt;when&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;108&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;then&lt;/span&gt; isnull(&lt;span style="color:Blue;"&gt;left&lt;/span&gt;(@LastName, 1), &lt;span style="color:Navy;"&gt;&amp;#39;&amp;#39;&lt;/span&gt;)&lt;br /&gt;        &lt;span style="color:Blue;"&gt;when&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;115&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;then&lt;/span&gt; &lt;span style="color:Blue;"&gt;case&lt;/span&gt; @Suffix&lt;br /&gt;            &lt;span style="color:Blue;"&gt;when&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;Junior&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;then&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;Jr&amp;#39;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:Blue;"&gt;when&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;Senior&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;then&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;Sr&amp;#39;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:Blue;"&gt;when&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;Esquire&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;then&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;Esq&amp;#39;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:Blue;"&gt;else&lt;/span&gt; isnull(@Suffix, &lt;span style="color:Navy;"&gt;&amp;#39;&amp;#39;&lt;/span&gt;)&lt;br /&gt;            &lt;span style="color:Blue;"&gt;end&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:Blue;"&gt;when&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;46&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;then&lt;/span&gt; &lt;span style="color:Blue;"&gt;case&lt;/span&gt; &lt;span style="color:Blue;"&gt;right&lt;/span&gt;(@TempString, 1)&lt;br /&gt;            &lt;span style="color:Blue;"&gt;when&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39; &amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;then&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:Blue;"&gt;else&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;.&amp;#39;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:Blue;"&gt;end&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:Blue;"&gt;when&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;44&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;then&lt;/span&gt; &lt;span style="color:Blue;"&gt;case&lt;/span&gt; &lt;span style="color:Blue;"&gt;right&lt;/span&gt;(@TempString, 1)&lt;br /&gt;            &lt;span style="color:Blue;"&gt;when&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39; &amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;then&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:Blue;"&gt;else&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;,&amp;#39;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:Blue;"&gt;end&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:Blue;"&gt;when&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;32&amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;then&lt;/span&gt; &lt;span style="color:Blue;"&gt;case&lt;/span&gt; &lt;span style="color:Blue;"&gt;right&lt;/span&gt;(@TempString, 1)&lt;br /&gt;            &lt;span style="color:Blue;"&gt;when&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39; &amp;#39;&lt;/span&gt; &lt;span style="color:Blue;"&gt;then&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:Blue;"&gt;else&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39; &amp;#39;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color:Blue;"&gt;end&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:Blue;"&gt;else&lt;/span&gt; &lt;span style="color:Navy;"&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:Blue;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;set&lt;/span&gt; @NameFormat = &lt;span style="color:Blue;"&gt;right&lt;/span&gt;(@NameFormat, len(@NameFormat) - 1)&lt;br /&gt;&lt;span style="color:Blue;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;Return&lt;/span&gt; @TempString&lt;br /&gt;&lt;span style="color:Blue;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:Blue;"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;  

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;This function will allow you to parse contact values and return them in any way you would like.&amp;nbsp; It&amp;#39;s not all inclusive in terms of available prefixes/suffixes, etc.&amp;nbsp; so, please feel free to use/modify this function as needed for your situation.&lt;/p&gt;
&lt;p&gt;Thanks for reading! &lt;br /&gt;&lt;/p&gt;
  &lt;img src="http://customerfx.com/aggbug.aspx?PostID=42955" width="1" height="1"&gt;</content><author><name>Jason Buss</name><uri>http://customerfx.com/members/Jason-Buss.aspx</uri></author><category term="How-To" scheme="http://customerfx.com/pages/customization/archive/tags/How-To/default.aspx" /><category term="SQL" scheme="http://customerfx.com/pages/customization/archive/tags/SQL/default.aspx" /><category term="Parsing Data" scheme="http://customerfx.com/pages/customization/archive/tags/Parsing+Data/default.aspx" /></entry><entry><title>Setting Billing/Shipping addresses on Insert Salesorder in the SalesLogix Web Client</title><link rel="alternate" type="text/html" href="http://customerfx.com/pages/customization/2010/04/14/Setting-Billing_2F00_Shipping-addresses-on-Insert-Salesorder-in-the-SalesLogix-Web-Client.aspx" /><id>http://customerfx.com/pages/customization/2010/04/14/Setting-Billing_2F00_Shipping-addresses-on-Insert-Salesorder-in-the-SalesLogix-Web-Client.aspx</id><published>2010-04-14T07:09:00Z</published><updated>2010-04-14T07:09:00Z</updated><content type="html">
&lt;p&gt;In a recent SLX Web project, it was requested that I add a contact lookup to the insert SalesOrder view, and when that was set, use the contact&amp;#39;s address for the Shipping and Billing address in the SalesOrder.&amp;nbsp; I was able to add a new Contact property to the SalesOrder and add the lookup to the insert SalesOrder view, but I wasn&amp;#39;t able to reference the new property after it was set.&lt;/p&gt;

&lt;p&gt;It turned out that on the insert form, the Contact property wasn&amp;#39;t actually being written until after the new SalesOrder record was saved.&amp;nbsp;&amp;nbsp; In order to get the selected contact&amp;#39;s address information, I simply referenced the Contact entity returned in the lookup as shown in this sample.&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;This code was added to a C# Snippet action in the OnChange Action event of the new contact lookup.&lt;br /&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Sage.Entity.Interfaces.ISalesOrder salesOrder = BindingSource.Current as Sage.Entity.Interfaces.ISalesOrder;&lt;br /&gt;&lt;b&gt;Sage.Entity.Interfaces.IContact con = lkeContact.LookupResultValue as Sage.Entity.Interfaces.IContact;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;if (salesOrder != null &amp;amp;&amp;amp; con != null &amp;amp;&amp;amp; con.Address != null)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; salesOrder.BillingAddress = salesOrder.SetSalesOrderBillingAddress(con.Address);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; salesOrder.BillingContact = con;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; salesOrder.BillToName = con.NameLF;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; salesOrder.ShippingAddress = salesOrder.SetSalesOrderShippingAddress(con.Address);&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; salesOrder.ShippingContact = con;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; salesOrder.ShipToName = con.NameLF;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;br /&gt;} &lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In addition, I added similar code the OnChange Action of the Account lookup, only instead I set the SalesOrder properties to Null instead.&amp;nbsp; I did this so that if a new Account was selected, a new contact would also need to be selected along with the new address information.&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;Hope you find this example helpful.&amp;nbsp; Thanks for reading!&lt;/p&gt;

&lt;p&gt;-Jason&lt;/p&gt;
&lt;a href="http://www.twitter.com/JasonBussCFX"&gt;&lt;img src="http://twitter-badges.s3.amazonaws.com/follow_me-b.png" alt="Follow JasonBussCFX on Twitter" border="0" /&gt;&lt;/a&gt;&lt;img src="http://customerfx.com/aggbug.aspx?PostID=41660" width="1" height="1"&gt;</content><author><name>Jason Buss</name><uri>http://customerfx.com/members/Jason-Buss.aspx</uri></author><category term="How-To" scheme="http://customerfx.com/pages/customization/archive/tags/How-To/default.aspx" /><category term="SalesLogix Web" scheme="http://customerfx.com/pages/customization/archive/tags/SalesLogix+Web/default.aspx" /></entry><entry><title>Hiding controls and control labels via code in the SalesLogix Web Client.</title><link rel="alternate" type="text/html" href="http://customerfx.com/pages/customization/2010/04/12/hiding-controls-and-control-lables-via-code-in-the-saleslogix-web-client.aspx" /><id>http://customerfx.com/pages/customization/2010/04/12/hiding-controls-and-control-lables-via-code-in-the-saleslogix-web-client.aspx</id><published>2010-04-12T14:21:00Z</published><updated>2010-04-12T14:21:00Z</updated><content type="html">&lt;p&gt;This is a minor item, but one I always seem to forget, so I thought I&amp;#39;d throw it up here quick as a reference...&lt;/p&gt;

&lt;p&gt;On occasion in the web, I want to hide a particular control instead of removing it. If I set this via code snippet in the onload event of the form, it&amp;#39;s a simple matter of just including the line &lt;i&gt;&amp;lt;control&amp;gt;.Visible = False.&amp;nbsp; &lt;/i&gt;If this is all you do, the caption of the control will still display even though the control itself is hidden.&amp;nbsp; In the past, I&amp;#39;ve just cleared out the caption property of the control, but you can hide it by appending &amp;quot;_lbl&amp;quot; to the end of the control name.&amp;nbsp; &lt;/p&gt;

&lt;p&gt;So, along with the line &lt;i&gt;&amp;lt;control&amp;gt;.Visible = False&lt;/i&gt;, you should also include &amp;lt;&lt;i&gt;control&amp;gt;_lbl.False&lt;/i&gt;.&lt;/p&gt;

&lt;p&gt;That&amp;#39;s all there is to it.&amp;nbsp; Pretty straight-forward.&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;Thanks for Reading!&lt;/p&gt;

&lt;p&gt;-Jason&lt;/p&gt;
&lt;a href="http://www.twitter.com/JasonBussCFX"&gt;&lt;img src="http://twitter-badges.s3.amazonaws.com/follow_me-b.png" alt="Follow JasonBussCFX on Twitter" border="0" /&gt;&lt;/a&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;img src="http://customerfx.com/aggbug.aspx?PostID=41649" width="1" height="1"&gt;</content><author><name>Jason Buss</name><uri>http://customerfx.com/members/Jason-Buss.aspx</uri></author><category term="Basics" scheme="http://customerfx.com/pages/customization/archive/tags/Basics/default.aspx" /><category term="How-To" scheme="http://customerfx.com/pages/customization/archive/tags/How-To/default.aspx" /><category term="SalesLogix Web" scheme="http://customerfx.com/pages/customization/archive/tags/SalesLogix+Web/default.aspx" /></entry></feed>