Wednesday, December 26, 2012

The import has failed because component new_entityName of type 1 is not declared in the solution file as a root component. To fix this, import again using the XML file that was generated when you exported the solution.

while i was importing a solution by adding a part of the xml for a new entity to the customization.xml file.

what i did is , i just added the entity tag section <Entity> ... </Entity> to the customization.xml file.
then imported. so i got the below error details after downloading the file and seeing...
"The import has failed because component new_entityName of type 1 is not declared in the solution file as a root component. To fix this, import again using the XML file that was generated when you exported the solution."

this says the clear thing that we must add the "new_entityName" to the solution.xml file and declare as a root component.

so open the corresponding solution.xml file and search for the "<RootComponents>" tag and add the below with the tags <RootComponents> and </RootComponents>.
<RootComponent type="1" schemaName="new_entityName" />

now zip the files and try to import , it should import smoothly.

Regards,
yes.sudhanshu

Friday, December 21, 2012

Full name , first name, last name in ms crm in contact

this below observation for contact related to the first name, last name and full name.

normally we know the full name is the primary filed and the value will be automatically combined from first name and last name. last name is business required in the system.

what i experienced is, i was pushing the value by interface code to the full name while creating the contact record. but the value was missing from the full name. (note: i was not pushing sny value to first name and last name).

why this was happening?
as above, the full name is the combined value from full name and last name, so if both are blank then full name is blank. and this happens while saving the record by the system.

so when i was pushing the value to the full name and not to first name and last name (so first name and last name were blank), so the full name were getting updated from first name and last name and was result as blank.

Regards,
yes.sudhanshu
 

currency logic in ms crm 2011

just putting my observations here...
this is on basis of the currency filed type in MS CRM 2011
1. when we create one currency field, the currency lookup will we will get created and two fields get created one with extra as (base)
2. if you just add the currency fields (not the one with Base) and do preview page you will see the field as just a common text field (normally the currency symbol should come)
below image Inventories is the currency field

3. if you just put the Currency look up and select the currency the currency symbol will be populated in the currency filed.
see in the below image
4. if you create from CRM its fine and things will work proper if you assign any value to the currency field(not lookup) so currency symbol(ex $) value will come automatically .
5. how if you have some interface program which is creating the record?
    a. if you create the record and you push any value to the currency field(not look up) then its fine , things are ok
    b. but how if you did not put the value ,means is you have n number of currency fields but none of the fields has any value, then in this scenario, all the currency fields will be shown as textbox, so no currency symbol.
    Why this happened?
cuz, the currency look up field has not been assigned any value there so its showing as text field and if you add any value to the currency(not llok up) field you will get error, 1st assign the currency look up.
   how to solve?
so to hit this, you just get the currency value and assign in the lookup, so that the currency symbol will be shown in the currency fields and teh value can be added. below code is to fetch the currency guid from the system, that configured.

public static Guid GetDefaultCurrencyID(IOrganizationService service)
        {
            Guid CurrencyGuid = Guid.Empty;
 
            QueryExpression query = new QueryExpression(TransactionCurrency.EntityLogicalName);
            query.ColumnSet = new ColumnSet(new string[] { "transactioncurrencyid" });
            query.Orders.Add(new OrderExpression("createdon", OrderType.Ascending));
 
            try
            {
                EntityCollection oEntityCollection = service.RetrieveMultiple(query);
                if (oEntityCollection.Entities.Count > 0)
                {
                    CurrencyGuid = (Guid)oEntityCollection.Entities[0].Id;
                }
            }
            catch (Exception ex)
            {
                Util.ThrowException(ex);
            }
 
            return CurrencyGuid;
        }

hope this will help to anyone in any corner....

today is doomsday... if we pass this day , it will help to many more :P

Regards,
yes.sudhanshu

Sunday, December 9, 2012

Quick way to get the ID(GUID) of record, Dirty Fields in the form and Scema names displayed for each fields in MS CRM 2011

ID(GUID) of Record
the below link really give an awesome way to fetch the ID(GUID) of a record which we mostly need, for any unit testing or other requirements...

