Validating the ticker symbol field

The default ticker symbol field in Dynamics CRM 2011 is integrated with MSN Money to bring up information about the entered symbol. When this symbol is not found, the user is faced with an Information Not Available page. Unfortunately, only the website will validate the user input, not your CRM application. For us to validate the symbols, we need to implement an additional piece of functionality. We can thus prompt the user once they have entered the symbol if the input is not valid.

Getting ready

In order to work through the steps of creating a ticker symbol field, use an existing solution or create a new one.

How to do it...

Perform the following steps to customize a ticker symbol field on an Account form:

  1. Add the Account entity to your solution, if not already added.
  2. Open the main form to customize it.
  3. Create a new field, name it Ticker, and set the Type to Single Line of Text and the Format to Ticker Symbol.
    How to do it...
  4. Add this new field to the form.
  5. Test the form to make sure the new field appears and observe the default behavior. By default, the Ticker Symbol formatting adds a link to the text entered, and forwards the user to Microsoft Money on a click.

    Note

    Please note that out of the box there is no ticker symbol validation. Only when you click on the link, the resulting page will look up the symbol entered, and will bring back the Search page.

  6. Add a new JScript web resource to your project, and add the following function to validate a ticker symbol. Add this function to the OnChange form field event.
    function CheckTicker()
    {
      var tickerValue = Xrm.Page.getAttribute("new_ticker").getValue();
      if(!CheckTicker(tickerValue))
      {
        alert("The Ticker symbol provided does not exist!");
      }
    }
  7. Save and Publish your solution.

How it works...

The function we just presented does nothing more than to read the user input value, and pass it to a custom CheckTicker() function. We are expecting this function to return true if the value is a valid value, or false if not. Please customize this function according to the requirements of your environment. You can use some of the free web services available on the web for this validation, or use an internal application.

There's more...

Re-routing your request to another provider:

For an on-premise deployment, if you want to re-route your request to an internal application that provides ticker information, the configuration for the ticker symbol is located in an HTC file at the following location:

C:Program FilesMicrosoft Dynamics CRMCRMWeb\_static\_formcontrolsINPUT.text.ticker.htc

You can override the JScript function in that file, and replace the line with safeWindowOpen(Mscrm.CrmUri.create(… to point to the URL of your custom application. This way, for an internal deployment where users are blocked from accessing the internet, the ticker link will forward them to your other internal application that provides stock information.

Please note that this customization is not supported, as it works using standard JavaScript and not the Dynamics CRM script API.

See also

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.222.132