Saturday, June 19, 2010

Starting a Workflow from an Event Receiver - SharePoint 2007

Out of the Box there are only a few options to start a (custom) workflow. E.g. when an item is created or changed. This means that there are a lot of situations that a workflow is fired where it is not needed (often a workflow only needs to be started if a field has a specific value). Therefore we can write an event receiver to time better when a workflow is started. Below you find the code to start a workflow from your event receiver.

[code:c#]

public override void ItemUpdated(SPItemEventProperties properties)

{

if(YourCondition)

{

SPList parentList = properties.ListItem.ParentList;

SPWorkflowAssociation associationTemplate =

parentList.WorkflowAssociations.GetAssociationByName("Workflow Name",

new CultureInfo

(Convert.ToInt32(parentList.ParentWeb.RegionalSettings.LocaleId)));

SPSite siteCollection = properties.ListItem.ParentList.ParentWeb.Site;

siteCollection.WorkflowManager.StartWorkflow(properties.ListItem,

associationTemplate, String.Empty);

}

}

[/code]

Tuesday, June 15, 2010

CRM 4.0 Network Resource Image Control

As the name suggest this is an on-premise / VPN solution so consider if you need this to work across the web / IFD. The idea is to utilize a simple network share together with VB 6.0 Common Control Open Dialog which can be summoned using JavaScript. The nice thing about the Dialog is that it enables you to see files as thumbnails, set the initial directory and return the selected image path into a text attribute. That’s pretty much what you need to make this work.





You can add an ISV toolbar button to pop the dialog but I find that this solution works hand in glove with the text image button post I wrote a while ago.
Here is what is did in a nut shell:
Create a Add a new text attribute. I used the pager attribute on the contact form for the sake of this example.
Add a new Fixed Field 1:1 section to the contact form. This is done so the IFRAME
that displays the image will occupy half the screen.


Then add a the image IFRAME and pointed it to a default blank.jpg image.


Arrange the form attributes as you like … here is what I did.



Set the path attribute to read-only so selection is possible only when using the dialog.
Add the following code to the contact on load event box.

And Finally create a network share anywhere on the server and set appropriate user permission.



That’s it … pretty simple ah … feel free to comment.





Show no. of open or closed activities (history) on the CRM form.

Hello all,
Have you ever wanted to see the total no. of outstanding/completed activities on a Case, Account, Opportunity, Contact etc..? 

Well now you can, simply add the following JavaScript code to the onLoad event of the entity, it will query the webservice and it will give you the exact count of open/closed activities.
Update: 9th March 2010 - I have updated the code below and tested.
// this code is to get the number of activities and historical activities.
var buXml = GetRegardingActivity();
if(buXml != null)
{
    var buNodes = buXml.selectNodes("//BusinessEntity/q1:statecode"); // CRM 4.0
    var iActivity = 0;
    var iHistory = 0;

    if(buNodes != null )
    {
        /*get values*/
        for( i = 0; i < buNodes.length; i++)
        {
            switch(buNodes[i].text)
            {
                case "Open" : iActivity++; break;
                case "Scheduled" : iActivity++; break;
                case "Completed" : iHistory++; break;
                case "Canceled" : iHistory++; break;
            }
        }

        if(document.getElementById('navActivities') != null)
        {
            document.getElementById('navActivities').getElementsByTagName('NOBR')[0].innerText = document.getElementById('navActivities').getElementsByTagName('NOBR')[0].innerText + " (" + iActivity + ")";
        }

        if(document.getElementById('navActivityHistory') != null)
        {
            document.getElementById('navActivityHistory').getElementsByTagName('NOBR')[0].innerText = document.getElementById('navActivityHistory').getElementsByTagName('NOBR')[0].innerText + " (" + iHistory + ")";
        }
    }
}

function GetRegardingActivity()
{
    var xml = "" +
    "<?xml version="1.0" encoding="utf-8"?>" +
    "<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">" +
    GenerateAuthenticationHeader()  +
    " <soap:Body>" +
    "<RetrieveMultiple xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
    "<query xmlns:q1='http://schemas.microsoft.com/crm/2006/Query'"+
    " xsi:type='q1:QueryExpression'>"+
    " <q1:EntityName>activitypointer</q1:EntityName>" +
    " <q1:ColumnSet xsi:type="q1:ColumnSet">" +
    " <q1:Attributes>" +
    " <q1:Attribute>statecode</q1:Attribute>" +
    " </q1:Attributes>" +
    " </q1:ColumnSet>" +
    " <q1:Distinct>false</q1:Distinct>" +
    " <q1:Criteria>" +
    " <q1:FilterOperator>And</q1:FilterOperator>" +
    " <q1:Conditions>" +
    " <q1:Condition>" +
    " <q1:AttributeName>regardingobjectid</q1:AttributeName>" +
    " <q1:Operator>Equal</q1:Operator>" +
    " <q1:Values>" +
    " <q1:Value xsi:type="xsd:string">" + crmForm.ObjectId + "</q1:Value>" +
    " </q1:Values>" +
    " </q1:Condition>" +
    " </q1:Conditions>" +
    " </q1:Criteria>" +
    " </query>" +
    "</RetrieveMultiple>"+
    " </soap:Body>" +
    "</soap:Envelope>" +
    "";

    var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
    xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
    xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple");
    xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
    xmlHttpRequest.send(xml);

    var resultXml = xmlHttpRequest.responseXML;
    return resultXml;
}
 
 
 
Source: http://mscrmblog.net/2009/05/18/show-no-of-open-closed-activities-history-on-the-crm-form/ 

Tuesday, June 8, 2010

SharePoint 2010 Licensing

SharePoint Foundation Server 2010  is the free offering replacing WSS 3.0. and will have the usual limits of SQL Express and Search Express.
The Standard  SharePoint functions will be base around Collaboration, Enterprise Search, Document and Content Management, Social Computing (Wikis, My Sites), Digital Asset Management (including Silverlight) and Records Management. Basically unstructured data.
The Enterprise  functionality is a long list:
  • Excel Services
  • Performance Point Services
  • Advanced Charting
  • Visio Services
  • Access Services
  • InfoPath Form Services
  • Client line of business integration and web parts
  • Custom Reports
In addition server licences can be upgraded to use FAST search.
Speaking of server licenses these break into Standard and Enterprise as before but this time there are both intranet and internet versions. Added to this is the aforementioned FAST server license which comes in both flavours too. So when you add this to the Foundation Server you have a total of seven types of SharePoint (a title for a post if ever I scribbled one).
Note that the SharePoint for Internet 2010 Standard Edition is designed for small to medium concerns and will retail at about half the price of the current MOSS for internet. But, and its a big but, it will be artificially throttled possibly round content size (the Microsoft boys were a bit hazy on this).
For intranet solutions the Client Access Model remains with the need to buy both a Standard  and Enterprise CAL  to access Enterprise features. For FAST although the license upgrade is for the server users utilising it will need an  Enterprise CAL.
Still with me?
Ok – SharePoint 2010 Online for intranet will continue with the current User Subscription License based on Enterprise, Standard and Deskless (read and form filling only). It will also have an Internet and Partner Access versions. Partner Access is effectively an extranet option.
For related technology:
SharePoint Workspace (the app formerly known as Groove) comes with Office 2010 PRO+ (which sounds like a caffeine tablet)
Office Web AppsOffice 2010 but do need SharePoint Foundation 2010  to work.
Project Server 2010 – needs a Project CAL  and a SharePoint Enterprise CAL
SQL Server Power Pivot  - SQL Enterprise Edition  if exposed only in office then an Office 2010 to be surfaced in SharePoint an Enterprise CAL  is required. 
Just for completeness there is also a non SharePoint version of FAST - Fast Search Server 2010 for Internet Business.


http://blogs.charteris.com/blogs/colinn/archive/2009/10/21/sharepoint-2010-licensing.aspx