XrmServiceToolkit.Extension Methods

With the integration of jQuery in the latest version of XrmServiceToolkit, some new functions are introduced.

  • JQueryXrmDependentOptionSet: Create Configurable Dependent Option Set to utilize CRM 2011 web resource.
  • JQueryXrmFieldTooltip: Create configurable tooltip for fields on CRM 2011 form
  • JQueryXrmCustomFilterView: Create configurable ability to add custom filter view to crm 2011 lookup field on the form
  • JQueryXrmFormatNotesControl: Format the notes control to allow insert, allow edit

Here is an exmaple of the usage about these methods. The parameter passed is the XML web resource name in your CRM solution. [NOTE] Users will need rights to be able to retrieve web resource for these methods to work

account_onLoad = function () {
    try {
        //Examples about how to use the extension mehtods.
        XrmServiceToolkit.Extension.JQueryXrmFieldTooltip("new_JQueryFieldTooltipConfig");
        XrmServiceToolkit.Extension.JQueryXrmDependentOptionSet("new_JQueryDependentOptionSetConfig");
        XrmServiceToolkit.Extension.JQueryXrmCustomFilterView("new_JQueryLookupCustomFilterViewConfig");
    }
    catch (err) {
        alert(err.message);
    }
};

account_accountcategorycode_onChange = function () {
    try {
        XrmServiceToolkit.Extension.JQueryXrmDependentOptionSet("new_JQueryDependentOptionSetConfig");
    }
    catch (err) {
        alert(err.message);
    }
};

JQueryXrmDependentOptionSet

This function provides a configurable approach to setup dependent optionset in a XML web resource. The origin of the method is from CRM 2011 SDK with the update to use jQuery and move away from passing parameters and also make the method generic to use.

<DependentOptionSetConfig>
  <entity name="account">
    <ParentField id="accountcategorycode" label="Category">
      <DependentField id="accountclassificationcode" label="Classification" />
      <Option value="1" label="Preferred Customer">
        <ShowOption value="1" label="VIP" />
        <ShowOption value="2" label="MVP" />
      </Option>
      <Option value="2" label="Standard">
        <ShowOption value="3" label="International Company" />
        <ShowOption value="4" label="National Wide Company" />
        <ShowOption value="5" label="Private Company" />
      </Option>
    </ParentField>
  </entity>
</DependentOptionSetConfig>

Once the method is called. The result should be like the following attached pictures.

Dependent OptionSet Result

Dependent OptionSet Result 2

JQueryXrmFieldTooltip

This function provides a configurable approach to setup tooltip for crm entity fields. The method was orginated from with modification to support cross browser and generic to use

http://lambrite.com/?p=221

Once the method is called. The result should be like the following attached pictures.

<help>
  <entity name="account">
    <attribute name="name">
      <shorthelp>&lt;br/&gt;&lt;br/&gt;This is the first line&lt;br/&gt;This is the second line</shorthelp>
    </attribute>
  </entity>
</help>

Field Tooltip

JQueryXrmLookupCustomFilterView

This function provides a configurable approach to add custom filter view to a lookup field. The purpose of this method is to provide

  • If the lookup will need to be filtered with certain conditions (filter by the value of standard field,  optionset by value / label. a random lookup id / name.
  • If the lookup (party list) will need to have 'default type' set.

[NOTE] The limitation of this method is obvious. Complex query like "filtered lookup with addtional conditions". Also fields like owner is not working with AddCustomView.

<CustomFilterView>
  <!-- The entity where the lookup field. Add other entity tags for other entities -->
  <entity name="account">
    <!-- Use the template to add filter view for other fields -->
    <targetField id="new_primarycontactid" viewentity="contact" viewname="Filtered Lookup View">
      <dynamic>
        <!-- this section defines the fields for which their values will be used to replace the correspondent fetchnote -->
        <!-- define all the fields if you need to use the values to build the correct fetch XML -->
        <field name="new_originatedcountry" operator="contains" fetchnote="fnCountry"></field>
      </dynamic>
      <!-- using advanced find to get the fetchXml -->
      <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
        <entity name="contact">
          <attribute name="fullname" />
          <attribute name="telephone1" />
          <attribute name="contactid" />
          <order attribute="fullname" descending="false" />
          <filter type="and">
            <condition attribute="new_country" operator="like" value="fnCountry" />
            <condition attribute="statuscode" operator="eq" value="1" />
          </filter>
        </entity>
      </fetch>
      <!-- this is the grid for the view -->
      <grid name="resultset" object="1" jump="contactid" select="1" icon="1" preview="1">
        <row name="result" id="contactid">
          <cell name="fullname" width="200" />
          <cell name="new_country" width="200" />
          <cell name="telephone1" width="200" />
        </row>
      </grid>
    </targetField>
  </entity>
</CustomFilterView>

Once the method is called. The result should be like the following attached pictures.

Custom Filter View for Lookup

Happy Coding!

Jaimie

Last edited Jan 25, 2013 at 1:58 PM by jaimieji, version 13

Comments

No comments yet.