Friday, November 23, 2018

Fetch Marketing List of a campaign with C# plugin in Dynamic 365 CRM


How to fetch the marketing lists associated with a campaign or campaign activity in Dynamic 365 CRM?

Within Dynamics 365 CRM, there are a number of entities that have N:N relationships. One of these is the CampaignItem entity that connects Campaigns, Marketing Lists, Products and Sales Literature.

I have created a generic method below in C# with detail explanations.



Here is how I am invoking my method

EntityCollection DynamicMarketingLists =
    GetManytoManyRelationShip(CampaignActivityId,
                                    "list",
                                    "listid",
                                    "campaignactivitylist_association",
                                    "campaignactivity",
                                    "subject",
                                    _service);




Here is method definition


private EntityCollection GetManytoManyRelationShip(
    Guid entityBGuid,
    string offenceEntityName,
    string offenceColumnSet,                                                            
    string relationShipName,
    string legalEntityName,
    string legalColumnSet,                                                            
    IOrganizationService _service)
{
 QueryExpression query = new QueryExpression(offenceEntityName);
 ColumnSet cols = new ColumnSet();
 cols.AddColumn(offenceColumnSet);
 cols.AddColumn("listname");
 query.ColumnSet = cols;

 Relationship relationship = new Relationship(relationShipName);
 RelationshipQueryCollection relationshipColl = new  RelationshipQueryCollection();
 relationshipColl.Add(relationship, query);

 RetrieveRequest request = new RetrieveRequest();
 request.RelatedEntitiesQuery = relationshipColl;
 request.Target = new EntityReference(legalEntityName, entityBGuid);
 request.ColumnSet = new ColumnSet(legalColumnSet);
 RetrieveResponse response = (RetrieveResponse)_service.Execute(request);

 return response.Entity.RelatedEntities[relationship];
}











Thanks.
Vipin Jaiswal
Vipinjaiswal12@gmail.com

Wednesday, November 7, 2018

Export Solution from MSCRM version 9 and import in version 8



One of my colleague who was remotely supporting me with some customizations was not able to access CRM environment, so he suggested to developed thing on free trail of Dynamic CRM and later to import customizations. He has done customization in specific solution in CRM Online version 9.

We realized that the target environment is version 8 and of On-Premise, CRM by default does not support later version to be imported to old version.

In order to save ourselves with lot of rework, we took some time to import solution by making certain changes in customizations.xml and solution.xml and yeah it work.

Here are list of changes we did.

1) Remove following Tag’s from customizations.xml

<IsDataSourceSecret>0</IsDataSourceSecret>

<AutoNumberFormat></AutoNumberFormat>

<IsBPFEntity>0</IsBPFEntity>

<IsRetrieveAuditEnabled>0</IsRetrieveAuditEnabled>

<IsRetrieveMultipleAuditEnabled>0</IsRetrieveMultipleAuditEnabled>

<EntityDataProviders />

<IsVisibleInMobile>1</IsVisibleInMobile>
         
<IsVisibleInMobileClient>1</IsVisibleInMobileClient>

<IsReadOnlyInMobileClient>0</IsReadOnlyInMobileClient>

<IsOfflineInMobileClient>0</IsOfflineInMobileClient>

<MobileOfflineFilters></MobileOfflineFilters>


2) Remove ExternalValue="" and Color="#0000ffAttribute from <option> tag in customizations.xml




As old version of dynamic CRM does not support these attributes for optionset.


3) Add <ObjectTypeCode> tag in customizations.xml for all entities listed as highlighted in below image.





Object type code should be specific to entity being used.

Later version of Dynamic CRM expect this tag under
Entities >> Entity >> Name >> ObjectTypeCode.


4) In Solution.xml file we need to change the value of attributes of very first Tag <ImportExportXml> with respect to the target environment.

As an example, this is what it looks like when it is Dynamic CRM version 9.1

<ImportExportXml version="9.1.0.626" SolutionPackageVersion="9.1" languagecode="1033" generatedBy="CrmLive" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

In my Case I need to change it to following one.

<ImportExportXml version="8.1.0000.0359" SolutionPackageVersion="8.1" languagecode="1033" generatedBy="OnPremise" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

Just a warning note, this may not be the best practise or a supported way from Microsoft Dynamic CRM.

In addition, while doing this there could be more errors that needed to be resolved.

However, we have created hundreds of fields and we do not want to repeat the process of making the fields in Dynamic CRM again, so this help us a lot in saving our time.

Please let me know what other errors in your scenario you getting.

Thanks,
Vipin Jaiswal
vipinjaiswal12@gmail.com

Wednesday, October 17, 2018

How to Find SharePoint Version installed


While SharePoint does not have a version button or about box with version info, there are a few distinctive features on each version. Unfortunately, you will not always see these features if an administrator and site designer has heavily customized the site. 
We can find the version using Power Shell
You must be a SharePoint farm administrator with Shell Admin rights.
ASNP Microsoft.SharePoint.Powershell
(Get-SPFarm).Products

Please note: You may encounter below exceptions while executing PowerShell commands even if you are SharePoint farm administrator
Add-SPShellAdmin: Cannot access the local farm. Verify that the local farm is properly configured, currently available, and that you have the appropriate permissions to access the database before trying again.

PowerShell: The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered.

This is because you do not have Shell Admin rights. Here you need to Provide Shell Admin right to the user from which you might be looking for SharePoint version. Here is a syntax to provide rights

Syntax : Add-SPShellAdmin -UserName Domain\User


Let’s now proceed with executing Powershell commands to get the SharePoint Version.




This returns a list of GUIDs related to what specific Microsoft Server products installed:

To figure out what these GUIDs mean, please refer to the table below.
VALUE
PRODUCT
84902853-59F6-4B20-BC7C-DE4F419FEFAD
Project Server 2010 Trial
ED21638F-97FF-4A65-AD9B-6889B93065E2
Project Server 2010
BC4C1C97-9013-4033-A0DD-9DC9E6D6C887
Search Server 2010 Trial
08460AA2-A176-442C-BDCA-26928704D80B
Search Server 2010
BEED1F75-C398-4447-AEF1-E66E1F0DF91E
SharePoint Foundation 2010
1328E89E-7EC8-4F7E-809E-7E945796E511
Search Server Express 2010
B2C0B444-3914-4ACB-A0B8-7CF50A8F7AA0
SharePoint Server 2010 Standard Trial
3FDFBCC8-B3E4-4482-91FA-122C6432805C
SharePoint Server 2010 Standard
88BED06D-8C6B-4E62-AB01-546D6005FE97
SharePoint Server 2010 Enterprise Trial
D5595F62-449B-4061-B0B2-0CBAD410BB51
SharePoint Server 2010 Enterprise
926E4E17-087B-47D1-8BD7-91A394BC6196
Office Web Applications 2010
35466B1A-B17B-4DFB-A703-F74E2A1F5F5E
Project Server 2013
BC7BAF08-4D97-462C-8411-341052402E71
Project Server 2013 Preview
9FF54EBC-8C12-47D7-854F-3865D4BE8118
SharePoint Foundation 2013
C5D855EE-F32B-4A1C-97A8-F0A28CE02F9C
SharePoint Server 2013 Standard
B7D84C2B-0754-49E4-B7BE-7EE321DCE0A9
SharePoint Server 2013 Enterprise
D6B57A0D-AE69-4A3E-B031-1F993EE52EDC
Microsoft Office Web Apps Server 2013

In my case, I have following 
9FF54EBC-8C12-47D7-854F-3865D4BE8118
SharePoint Foundation 2013
B7D84C2B-0754-49E4-B7BE-7EE321DCE0A9
SharePoint Server 2013 Enterprise

Refer more articles related to SharePoint and Dynamic CRM




Regards,
Vipin Jaiswal
vipinjaiswal12@gmail.com

Wednesday, October 3, 2018

The plug-in execution failed because the Sandbox Client encountered an error during initialization.


There are certain out-of-box Dynamic CRM plugins, which executed by CRM Sandbox Service only. I came to know about one such scenario where I was changing the security role of a user in dynamic CRM and an exception message flashes on screen.

I would like to share my investigation here so that we have a structured approach to resolve an issue.

This is for CRM 2016 On-Premise….

Other Similar exception message you might encountered

The plug-in execution failed because no Sandbox Hosts are currently available. Please check that you have a Sandbox server configured and that it is running.


In the Event Viewer, I was getting following exceptions for SOURCE : MSCRMSandboxClient

The TransportManager failed to listen on the supplied URI using the NetTcpPortSharing service: failed to start the service (5). Refer to the Event Log for more details.
   at System.ServiceModel.Channels.SharedConnectionListener.SharedListenerProxy.HandleServiceStart(Boolean isReconnecting)

There was no endpoint listening at net.pipe://localhost/CrmSandboxHost that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. ---> System.IO.PipeException: The pipe endpoint 'net.pipe://localhost/CrmSandboxHost' could not be found on your local machine.

System.ServiceModel.CommunicationObjectFaultedException: The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.

The Sandbox SDK Listener failed to start.
 Source: w3wp.exe (5156)
 Endpoint: net.tcp://localhost/CrmSandboxSdkListener-w3wp
 Error: System.ServiceModel.CommunicationException: The TransportManager failed to listen on the supplied URI using the NetTcpPortSharing service: failed to start the service (5). Refer to the Event Log for more details.

Step-By-Step Verification and Solution

Verify if Microsoft Dynamics CRM Sandbox Processing Service (MSCRMSandboxService) is up and running on CRM Web Server. 
If you have a load-balanced environment then we need to verify on each hosted application server.



You can try to restart Sandbox Services (each on hosted server) and verify if the error is still occurring. If not then jump to next solutions.

Preferred Method : Specify host names in CRM Web Application server
regedit -> HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0
1.    Right-click MSV1_0, point to New, and then click Multi-String Value.
2.    Type BackConnectionHostNames, and then press ENTER.
3.    Right-click BackConnectionHostNames, and then click Modify.
4.    In the Value data box, type the host name or the host names for the sites that are on the local computer, and then click OK. Separate each entry with a new line.

Less Recommended Method : Disable the loopback check
regedit -> HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
1.    Right-click Lsa, point to New, and then click DWORD Value.
2.    Type DisableLoopbackCheck, and then press ENTER.
3.    Right-click DisableLoopbackCheck, and then click Modify.
4.    In the Value data box, type 1, and then click OK.

Method : Modifying the IIS Maximum Worker Processes

In IIS, right-click on Application Pool, select Advance Settings, and in the Process Model section, you will have “Maximum Worker Processes”. Edit the value to "1". 

Note & Tips:
Quit Registry Editor, and then restart the IISAdmin service.
Run ipconfig /all in the command prompt to check for a host name.
For a detailed understanding and cause about these issues refer below MSDN blogs