Tuesday, 20 December 2016

email issues


Wednesday, 26 October 2016

Displaying image for branding site

We got a common site and then branding sites, One of the site wants to show the image before a particular text and other didn't want to show that image at all.


Update the common site to have a Div or Span and specify css class on it place this span before the text, e.g.

<span class="summaryimage"></span> Some text is shown here

now in CSS class specify

background: url(http://url of the image) no-repeat 96% 96%;
float: left;

Syntax: background: <background-color> | <background-image> | <background-repeat> | <background-attachment> | <background-position>


background-color: white;
background-image: url(logo.gif);
background-position: 50% 50%;
background-repeat: no-repeat;
background-attachment: fixed;
And change it to this:
background: white url(log.gif) no-repeat fixed 50% 50%;

Friday, 21 October 2016

Revert bad checkin in tfs

When working on one of the project I checked in some wrong code and relaised that I need to rollback to previous version.


Right click the folder/file (the one to revert) and click view history and find the last changeset number you like to revert to. Open Visual Studio Command Prompt (Run as administrator) and write the following command

Preferred (worked for me)

tf rollback /toversion:C<<write your previous changeset number you like to rever to>> /recursive <<path to folder>>

tf rollback /toversion:C378 /recursive c:\tfs\dev1\projectxyz

(use . to use the current working space for this)

tf rollback /changeset: <<write your previous changeset number you like to revert to>>


tf rollback /changeset:378

Friday, 2 September 2016

SQL Management Studio not showing shared/mapped drives in the Restore Database window

I was running out of diskspace and had a databaes .bak file at UNC to restore locally, if I copy that then won't left with enough disk space to restore that as well. When I mapped the shared folder to local drive and tried to restore database I couldn't see mapped drive nor was I able to use share path as is

Reason: SQL management studio run under a different session.

Resolution: In order to use share folder path go to the remote computer and share that folder with everyone (or find which account SQL management studio is running and share it with that account). Then on SQL MS go to restore database option then disk option and click add and then paste the share path in the folder path and in the file name enter the .bak file name and click OK though SQLMS won't show shared drive it will accept the share folder path.


Thursday, 14 July 2016

CRM Tracing/Debugging Service

When writing plugin we try to make sure all possible scenarios are covered however when application is deployed at client side they enter some data which we didn't think of when writing code or use application which causes Business Process error BPE, In this case CRM shows BPE dialog window and use can click on download log button to view the stack trace, sometimes that's not enough, and we should use tracing service so that we can trace to be bit more understandable about which code been executed and with what values been passed by showing including that to trace.

ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));

then use the Trace method to write trace

tracingService.Trace("Cost provided"+ entityObject.prefix_fieldname);

Now when plugin throws BPE we will get more of an idea about what happened in code.

Remote Debugging

Go to google and seach for Remote tools download and install it on the machine which needs to be debugged, if this is a UAT environment within same network where the bug is reported and not able to reproduce locally, Then install it on their. Either to start and stop remote debugger go to start and then select Remote debugger windows app Or else go to windows services area and set the Remote debugger service to run as always.

Run the Remote debugger under local system account.

Depending how the plugin is registered we need to attached to respective process e.g. if the plugin is registered to run under sand box then we need to attach to sandbox process or in case of custom assemblies sandbox async service. If plugin is set to run under full privilege (none/not sandbox) then select w3wp for sync plugin or async service for customer assemblies or async plugins.

To debug with in visual studio go to debug -> attach to process
Attach to : Automatic: Native code (when service to attach is selected then the value might change to Automatic)
on qualifier field click on find and it will discover any remote debuggers running with in local network/subnet, or type manually default to 4016 port

Then trigger the process to debug the code (debug sysmbole won't load initially unless they are triggered an cached first time) if the symbols still doesn't load, then look if there are any more process pending to attached if there are then attached them e.g. w3wp or aysnc service, if this isn't the case cancel attached process and rebuild solution and redeploy and do the attach to process again.

Please note there is default 2 mins time out for Sandbox CRM process to terminate and restart if process take long to process

Different ways of doing converting list to custom arrays

List<EntityReference> list = new List<EntityReference> { new EntityReference("contact", Guid.NewGuid()), new EntityReference("contact", Guid.NewGuid()) };

Option 1

Entity[] listArray = new Entity[toList.Count];


for (int i = 0; i < toList.Count; i++)


Entity toParty = new Entity("activityparty");

toParty["partyid"] = toList[i];

listArray[i] = toParty;


Option 2
Entity[] listArray = new Entity[toList.Count];

list.ForEach(delegate(EntityReference item)


Entity ccParty = new Entity("activityparty");

       ccParty["partyid"] = item;

       listArray.SetValue(ccParty, listArray.Count());


Option 3

Entity[] listArray = ccList.ConvertAll<Entity>(delegate(EntityReference item) { return new Entity { LogicalName = "activityparty", Attributes = { { "partyid", item }   } }; }).ToArray();

Thursday, 9 June 2016

Compare 2 objects[] in powershell

compare-object command is used to compare two object arrays they can be different types of objects for example an object array from xml compared to object array of csv file data

for my example I used it to compare two different types of crm objects
we use bespoke tool to get crm records with in powershell, but idea here to show the use of compare-object

Compare-object -referenceobject (get-crmrecord -connect http://kuksolutiondev01/org1 -entityname kuk_configurations) -differenceobject (get-crmrecord -connect http://kuksolutiondev02/org4 -entityname kuk_configurations)

Output of above command is like

InputObject                                                                  SideIndicator
@{Id=7215239d-ddkd-kdld-kdkdfd44c342; Ent...   =>
@{Id=7215239d-ddkd-kdld-kdkdkdkf4das; Ent...   =>
@{Id=7215fdsf-ddkd-kdld-kdkdfdsa23dkd; Ent...   <=
@{Id=72152342-ddkd-kdld-d543fsdakdkd; Ent...   =>
@{Id=721523jkl-fdsad-kdk34fdsajkdkdkd; Ent...   <=

=> says the difference is found in the http://kuksolutiondev02/org2=4 and <= says difference is in http://kuksolutiondev01/org1

to find the full details of the input object use fl * in the pipeline

Compare-object -referenceobject (get-crmrecord -connect http://kuksolutiondev01/org1 -entityname kuk_configurations) -differenceobject (get-crmrecord -connect http://kuksolutiondev02/org4 -entityname kuk_configurations) | fl *