using Alias in MS CRM

When we are retrieving linked entity related information using FetchXML or Query expression we are using alias attribute to identify the linked entity attributes. Alias name is prefixed to all linked entity attributes.

Below code snippet will give more information on how to use alias in FetchXML.





string 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' />
                                    <attribute name='middlename' />
                                    <attribute name='lastname' />
                                    <attribute name='firstname' />
                                    <order attribute='fullname' descending='false' />
                                    <link-entity name='account' from='accountid' to='parentcustomerid' visible='false' link-type='outer' alias='AliasAccountName'>
                                      <attribute name='donotphone' />
                                      <attribute name='accountclassificationcode' />
                                      <attribute name='createdon' />
                                      <attribute name='crisp_balance' />
                                    </link-entity>
                                  </entity>
                                </fetch>
                                ";
 FetchExpression fetchExpression = new FetchExpression(fetchXML);
 EntityCollection fetchCollection = service.RetrieveMultiple(fetchExpression);

Here “service” is an organization service. Click here for more information on how to create organization service

After you run above fetchxml, the way we are reading account related attributes are bit different than customer related attributes.

Reading alias values for different datatypes:

OptionSet Value:

int aliasOptionsetValue = ((OptionSetValue)((AliasedValue)fetchCollection.Entities[0].Attributes["AliasAccountName .new_status"]).Value).Value;

Lookup:

Guid aliasstateGuid = ((EntityReference)fetchCollection.Entities[0].Attributes["AliasAccountName.crisp_state"]).Id;

string aliasstateName = ((EntityReference)fetchCollection.Entities[0].Attributes["AliasAccountName.crisp_state"]).Name

Money:

decimal aliasamt = ((Money)fetchCollection.Entities[0].Attributes["AliasAccountName.new_balance"]).Value;

Boolean:

bool aliasisactive = Convert.ToBoolean(fetchCollection.Entities[0].Attributes["AliasAccountName.new_isactive"]);

String:

string aliasString = ((AliasedValue)fetchCollection.Entities[0].Attributes["AliasAccountName.new_name"]).Value.ToString();





You may like below posts

Improving MS CRM Performance

Performance Center in MS CRM 2013

date and time field behavior in MS CRM

Upsert in MSCRM

Locking mechanism in MS CRM

Ticker Symbol Field in MS CRM

Themes in MS CRM

Enable Tracing in MS CRM

Calculated Field in Dynamics CRM 2015


IME Mode in MS CRM

Retrieve all entities and attributes metadata in MS CRM

             
Below code snippet will retrieve all entities metadata which includes it's attributes metadata as well.


              RetrieveAllEntitiesRequest metaDataRequest = new RetrieveAllEntitiesRequest();
                RetrieveAllEntitiesResponse metaDataResponse = new RetrieveAllEntitiesResponse();
                metaDataRequest.EntityFilters = EntityFilters.All;

                // Execute the request.

                metaDataResponse = (RetrieveAllEntitiesResponse)service.Execute(metaDataRequest);

              List<EntityMetadata>   entities = metaDataResponse.EntityMetadata.ToList();




Note: "service" is nothing but an organization service you are going to create and you need to include below namespaces...

using Microsoft.Xrm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Metadata;



You may like below posts

Improving MS CRM Performance

Performance Center in MS CRM 2013

date and time field behavior in MS CRM

Upsert in MSCRM

Locking mechanism in MS CRM

Ticker Symbol Field in MS CRM

Themes in MS CRM

Enable Tracing in MS CRM

Calculated Field in Dynamics CRM 2015

IME Mode in MS CRM

Can we register image to custom action in MS CRM?

Answer is No. we can not register images to actions. We can only register images to pre-defined messages like Create, Update, Delete etc.



If you are looking for any attribute values through images, the only options are passing that attribute value as Input parameter or you can write down a fetch xml or Query expression to retrieve those values.




You may like below posts

Improving MS CRM Performance

Performance Center in MS CRM 2013

date and time field behavior in MS CRM

Upsert in MSCRM

Locking mechanism in MS CRM

Ticker Symbol Field in MS CRM

Themes in MS CRM

Enable Tracing in MS CRM

Calculated Field in Dynamics CRM 2015

IME Mode in MS CRM

Get or Set values of all data types using javascript in MS CRM




Single Line of Text or Multi Line of Text:

Set:

Xrm.Page.getAttribute("attribute logical name").setValue("Test");

Get:

Xrm.Page.getAttribute("attribute logical name").getValue();


Two Options:

Set:

Xrm.Page.getAttribute("attribute logical name").setValue(1);

Two options will accept either 1 or 0.

Get:

Xrm.Page.getAttribute("attribute logical name").getValue();

Above code snippet will return “true” in case set value is “1” and “false” if set value is “0”

Xrm.Page.getAttribute("attribute logical name ").getText();

This code snippet will returns the text we have selected.

OptionSet:

Set:

Xrm.Page.getAttribute("attribute logical name").setValue(1);

Get:

Xrm.Page.getAttribute("attribute logical name").getValue();

Above code snippet will return the selected option value.

Xrm.Page.getAttribute("attribute logical name ").getText();

Above code snippet will returns the text of option we have selected.

DateTime:

Set:

Xrm.Page.getAttribute("attribute logical name ").setValue(new Date("12-31-2014"));

Get:

Xrm.Page.getAttribute("attribute logical name ").getValue();


Lookup:

Set:

Xrm.Page.getAttribute("lookupname").setValue([{ id: "record Guid", name: "record name (Optional)", entityType: "entity logical name" }]);


Get:

var lookupVar = Xrm.Page.getAttribute("attribute logical name").getValue();

var ID= lookupVar[0].id;

var Name= lookupVar[0].name;

var LogicalName= lookupVar[0].entityType;


Currency or Decimal:

Set:

Xrm.Page.getAttribute("attribute logical name").setValue("100.00");

Get:

Xrm.Page.getAttribute("attribute logical name").getValue();

Retrieve all attributes using FetchXML in MS CRM




Below code snippets gives an example on how to retrieve all the attributes from an entity using fetch xml.

<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false' count='1'>
  <entity name='new_account'>
    <all-attributes />
    <order attribute='createdon' descending='true' />
    <filter type='and'>
      <condition attribute='new_name' operator='eq' value='Test' />
    </filter>
  </entity>

</fetch>

<all-attributes />  will fetch you all attributes in fetch XML.








Ticker Symbol Field in MS CRM




Ticker Symbol is the new feature we are having in MS CRM 2015. This is very useful when we want to navigate the link to respective stocks.


Ticker Symbol:   This creates a stock ticker symbol in all capital letters. Click the symbol to open information about the stock in the user's default browser. By default, the MSN website opens.


Below is the small screen I have developed, and entered Ticker Symbol as “GE”. When I click on this link, it will navigate you to second screen which will have all stock’s related information of GE
















































You may like below posts

Improving MS CRM Performance

Performance Center in MS CRM 2013

date and time field behavior in MS CRM

Upsert in MSCRM

Locking mechanism in MS CRM

Themes in MS CRM

Enable Tracing in MS CRM

Calculated Field in Dynamics CRM 2015


IME Mode in MS CRM

Themes in MS CRM





With MS CRM 2015 udpate 1, we get a new feature of Theme under Customizations as shown below screen.











With this feature we can change the Theme of CRM screen as we required. Once we click on Theme, it will navigate you to the Themes view and there we can add new theme. Below is the sample theme I have created.


















Once all the colors have been configured we can check the preview of the screen by clicking on “Preview” button on command bar. For my sample them, screen will be looks like below.


You can exit from the preview by clicking on Exit Preview button and if everything is looks good , you can publish the Theme by clicking on Publish button.
























You may like below posts

Improving MS CRM Performance

Performance Center in MS CRM 2013

date and time field behavior in MS CRM

Upsert in MSCRM

Locking mechanism in MS CRM

Ticker Symbol Field in MS CRM

Enable Tracing in MS CRM

Calculated Field in Dynamics CRM 2015


IME Mode in MS CRM

Featured Post

Improving MS CRM Performance

Performance on MS CRM is always a crucial thing and we may follow different ways to achieve the performance thing. Below is the one more a...