Programmatically working with Service Scheduling in CRM


Hi,

Please check out the following post that explains in detail the concept of Service Scheduling programmatically.

Calendar, Inner Calendar etc..

http://blogs.msdn.com/b/crm/archive/2008/02/15/service-scheduling-exposed-partially.aspx

This is the other helpful post

http://dotnetdevlife.blogspot.com/2011/07/crm-2011-creating-service-restrictions.html

Hope it helps.

Programmatically set Time Off for the System User in CRM 2011


We can make use of below sample code to set the Time Off for the user programmatically. In the below code we are setting time off of duration 8 hours on 7th May 2013.


IServiceManagement<IOrganizationService> orgServiceManagement =
 ServiceConfigurationFactory.CreateManagement<IOrganizationService>(new Uri("https://orgname.crm5.dynamics.com/XRMServices/2011/Organization.svc"));

AuthenticationCredentials authCredentials = new AuthenticationCredentials();
 authCredentials.ClientCredentials.UserName.UserName = "user@domain.onmicrosoft.com";
 authCredentials.ClientCredentials.UserName.Password = "password";
 AuthenticationCredentials tokenCredentials = orgServiceManagement.Authenticate(authCredentials);

OrganizationServiceProxy organizationProxy = new OrganizationServiceProxy(orgServiceManagement, tokenCredentials.SecurityTokenResponse);

 // Get the user id
 Guid userid = ((WhoAmIResponse)organizationProxy.Execute(new WhoAmIRequest())).UserId;

// Get the calendar id of the user
 Entity systemUserEntity = organizationProxy.Retrieve("systemuser", userid, new ColumnSet(new String[] { "calendarid"}));

// Retrieve the calendar of the user
 Entity userCalendarEntity = organizationProxy.Retrieve("calendar", ((Microsoft.Xrm.Sdk.EntityReference)(systemUserEntity.Attributes["calendarid"])).Id, new ColumnSet(true));

// Retrieve the calendar rules defined in the calendar
 EntityCollection calendarRules = (EntityCollection)userCalendarEntity.Attributes["calendarrules"];

// Create a new inner calendar
 Entity newInnerCalendar = new Entity("calendar");
 newInnerCalendar.Attributes["businessunitid"] = new EntityReference("businessunit", ((Microsoft.Xrm.Sdk.EntityReference)(userCalendarEntity["businessunitid"])).Id);
 Guid innerCalendarId = organizationProxy.Create(newInnerCalendar);

// Create a new calendar rule and assign the inner calendar id to it
 Entity calendarRule = new Entity("calendarrule");
 calendarRule.Attributes["description"] = "Time Off Rule";
 calendarRule.Attributes["duration"] = 480;
 calendarRule.Attributes["extentcode"] = 2;
 calendarRule.Attributes["pattern"] = "FREQ=DAILY;INTERVAL=1;COUNT=1";
 calendarRule.Attributes["rank"] = 0;
 calendarRule.Attributes["timezonecode"] = 190;
 calendarRule.Attributes["innercalendarid"] = new EntityReference("calendar", innerCalendarId);

// starting at 12:00 on 7 May
 calendarRule.Attributes["starttime"] = new DateTime(2013, 5, 7,0,0,0,DateTimeKind.Utc);
 calendarRules.Entities.Add(calendarRule);

// assign all the calendar rule back to the user calendar
 userCalendarEntity.Attributes["calendarrules"] = calendarRules;
 // update the user calendar entity that has the new rule
 organizationProxy.Update(userCalendarEntity);

Entity calendarRule1 = new Entity("calendarrule");

// duration of 8 hours
 calendarRule1.Attributes["duration"] = 480;
 calendarRule1.Attributes["effort"] = 2.0;
 calendarRule1.Attributes["issimple"] = true;


 calendarRule1.Attributes["offset"] = 0;
 calendarRule1.Attributes["rank"] = 0;
 // subcode 6= vacation
 calendarRule1.Attributes["subcode"] = 6;
 // time code 2 = unavailable
 calendarRule1.Attributes["timecode"] = 2;
 calendarRule1.Attributes["timezonecode"] = -1;
 calendarRule1.Attributes["calendarid"] = new EntityReference("calendar", innerCalendarId);

EntityCollection innerCalendarRules = new EntityCollection();
 innerCalendarRules.EntityName = "calendarrule";
 innerCalendarRules.Entities.Add(calendarRule1);

newInnerCalendar.Attributes["calendarrules"] = innerCalendarRules;
 newInnerCalendar.Attributes["calendarid"] = innerCalendarId;
 organizationProxy.Update(newInnerCalendar);

Hope it helps

Filter on Add Existing Lookup for 1-n relationship in CRM 2011.


Hi,

We recently had a requirement to implement filtering on Add Existing lookup button for 1-n relationship.

This is the post that helped us to implement it.

http://sliong.wordpress.com/2012/06/22/crm-2011-filtered-lookup-for-add-existing-button-for-one-to-many-relationship-crmformsubmit-is-undefined/

Only change was in the name of the getParameter function.

function
replaceAddExistingButtonView(params) {

    var
relName = params.gridControl.getParameter(“relName”),

    var roleOrd = params.gridControl.getParameter(“roleOrd”),

instead of getParameter it is now GetParameter (capital G)

Bye.

To use this saved view, you must remove criteria and columns that refer to deleted or non-searchable items error in CRM 2011


Hi,

Was working on Filtering Add Exiting Lookup and got the below error.

Here we need to make sure that we are referencing correct columns in the fetchxml and layoutxml while creating the view using JavaScript.

fetchXml: “<fetch
version=1.0
output-format=xml-platform
mapping=logical
distinct=false>” +

<entity name=new_mycustomentity>” +

<attribute name=new_customentityid />” +

<attribute name=new_name/>” +

<order attribute=new_name‘ descending=false />” +

<filter type=and>” +

<condition attribute=new_name‘ operator=like‘ value=%1% />” +

</filter>” +

</entity>” +

</fetch>“,

layoutXml: “<grid name=resultset‘ object=10001‘ jump=new_name
select=1‘ icon=1‘ preview=1>” +

<row name=result‘ id=new_customentityid’>” + <cell name=new_name‘ width=300 />” +

</row>” +

</grid>“,

Hope it helps.

Get “Sign in as Different User” back in SharePoint 2013


Hi,

Was working on portal in SharePoint 2013, and had to validate few things by signing as a different user. Then realized that the option of “Sign in as Different user” was missing.

Followed these article to get past this issue

http://support.microsoft.com/kb/2752600

http://nickgrattan.wordpress.com/2012/07/23/sign-in-as-different-user-and-sharepoint-2013/

Hope it helps

The server was unable to save the form at this time. Please try again. Error in Document Library (SharePoint 2013)


Hi,

I was getting the following error while trying to edit properties of a document in the document library in SharePoint 2013.

As suggested restarted SharePoint Search Host Controller service. Stopped few services to release some memory. Nothing helped.

Finally followed these steps

  • Create a new Document Library accepting all defaults
  • Add a document to the library
  • Edit the properties of the document and save.
    RESULT: The server was unable to save the form at this time. Please try again.
  • Enable ‘Manage content types’ in the library setting.
  • Add the ‘Link to a document’ content type.
  • Edit the properties of the document and save.
  • RESULT: Fixed

The helpful post

http://www.3guysonsharepoint.com/?p=1476

Hope it helps.