Wednesday, March 25, 2015

Access Quick View Form values in JavaScript

Generally if want to access any control or attribute in CRM form script you will use control or attribute name.. For Quick form it is little bit complicated.

If I have Quick form for custom entity new_manufacture, and I added this quick form in new_car entity form.

To access new_manufacturer quick form in car entity form I need to use Quick form name, entity name and attribute name to get value.

To access in JavaScript Quick view, control name should be like
QuickFormname_QuickFormname_EntityName_AttributeName



My Quick Form name is : manufactureQuickView
Entity Name : new_manufacture
Attribute: new_Country

if (Xrm.Page.getControl('manufactureQuickView_manufactureQuickView_new_manufacture_new_Country') != null)
{
            var manfCountyctrl = Xrm.Page.getControl('manufactureQuickView_manufactureQuickView_new_manufacture_new_Country');
            var country = manfCountyctrl.getAttribute().getValue();


        }


Tuesday, March 24, 2015

Show Parent and child together..MS CRM view sorting without column in view

MS CRM allows view to be sorted by columns which are in view only.. but some time we don't want to show column in view but want to sort view by that column.


I have a situation in contact view.. I have contacts who has child contact records and in view I want to show parent and child contact records together.




For this I added one column in contact entity - Contact number (text), and I am numbering contacts are like
1. Parent - 01
   Child 1 - 011, child 2 - 012
2. Parent 02
   Child 1 - 021, child 2 - 022, Child 3 - 023

I added this contact number column in my view and then able to sort as per requirement.



But customer don't want to see the contact number column in grid, but wants the same sorting..

To achieve this I exported contact entity customization. and looked into Saved query for this view.
Saved query has layout xml and fetchxml.

First I removed Contact number column from layout xml.

<layoutxml >
  <grid name="resultset" object="2" jump="fullname" select="1" icon="1" preview="1">
    <row name="result" id="contactid">
      <cell name="new_contactnumber" width="300" / >
      <cell name="fullname" width="300" / >
      <cell name="emailaddress1" width="150" / >
      <cell name="parentcustomerid" width="150" / >
      <cell name="telephone1" width="125" / >
    </row>
  </ grid>

</ layoutxml>

Then I looked at fetch xml, it has order node..

<fetchxml>
  <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
    <entity name="contact">
      <attribute name="fullname" / >
      <attribute name="parentcustomerid" / >
      <attribute name="telephone1" / >
      <attribute name="emailaddress1" / >
      <order attribute="fullname" descending="false" / >
      <filter type="and">
        <condition attribute="ownerid" operator="eq-userid" / >
        <condition attribute="statecode" operator="eq" value="0" / >
        <condition attribute="createdon" operator="today" / >
      </filter>
      <attribute name="new_contactnumber" / >
      <attribute name="contactid" / >
    </entity>
  </ fetch>

</ fetchxml>

I changed this order node as

      <order attribute=" new_contactnumber " descending="false" / >

Saved customization and imported back to CRM.. and Published customization..
Now my view is  showing same sorting and no contact number column in it..




Monday, March 23, 2015

Show Or Hide Entity Image and Navigation Items form Entity Form

For Entity forms don't want to show Entity Image or Navigation items, Microsoft provided this setting in Form Properties.

Open Form in customization,
Click on Form properties.
In Display tab you will see two sections - Page navigation & Image,



Page navigation - Show navigation Items is default checked.. means show navigation items, when any record opened in this form. If you uncheck this checkbox, then navigation items will not be shown.



Image - Show image in Form is also default checked, Entity Image will be shown on form, when it is unchecked, entity image will not be shown for record when this form is used to open record.