Pages

Tuesday, May 25, 2010

ASP.NET Server tags

<% ... %> Embedded Code Blocks

http://msdn2.microsoft.com/en-us/library/ms178135(vs.80).aspx

<%= ... %> Response.Write shorthand

http://msdn2.microsoft.com/en-us/library/6dwsdcf5(VS.71).aspx

<%# ... %> Data-binding expression

http://msdn2.microsoft.com/en-us/library/ms178366.aspx

<%$ ... %> Runtime expression

<%@ ... %> Directives

http://msdn2.microsoft.com/en-us/library/xz702w3e(VS.80).aspx

<%-- ... --%> Server side comment

http://msdn2.microsoft.com/en-us/library/4acf8afk.aspx

Thursday, May 20, 2010

Using jQuery to show assigned tabindex

This is a bit crude but I've found it useful for debugging tabindex attributes

$(document).ready(function(){
       
     $('[tabindex]').each(function () {
             $(this).after('<span style="background-color:red;color:white;">' + $(this).attr('tabindex') + '</span>');
         });
 });

Sunday, May 16, 2010

BinaryFormatter versus XmlElement

Ran into an issue trying to store a Web Reference tool generated class in ViewState that had an internal XmlElement array.

System.Runtime.Serialization.SerializationException: Type 'System.Xml.XmlElement' in Assembly 'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.

One possible solution would be to create a ISerializationSurrogate that gets added to the BinaryFormatter.SurrogateSelector (example). However, it isn't clear how this would work with ViewState serilization (I.e. where to plug it in?).

Instead I extended the partial class created by the web reference tool so that it implemented ISerializable. Then using the GetObjectData method and a custom deserilization constructor I stored the OuterXml of the XmlElement at a string.

Saturday, May 15, 2010

S4S web.config settings to use the Sandbox API

The following web.config applicationSettings can be used to override the default Partner API URL for S4S.

Note: The setting names will alter with updates to S4S as the Salesforce Partner API is updated.

    <configSections>
        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="FuseIT.Sitecore.SalesforceConnector.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
        </sectionGroup>
    </configSections>
    <applicationSettings>
        <FuseIT.Sitecore.SalesforceConnector.Properties.Settings>
            <setting name="Sitecore_Salesforce_SalesforcePartner170_SforceService"
                serializeAs="String">
                <value>https://test.salesforce.com/services/Soap/u/17.0</value>
            </setting>
            <setting name="FuseIT_Sitecore_SalesforceConnector_SalesforceMetadata160_MetadataService"
                serializeAs="String">
                <value>https://ap1-api.salesforce.com/services/Soap/m/16.0</value>
            </setting>
        </FuseIT.Sitecore.SalesforceConnector.Properties.Settings>
    </applicationSettings>

As of 1.4 the preferred approach is to change the binding environment in the connection string. E.g.

<connectionStrings>
  <add name="S4SConnString" connectionString="S4S:user id=user_name;password=user_password;token=user_security_token;environment=Sandbox" />
</connectionStrings>

Key

Description

user id

The Salesforce user name that will be used to establish the Partner API session

password

The password for the Partner API user. If the servers IP address isn’t trusted by the Salesforce Organization being connected to the users security token can be appended to the password.

token

(Optional) As an alternative to appending the users security token to the password in the connection string it can be defined separately to provide the same functionality.

environment

(Optional) The type of Salesforce environment being connected to. Defaults to Production if unspecified which will also work for developer edition organizations if required.

Possible values:

  • Production
  • DeveloperEdition
  • Sandbox
  • Pre_release

Friday, May 14, 2010

Salesforce - Eclipse Schema Explorer

  1. Install the Eclipse IDE
  2. Install the Force.com IDE Add-on
  3. Create a new Project linked to a Salesforce instance
  4. Help Docs

    To open the Schema Explorer

    1. In the Package Explorer, expand the node for your Force.com project.
    2. Double-click salesforce.schema.
    To create a query:
    1. Expand the Schema objects in the hierarchical tree and select the objects or fields you want to query on.
    2. Click Run Me.
    3. You can also create a query by entering SOQL directly in the Query Results window. For example, to search for all the accounts in your organization that start with the letter B, enter the following SOQL query:
      SELECT Name FROM Account WHERE Name LIKE 'B%'

Wednesday, May 5, 2010

Stopping a run away Visual Studio build

To stop a build in progress use ctrl + break (as found on Steven Harman's blog)

Alternatively, add a Macro (Visual Studio -> Tools -> Macros -> Macro IDE... or ALT+F11) that will stop the solution build when a project fails to build. This can save a lot of time when all the subsequent projects will fail.

Private Sub BuildEvents_OnBuildProjConfigDone(ByVal Project As String, ByVal ProjectConfig As String, ByVal Platform As String, ByVal SolutionConfig As String, ByVal Success As Boolean) Handles BuildEvents.OnBuildProjConfigDone

        If Success = False Then
            ' Stop the build when the first project fails to build.
            DTE.ExecuteCommand("Build.Cancel")
        End If

    End Sub

See also: