Search This Blog

Thursday, November 26, 2015

Open Entity form "attributePlatformName" error occur in CRM

Open Entity form "attributePlatformName" error occur in CRM

If you have any doubt in the post please post comments. I will try to solve your problem with in a day.

Goto Settings->Customization->Open Default solution

Open customize the solution.select the entity form that you have error. Here I have issue in open the account form. So I select the account and click forms and click form order
Change managed entity form in the top and click ok and publish customization.

Converting Managed Solutions to Unmanaged Solutions CRM 2013 and 2015

Converting Managed Solutions to Unmanaged Solutions CRM 2013 and 2015

If you have any doubt in the post please post comments. I will try to solve your problem with in a day.

1. Create a new staging organization in Dynamics CRM 2013 (lets say StagingOrg)
2. Import the managed solution you want to convert to unmanaged in this Organization (StagingOrg).
3. Now connect SQL server from the database of StagingOrg and run this Query after changing the name of your managed solution accordingly.
4. It will show some errors after running the script. I ignored them.
5. Now go into Settings > Customizations > Solutions > and export the solution as Unmanaged. Notice that it has become Unmanaged from managed now.
6. Save the zip file and extract it to a folder
7. Open the solution.xml file from the folder and search MissingDependency tag.
8. You will notice lot of MissingDependency elements, remove them all and self close the MissingDependency tag like this <MissingDependency />
9. Zip the files again and now import it to your development environment. Now you can import it as managed or unmanaged wherever you want.

SQL  Script

declare @solutionId uniqueidentifier, @systemSolutionId uniqueidentifier

-- specify the uniquename of the managed solution you'd like to unmanage here it is StagingOrg
select @solutionId = solutionid from SolutionBase where UniqueName='SuperGridSolution'

-- DO NOT TOUCH FROM HERE ON --
select @systemSolutionId = solutionid from SolutionBase where UniqueName='Active'

update PublisherBase set IsReadonly=0
where PublisherId in (select PublisherId from SolutionBase where SolutionId=@solutionId)

print 'updated publisher'


declare @tables table (id int identity, name nvarchar(100), ismanaged bit, issolution bit)
declare @count int, @currentTable nvarchar(100), @currentM bit, @currentS bit, @sql nvarchar(max)

-- go through all the tables that have the ismanaged/solutionid flag, find the related records for the current solution and move them to the crm active solution.
insert into @tables (name, ismanaged, issolution)
select name, 1, 0 from sysobjects where id in
(select id from syscolumns where name in ('IsManaged'))
and type='U'
order by name

insert into @tables (name, ismanaged, issolution)
select name, 0, 1 from sysobjects where id in
(select id from syscolumns where name in ('SolutionId'))
and type='U' and name not in ('SolutionComponentBase') -- ignore this table because it doesn't make a difference. it does cause dependency errors on the exported solution but we can manually edit the xml for that.
order by name

select @count = count(*) from @tables
while (@count > 0)
begin
select @currentTable =name, @currentM =ismanaged, @currentS =issolution from @tables where id=@count

if (@currentM = 1)
begin
select @sql ='update ' + @currentTable + ' set IsManaged=0 where SolutionId=N''' + cast(@solutionId as nvarchar(100)) + ''''
exec (@sql)

print 'updated IsManaged to 0 on: ' + @currentTable
end

if (@currentS = 1)
begin
select @sql ='update ' + @currentTable + ' set SolutionId=N''' + cast(@systemSolutionId as nvarchar(100)) + ''' where SolutionId=N''' + cast(@solutionId as nvarchar(100)) + ''''
exec (@sql)

print 'updated SolutionId on: ' + @currentTable
end

select @count = @count -1, @currentTable = NULL
end

Wednesday, November 25, 2015

Create button in CRM form using javascript with field

Create button in CRM form using javascript with field

If you have any doubt in the post please post comments. I will try to solve your problem.

Step 1:-Add a new attribute of type single line text in CRM form or you may use existing one.

Step 2: Add the fallowing code to your crm java script web resource. And call this function in the form onload.

function MakeButton() { 
        var atrname ="YOUR ATTRIBUTE SCHEMA NAME";// "new_stringtest";
        if (document.getElementById(atrname ) != null) {
        var fieldId = "field" + atrname ;
        if (document.getElementById(fieldId ) == null) {
            var elementId = document.getElementById(atrname + "_d");
            var div = document.createElement("div");
            div.style.width = "100px";
            div.style.textAlign = "right";
            div.style.display = "inline";
            elementId .appendChild(div, elementId );
            div.innerHTML = '<button id="' + fieldId + '"  type="button" style="margin-left: 3px; width: 100%;" >CRM Form Button</button>';
            document.getElementById(atrname).style.width = "0%";
            document.getElementById(fieldId ).onclick = function () { YourOnClickFunction(); };
        }
    }
}

function YourOnClickFunction(){
alert("Hi");

}

Disable autosave particular form in javascript CRM

Disable autosave particular form in javascript CRM

If you have any doubt in the post please post comments. I will try to solve your problem.

  1. Write following JavaScript code in your entity JavaScript file.

                  function preventAutoSave(econtext) {
                        var eventArgs = econtext.getEventArgs();
                       if (eventArgs.getSaveMode() == 70) {
                              eventArgs.preventDefault();
                        }
                  }
  1. In the Form Properties window, in the Event Handlers section, set Event to OnSave.
  2. Click on Add  and choose the above code written JavaScript resource file
  3. In the Handler Properties window, set Library to the web resource you added in the previous step.
  4. Type ‘preventAutoSave’ in the Function field. This is case sensitive. Do not include quotation marks.
  5. Make sure that Enabled is checked.
  6. Check Pass execution context as first parameter.
  7. Click OK to close the Handler Properties dialog.
  8. The Handler Properties dialog should look like this.
  9. AutoSave2
    After you apply this script to the OnSave event, when people edit a record using this form the message unsaved changes will appear in the bottom right corner of the form just as it would if auto-save was not disabled. But this message will not go away until people click the Savebutton next to it.

Tuesday, November 24, 2015

Loop exists in this entity hierarchy.Detail

Loop exists in this entity hierarchy.Detail

If you have any doubt in the post please post comments. I will try to solve your problem.

 ParentId is not a sub account or the same as the account you are setting the parent account on .

Mapping is not working for Quote to Quote product or Order to Order product and as well Opportunity and Invoice

Mapping is not working for Quote to Quote product or Order to Order product and as well Opportunity and Invoice

If you have any doubt in the post please post comments. I will try to solve your problem.

If you use Editable sub-grid, you will not be able to make the mapping working.

This issue is already exist from CRM 2011 to CRM 2015.

To make it works, you need to replace your editable sub-grid to the standard sub-grid, so  the mapping will work well.But editable grid feature is not work.

This is not only for some fields, but for other fields that you have defined in the mapping in the relationship mapping.

Monday, November 23, 2015

CRM Ribbon work bench parameter

CRM Ribbon work bench parameter
If you have any doubt in the post please post comments. I will try to solve your problem.
Value Description
PrimaryEntityTypeCode A number representing the unique type of entity for a specific Microsoft CRM deployment.
PrimaryEntityTypeName A string representing the unique name of an entity.
PrimaryItemIds A string array providing the GUID Id values for the Primary Item.
FirstPrimaryItemId Provides one GUID identifier as a string for the record being viewed.
PrimaryControl An Object referencing the Control that had focus when the Ribbon Command action occurred.
PrimaryControlId A string providing the Id value of the control that had focus.
SelectedEntityTypeCode A number representing the unique type of entity for a record selected in a grid. The Entity type code will vary between deployments.
SelectedEntityTypeName A string representing the unique name of the entity for a record selected in a grid.
FirstSelectedItemId Provides one GUID identifier as a string for the first item selected in a grid.
SelectedControl An Object referencing the Control that had focus when the Ribbon Command action occurred.
SelectedControlSelectedItemCount The number of selected items in a grid.
SelectedControlSelectedItemIds A string array of GUID Id values for all selected items in a grid.
SelectedControlSelectedItemReferences An array of EntityReference objects that represent all the selected items in the grid. This option is only available when used with the<JavaScriptFunction> (RibbonDiffXml) element.
SelectedControlAllItemCount A number showing the total number of items displayed in a grid.
SelectedControlAllItemIds A string array providing the GUID Id values for all items displayed in a grid.
SelectedControlAllItemReferences An array of EntityReference objects representing all the items in the grid. This option is only available when used with the<JavaScriptFunction> (RibbonDiffXml) element.
SelectedControlUnselectedItemCount The number of unselected items in a grid.
SelectedControlUnselectedItemIds A string array of GUID Id values for all unselected items in a grid.
SelectedControlUnselectedItemReferences An array of EntityReference objects representing all the items not selected in the grid. This option is only available when used with the<JavaScriptFunction> (RibbonDiffXml) element.
OrgName The name of the organization.
OrgLcid The Language Code representing the base Language for the organization.
UserLcid The Language Code representing the language preference chosen by the user..
Access other control in ribbon work bench javascript
var objValue= Xrm.Page.ui.controls.get(controlname).getAttribute().getValue()
or
var objValue= Xrm.Page..getAttribute(controlname).getValue()

Sunday, November 22, 2015

Get Entity/Object type code in CRM using javascript

Get Entity/Object type code in CRM using javascript

If you have any doubt in the post please post comments. I will try to solve your problem.

If you need the entity type code for the all form include custom form.

Mscrm.EntityPropUtil.EntityTypeName2CodeMap["account"]

or

Mscrm.EntityPropUtil.EntityTypeName2CodeMap.account

How to open the form using javascript with parameters

Open new entity form using javascript

If you have any doubt in the post please post comments. I will try to solve your problem.

Syntax:
Xrm.Utility.openEntityForm( entityName, id, parameters);

entityName:Name of the entity name
id:Id of the existing record open
parameters: value to be fill when form open

Example:To open a new form in CRM through javascript

var parameters={};
//Set text in the Description field.
 parameters["description"] = "Default values for this record were set programmatically.";
 //Set optionsSet value
 parameters["accountlookup"] = "2878282E-94D6-E111-9B1D-00155D9D700B";
 //Set optionsSet value
 parameters["address1_addresstypecode"] = "3";


Xrm.Utility.openEntityForm( "quote" , null , parameters);

Enable “Allow to use Credentials for Email Processing” in CRM

Enable “Allow to use Credentials for Email Processing” in CRM

If you have any doubt in the post please post comments. I will try to solve your problem.

To enable this option by adding a register key, we can add register key manually or can use power shell command to add registry key for us. Following are the step required to add it using power shell commands

Start Power Shell editor (Navigate to Run->Powershell)
Use following commands in powershell editor

  •   Add-PSSnapin Microsoft.Crm.PowerShell
  •  $setting=Get-CrmSetting ServerSideSyncEmailSettings
  • $setting.AllowCredentialsEntryViaNonSecureChannels=$True
  •  Set-CrmSetting $setting
  •  Get-CrmSetting TraceSettings

Close power shell editor
Click Ok to close and do IISRESET
Now navigate to mailbox record in crm, you should get “Allow to use Credentials for Email Processing”enabled.
users

CRM Plugin Introduction and Execution Pipeline Message explanation

If you have any doubt in the post please post comments. I will try to solve your problem.

Plug-ins are handlers for events fired by Microsoft Dynamics CRM. It  is to enhance or modify the standard features/behavior of CRM by injecting custom business logic into the execution of nearly any task a user performs in CRM.

Plugin code can be triggered to run when a record is created or updated or perhaps even when a group of records are queried. 

The messages are processed by the Microsoft Dynamics CRM execution pipeline for the plug-in to execute.
There are four event execution stages of pipeline that we configure a plugin to trigger

  • Pre-validation
  • Pre-Operation
  • Post-Operation(Synchronous)
  • Post-Operation(ASynchronous)

Pre-validation:
It will trigger your plugin will run before the form is validated 
Pre -operation:
It will trigger your plugin will run  after validation and before the values are saved to the database
Post operation :
It will trigger your plugin will run after the values have been inserted/changed on the database and changes reflect to the UI immedietly because the form will wait once the plugin complete its work.
Post operation Asynchronous:
It will trigger  your plugin will run after the values have been inserted/changed on the database and changes has to reflect quite some time because the plugin in process in background
Message:
It is processed by the Microsoft Dynamics CRM execution pipeline for the plug-in to execute.
The following are some of the important message.

Create:
This message is helps to trigger the plugin whenever new record is created

Plugin parameter when fire:

Context.InputParameter:

  • Target-It contains entity object

Update:
This message is helps to trigger the plugin whenever existing record is updated

Plugin parameter when fire:

Context.InputParameter:

  • Target-It contains entity object

RetrievedMultiple:
This message is helps to trigger the plugin whenever multiple records is return to the CRM(grid display,lookup control data populate.

Plugin parameter when fire:

Context.InputParameter:

  • It contains fetch xml query

Context.OutputParameter:

  • It is only available at post-operation event 
  • Only synchronous post-event and asynchronous registered plug-ins have OutputParameters populated as the response is the result of the core platform operation.
  • It contains BusinessEntityCollectio that means output of the fetch xml query entity record set(rows data).

Example:
If you want to display "name" column as concatenating  first name and last name in the entity grid. 
Configure Plugin:
Message name:Retrieved multiple
PrimaryEntity: Entity
Operation: post-operation (synch)
Plugin code
   Get the data from context.outputParameter["BusinessEntityCollection"]
   and change the value inside list by concatenating  first name and last name.
PublishAllCustomization:
This message is helps to trigger the plugin whenever you click publish button in CRM

GrantAccess-Share
This message is helps to trigger the record is share

InputParameter
context.InputParameters["PrincipalAccess"] Example:

 //Obtain the principal access object from the input parameter
                Microsoft.Crm.Sdk.Messages.PrincipalAccess PrincipalAccess = (Microsoft.Crm.Sdk.Messages.PrincipalAccess)context.InputParameters["PrincipalAccess"];
                //Then got the User or Team and also Access Control that being Granted
                //***to Get User/Team that being Shared With
                var userOrTeam = PrincipalAccess.Principal;
                var userOrTeamId = userOrTeam.Id;
                var userOrTeamName = userOrTeam.Name;
//this userOrTeam.Name will be blank since entityReference only will give you ID
                var userOrTeamLogicalName = userOrTeam.LogicalName;
RevokeAccess-Unshare
This message is helps to trigger the record is unshare


InputParametercontext.InputParameters["Revokee"]

Example:

//Unshare does not have PrincipalAccess because it removes all, only can get the revokee
                //Obtain the principal access object from the input parameter
                var Revokee = (EntityReference)context.InputParameters["Revokee"];
                var RevokeeId = Revokee.Id;

                var RevokeeLogicalName = Revokee.LogicalName; //this one Team or User