http://blog.sonomapartners.com/2012/08/javascript-bookmark-series-part-2.html
script for this is

javascript: var id = frames[0].Xrm.Page.data.entity.getId(); if (id) { clipboardData.setData("Text", id.toString()); alert(id); } else { alert('No id yet!'); }

 Dirty Fields in MS CRM Form
 
use this idea how to fetch the dirty fields(fields that has been changed in the form) from MS CRM form...
script is as below
javascript:var message="The following fields are dirty: \n";window.frames[0].Xrm.Page.data.entity.attributes.forEach(function(attribute,index){if(attribute.getIsDirty()==true){message+="\u2219 "+attribute.getName()+"\n";}});alert(message);
 Get Schema Names use the below link to get the way to find the schema names of the fileds on the form..
script is as below
javascript:frames[0].Xrm.Page.ui.controls.forEach(function(a){a.setLabel(a.getName())});
 how to put in Favorite bar and use it...
just browse to any of the crm pages...
then click Favorites -> Add to Favorite
now go to Favorite and the saved one and right click and then properties...
then in the URL , update the above JS code for diff requirements... and save
 
then when u need this requirement, open the record, then do ctrl + N (to get the Fav bar), then click the item... and it will prompt you the result...
then just click on that aleart window and do ctrl + C(copy command), then paste in notepad to get the result...
 
thats it...
:)

 

Wednesday, December 5, 2012

Sample function using SetStateRequest to deactivate record ms crm 2011

below is the code to deactive the records associated to a particular record.
also the 2nd function is used to deactivate a particular record...

//Diactivate all the Associated Records of the primary records
        public static void DiactivateAllAssociatedRecords(IOrganizationService service, Guid primaryEntityId,
            String relatedEntityName, String lookupName)
        {
            try
            {
                //first get all the GUIDs as per the primaryEntityId
                #region //build the query
                ConditionExpression condition1 = new ConditionExpression();
                condition1.AttributeName = lookupName;
                condition1.Operator = ConditionOperator.Equal;
                condition1.Values.Add(primaryEntityId);
 
                FilterExpression filter1 = new FilterExpression();
                filter1.Conditions.Add(condition1);
 
                QueryExpression query = new QueryExpression();
                query.EntityName = relatedEntityName;
                query.ColumnSet = new ColumnSet(true);
                query.Criteria.AddFilter(filter1);
                #endregion
 
                EntityCollection ecResult = service.RetrieveMultiple(query);
                if (ecResult != null && ecResult.Entities.Count > 0)
                {
                    foreach (Entity eResult in ecResult.Entities)
                    {
//this is the next function called.....
                          DiactivateRecord(service, eResult);
                    }
                }
            }
            catch (SoapException spex)
            {
                throw new Exception("Interface : " + spex.StackTrace);
            }
            catch (Exception ex)
            {
                throw new Exception("Interface : " + ex.StackTrace);
            }
        }

 

//diactivate the record now
        public static void DiactivateRecord(IOrganizationService service, Entity eResult)
        {
            try
            {
                SetStateRequest setState = new SetStateRequest();
                setState.EntityMoniker = new EntityReference(eResult.LogicalName, eResult.Id);
                setState.State = new OptionSetValue();
                setState.State.Value = 1;
                setState.Status = new OptionSetValue();
                setState.Status.Value = -1;
                SetStateResponse setStateResponse = (SetStateResponse)service.Execute(setState);
            }
            catch (SoapException spex)
            {
                throw new Exception("Interface : " + spex.StackTrace);
            }
            catch (Exception ex)
            {
                throw new Exception("Interface : " + ex.StackTrace);
            }
        }

 NOTE: We Can not Deactivate the Address records as there is no option for that... if we do, it will throw the below exception....
"The 'SetStateDynamicEntity' method does not support entities of type 'customeraddress'."

Regards,
Sudhanshu

Sunday, November 4, 2012

Sending e-mail (If an e-mail field does not exist, one will be created) in MS CRM 2011

while creating an entity we used to get one option as "Sending e-mail (If an e-mail field does not exist, one will be created)" in MS CRM 2011 and its newly introduced in MS CRM 2011.

