Plugin when a case (incident) is resolved in CRM 2013.


Hi,

To fire a plugin when an incident is resolved we need to register the plugin in

Close message for the incident entity.

And in the input parameters of the context we need to check for IncidentResolution.

This entity is a special entity that holds the information about the incident record that is being closed.

The sample plugin below gets the actual end attribute value of IncidentResolution and subtracts created on attribute value of Incident to get the duration and updates the duration (custom field) in the case being resolved.


public void Execute(IServiceProvider serviceProvider)
{
// Obtain the execution context from the service provider.
IPluginExecutionContext context = (IPluginExecutionContext)
serviceProvider.GetService(typeof(IPluginExecutionContext));

if (context.InputParameters.Contains("IncidentResolution"))
{
Entity incidentResolution = (Entity)context.InputParameters["IncidentResolution"];
Guid relatedIncidentGuid = ((EntityReference)incidentResolution.Attributes["incidentid"]).Id;
DateTime actualEnd = DateTime.Now;
if (incidentResolution.Contains("actualend"))
{
actualEnd = (DateTime)incidentResolution.Attributes["actualend"];
}
// Obtain the organization service reference.
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

// Get created on of incident

Entity retrievedIncident = service.Retrieve("incident", relatedIncidentGuid, new ColumnSet(true));
DateTime createdOn = (DateTime)retrievedIncident.Attributes["createdon"];

TimeSpan totalTimeSpent = actualEnd.Subtract(createdOn);

Entity incident = new Entity("incident");
incident.Id = relatedIncidentGuid;
incident.Attributes["new_duration"] = totalTimeSpent.TotalMinutes;
service.Update(incident);

}
}

The helpful post

http://varghesedanny.com/2011/02/24/plug-in-when-case-incident-is-closed/

 

 

 

 

 

 

 

Cleared MB2-707 Microsoft Dynamics CRM Customization and Configuration CRM 2015 Exam


Took my first CRM 2015 exam this Monday and somehow managed to clear it.

There were total 49 questions with passing marks of 700 in 2 hours’ time.

Refer to the below helpful post for the training material

http://www.nzcrmguy.com/microsoft-dynamics-crm-2015-exams-elearning-courseware/

The file or folder name contains characters that are not permitted SharePoint 2013. Removing the invalid characters using Regex C#.


Was getting the below error while uploading attachment to SharePoint document library.


string pattern = "[\\~#%&*{}/:<>?|\"-]";
string replacement = " ";

Regex regEx = new Regex(pattern);

string sanitized = Regex.Replace(regEx.Replace(input, replacement), @"\s+", " ");

Helpful post

http://simplyaprogrammer.com/2008/05/importing-files-into-sharepoint.html

Hope it helps

Missing Windows Authentication Provider in IIS 8 in Windows 8 or Windows 8.1


Was hosting a WCF Service in IIS on my machine.

Realized that Windows Authentication option was missing.

To add it, go to

Control Panel à Program Features à Turn Windows Features On and Off

Enable Windows Authentication.

Hope it helps

Problem with SharePoint 2013 and Internet Explorer 11


Nice tip !

bbuhac's avatarSharepoint Thing

So if you are one of few that are using IE11 and SharePoint 2013 you have probably noticed many corruptions and misbehaves in UI. So far I have discovered the following problems:

  • Calendar web part is extremely corrupted
  • You will click Settings > Edit Page, Pages will not enter edit mode.
  • Web Part Properties cannot be modified.

So until we get official CU or SP from SharePoint team, run your sites in compatibility mode.

  1. Click Compatibility View Settings in Settings
  2. Click Add to add the current SharePoint site to your list.

View original post

Code to upload multiple attachments to SharePoint Folder using Client Object Model



public static void UploadDocument(
string siteURL,
string documentListName,
string documentListURL,
string documentName,
byte[] documentStream,
string folderName,
string invoiceId)
{
using (var clientContext = new ClientContext(siteURL))
{
// Get Document List
var documentsList = clientContext.Web.Lists.GetByTitle(documentListName);

// check if folder already exists else create folder

if (!FolderExists(clientContext.Web, documentListName, folderName))
{
var info = new ListItemCreationInformation();
info.UnderlyingObjectType = FileSystemObjectType.Folder;
info.LeafName = folderName.Trim();
var newItem = documentsList.AddItem(info);
newItem["Title"] = folderName;
newItem.Update();
clientContext.ExecuteQuery();
}

var fileCreationInformation = new FileCreationInformation();

// Assign to content byte[] i.e. documentStream
fileCreationInformation.Content = documentStream;

// Allow owerwrite of document
fileCreationInformation.Overwrite = true;

// Upload URL
fileCreationInformation.Url = siteURL + documentListURL + folderName + "/" + documentName;
var uploadFile = documentsList.RootFolder.Files.Add(fileCreationInformation);

// Update the metadata for a field having name "DocType"
uploadFile.ListItemAllFields["Invoice_x0020_Id"] = invoiceId;

uploadFile.ListItemAllFields.Update();
clientContext.ExecuteQuery();
}
}


public static bool FolderExists(Web web, string listTitle, string folderUrl)
{
var list = web.Lists.GetByTitle(listTitle);
var folders = list.GetItems(CamlQuery.CreateAllFoldersQuery());
web.Context.Load(list.RootFolder);
web.Context.Load(folders);
web.Context.ExecuteQuery();
var folderRelativeUrl = string.Format("/{0}/{1}", list.RootFolder.Name, folderUrl);
return Enumerable.Any(folders, folderItem => (string)folderItem["FileRef"] == folderRelativeUrl);
}