Showing posts with label update. Show all posts
Showing posts with label update. Show all posts

Thursday, January 02, 2014

Close queueitem

Use the code template from here

If you need to close the queueitem after creating a case from an email, here you go with the code

target is of type entity "email"
Code:
        if (target.Contains("regardingobjectid"))
        {
            EntityReference _object = (EntityReference)target["regardingobjectid"];

            if (_object.LogicalName == "incident")
            {
                CloseQueueItem(_object.Id, service);
            }
        }
Code:
public static bool CloseQueueItem(Guid _sourceId, IOrganizationService service)
    {

        Guid _queueItemId = Guid.Empty;
        bool _queueItemClosed = false;

        ConditionExpression ent_ce1 = new ConditionExpression("objectid", ConditionOperator.Equal, _sourceId);
        ConditionExpression ent_ce2 = new ConditionExpression("statecode", ConditionOperator.Equal, 0);
        FilterExpression ent_fe = new FilterExpression(LogicalOperator.And);
        ent_fe.AddCondition(ent_ce1);
        ent_fe.AddCondition(ent_ce2);

        QueryExpression ent_qe = new QueryExpression();
        ent_qe.EntityName = "queueitem";
        ent_qe.Criteria = ent_fe;
        ent_qe.ColumnSet = new ColumnSet("queueitemid", "queueid", "objectid");
        ent_qe.PageInfo.ReturnTotalRecordCount = true;
        EntityCollection ent_coll = service.RetrieveMultiple(ent_qe);

        if (ent_coll.Entities.Count > 0)
        {
            foreach (Entity _queueItem in ent_coll.Entities)
            {
                EntityReference enRef = (EntityReference)_queueItem["objectid"];
                PluginHelper.SetState(_queueItem.LogicalName, _queueItem.Id, 1, 2, service);
            }
            _queueItemClosed = true;
        }

        return _queueItemClosed;
    }

Monday, May 21, 2012

Integrating with Sharepoint

With the new built in integration of sharepoint list mode, crm offers the capability to integrate with sharepoint. However we are are often stuck with the builtin tool to create teh sharepoint folders which are not effective. So I am presenting a solution to automate the integration. In my previous post we have created a plugin to generate autonumber. We will use this to create the sharepoint folder.

Remember
1. Update the sharepoint site URL
2. If you want to use the defaults, update the GUID from your database
3. Remember to use the entity names as display names in sharepoint site

Assumption
1. Sharepoint site already created
2. Document libraries are created for each entity in CRM that integrated with sharepoint
(Created by default when you enable storing documents in shrepoint)


The below code will generate the sharepoint structure as below
spsite/entity/unique-identifier

If the folder already exists in sharepoint, it just links the folder in CRM else it creates the folder in Sharepoint and then created the document locations in CRM. You can customize in the code on which fileld to be used for the document location "GetSharepointAttribute(string EntityName)". Update this function to reflect your needs


Monday, February 13, 2012

How to export a MANAGED Solution in CRM 2011

The following is not recommended and it at your own risk.

In general, MS CRM 2011 allows you to export a Unmanged solution. But in case if you want to update any of the default component of MS CRM, you will not be allowed to do so as the IsCustomizable is set to false.
Also you might encounter situations where you will not be able to extend a previously imported Managed solution or export a Managed solution. However you can override all these if you get access to the SQL database.

Please make a note of the few system tables.
1. SolutionBase - Base table where the solution information is stored - Update the IsManaged to False
2. SystemFormBase - Base table for forms. If you want to update a form, get the form id and set the IsManaged to False. You can filter the forms by using the Solution Id and the Entity Id.

Go Hack yourself :)