how this works is, this can be used in the eMails activity to send email instead it e-mail ids. so in the dropdown list of to lookup in email activity this custom entity will be listed out.

while creating an entity if you will select it, then one attribute with name "emailaddress" will be created and it will be used to send email.

once this is selected, after that it can not be edited and its clear as, if there is any emials need to be sent are in queue.. it will violete the rules...

but once if u have created the entity latter you can select this option and from then onwards, it will be uneditable and the email will work.

but what does it mean "If an e-mail field does not exist, one will be created" ?
yes its true, if you have created the entity initially with out selecting it, so no default email attribute will be created. but if u select that option and u have already one email attrobute present in any name, then it will  not create any email atribute, so it will take the exiting email attribute...

but how if there is more that one email attribute present in the entity and then we are selecting that option, which email attribute it will consider to use for sending emails....??

i think it will take the 1st email attribute which was created....
anyone has any idea, please share here...
i did not try on this, once i ll try , i will update which email attribute it will consider...

regards,
yes.Sudhanshu

Friday, November 2, 2012

Queue created in MS CRM 2011

how the Queues created in MS CRM 2011, automatically....
if you created any BU, any user or any Team in the CRM system, then a Queue will be get created in the CRM system in the same name of the BU, User or Team automatically....
so initially we must have 2 queues in the name of the Admin and name of the Organisation we are creating.....

but how when we create a bu and same time a team also get created, so this point of time it will not create one queue for the BU and one for the team...

hope its bit clear.... :)

thanks,
yes.sudhanshu

Monday, October 22, 2012

Chart Component Details(create,import,export) MS CRM 2011

Create and Configure System Charts
System charts are organization-owned charts and cannot be assigned or shared.
1.       In the Navigation Pane, click Settings.
2.       Under Customization, click Customizations.
3.       In the Customization area, click Customize the System.
4.       Under Components, expand Entities.
5.       Expand the name of the entity for which you want to create or edit a chart, and then click Charts.
6.       To create a chart, on the Actions toolbar, click New.
- OR -
To edit a chart, click More Actions, and then click Edit.
The Chart Designer opens.
7.       In Record Type View, select a view that you want to use for the chart.
By default, the default view for any record type is displayed in this list. The view selection determines the data for the chart. For example, if you select My Open Accounts as the Record Type View, the chart displays only the data for the open accounts.
8.       Format the chart.
The purpose of this step is to specify the type of chart, and how the data is displayed in the chart.
1.                  Specify which data to display on each axis:
a.                              In the first drop-down list under Legend Entries (Series), select a field to display on the series axis.
b.                              In the Aggregate drop-down list, click the option by which you want to group the field you selected in Legend Entries (Series).
For non-numeric fields, you can only select Count: All or Count: Non-empty. For numeric fields, you can select one of the following aggregation options: Count: All, Count: Non-empty ,Avg, Max, Min, or Sum.
Important
·                                                                NULL values are not considered for computing minimum, maximum, and average of data. However, zeros (0) are considered. For example, if you have the following data:
Topic
Potential Customer
Established Value
Opportunity 1
Account 1
NULL
Opportunity 2
Account 1
250
Opportunity 3
Account 2
0
Opportunity 4
Account 2
250
The average for Account 1 is 250 because the NULL value was not used. The average for Account 2 is 125 because the zero was used.
·                                                                If the records that are used in generating the chart involve multiple currencies, the aggregated data for records used in generating a chart may not be consistent.
For example, you have two accounts, Account1 and Account2. The revenue specified at the time of creating the records for Account1 is 600,000 Indian rupees and Account2 is and 800,000 Japanese yen. The conversion rate when the records are created is 1:60 for the Indian rupees and 1:80 for the Japanese yen. When this revenue is converted to the base currency of US dollars, the revenue becomes 10000 for Account1 and 10000 for Account2.
If you add the amounts, the data in the base currency is 20,000 US dollars.
If the conversion rate changes to 1:40 for the Indian rupees and 1:75 for the Japanese yen, and the user’s default currency is Indian rupees, adding the amounts together in the chart is 800,000 Indian rupees (20000 US dollars ´ 40).
c.                               To create a chart with multiple series, click the Add a series icon , select another field to display on the series axis, and then select an aggregate option for that series.
Note
A multiple series chart can include up to five series items and only one category item.
d.                              To change the chart type for a series, select the series, click the Current chart type icon for that series, and then select a chart type.
e.                              To stack items in a chart, click the chart type, and then click Stacked or 100% Stacked. You can stack items only in a bar, column, or an area chart.
f.                               To display only top items on the chart, click the Top/Bottom Rules icon , then click the Top X Rule icon , and then click 3 or 5, or click Custom to specify a different number. For example, to display only the top three opportunities grouped by potential customers, click the Top/Bottom Rules icon , then click Top X Rule icon , and then click 3.
- OR -
To display only the bottom items on the chart, click the Top/Bottom Rules icon , then click the Bottom X Rule icon , and then click 3 or 5, or click Custom to specify a different number.
Notes
·                                                        When you apply the Top X or Bottom X rule in a chart, items are sorted on the series on which you have applied the top or bottom rule, and then based on the order, the top or bottom items are selected for that series and displayed in the chart.
·                                                        To clear top or bottom rules for a series, click the Clear Rules icon next to that series.
g.                              From the list under Horizontal (Category), select the field to display on the category axis.
h.                              To create a comparison chart with multiple categories, click the Add a category icon , and then select another field to display on the category axis.
Note
A comparison chart can contain only two category items and one series item.
i.                                For fields that are of the datetime type, click the option by which you want to group the field you selected as the category.
The chart is named based on the fields you chose for the series and category axes.
2.                  If you want to specify a different name for the chart, click the chart name to edit it.
3.                  Type a meaningful description for the chart. The description is useful to identify the purpose of the chart.
9.       Click Save.
Important
You can create and attach charts to only those record types in Microsoft Dynamics CRM that support the new ribbon interface in the Web application. This is because all of the chart controls are only present in the ribbon interface of Microsoft Dynamics CRM.
 
Export a system chart
You cannot create complex visualizations such as multi-series charts or comparison charts by using the Microsoft Dynamics CRM Web application. To create complex charts, export the chart, edit the chart definition file, and then import it back into Microsoft Dynamics CRM.
1.       In the Navigation Pane, click Settings.
2.       Under Customization, click Customizations.
3.       In the Customization area, click Customize the System.
4.       Expand the name of the entity that has the chart that you want to export, and then click Charts.
5.       Select the chart that you want to export and on the Actions toolbar, click Actions, and then click Export Chart.
6.       To open the exported chart definition file, click Open.
- OR -
To save the file, click Save.
 
Import system charts
You cannot create complex visualizations such as multi-series charts or comparison charts by using the Microsoft Dynamics CRM Web application. To create complex charts, export the chart, edit the chart definition file, and then import it back into Microsoft Dynamics CRM.
1.       In the Navigation Pane, click Settings.
2.       Under Customization, click Customizations.
3.       In the Customization area, click Customize the System.
4.       Under Components, expand Entities.
5.       Expand the name of the entity to which you want to import the chart, and then click Charts.
6.       On the Actions toolbar, click Actions, and then click Import Chart.
7.       On the Import Chart dialog box, click Browse to select the definition file of the chart that you want to import, and then click OK.
Note
When you import the definition file, Microsoft Dynamics CRM checks the chart definition file for the chart ID, chart name, and the file name in the same order.
If a chart with the same ID already exists in Microsoft Dynamics CRM, you are given the option either to replace the existing chart with a file or to save the chart that you are importing with a new name. If an ID is not specified in the chart definition file, Microsoft Dynamics CRM checks to see if a chart with the same name already exists. If a chart exists with the same name, you are given the option either to replace the existing chart or to save the chart that you are importing with a new name. If both ID and name are not specified, Microsoft Dynamics CRM checks to see if there is a chart with the name same as the file name. If a chart exists with the same name, you are given the option either to replace the existing chart or to save the chart that you are importing with a new name.
If there are two or more existing charts with the same name, you can only import a chart with a new name.
 
note: fetched from help of MS CRM 2011
Regards,
yes.sudhanshu