Plugin for Resolve Case action against Incident Entity. (CRM 4.0)


We had a requirement wherein we wanted to update one of the fields in the incident record when we are resolving it through (Actionà Resolve Case).

Here we had to write a Pre-Update plugin registered on Child Pipeline against incident entity.

More on that

http://roman20007.wordpress.com/2010/04/25/resolve-case-event-in-plugin/

http://social.microsoft.com/Forums/en-HK/crmdevelopment/thread/ef1e594f-f50b-484e-a166-285429df8e4d

Hope it helps.

Calling On Demand Workflow through a Button in Ribbon (launchOnDemandWorkflow) in CRM 2011


I had to call an on demand workflow through a custom button click inside the ribbon. I thought of using launchOnDemandWorkflow function.

http://inogic.blogspot.com/2009/06/call-workflow-from-isv-button.html

But couldn’t really find a way of calling that function.

So thought of calling it through its url, which would be something like this

http://servername/orgname/_grid/cmds/dlg_runworkflow.aspx?


iObjType=10004

&iTotal=1

&sIds=%7b4BEBDCAF-8F66-E011-A475-00155D045711%7d%3b

&wfId=%7bF0ED25C7-5129-4297-8515-69DFFA0739FF%7d


function CallOnDemandWorkflow() {


var recordID = crmForm.ObjectId;


var url = http://server/org/_grid/cmds/dlg_runworkflow.aspx?iObjType=10004&iTotal=1&sIds={“ + recordID + “}&wfId={F0ED25C7-5129-4297-8515-69DFFA0739FF}”;

window.open(url);

}

However I keep getting some JavaScript Error.

Finally found out the correct way of doing so.

function CallOnDemandWF() {

var a = new Array(crmFormSubmit.crmFormSubmitId.value);

var sIds = crmFormSubmit.crmFormSubmitId.value+“;”;

var sEntityTypeCode = “10004”; //Replace this with your entity type code

var sWorkflowId = “{F0ED25C7-5129-4297-8515-69DFFA0739FF}”; //Replace this with your actual workflow ID

var iWindowPosX = 500; //Modal dialog position X

var iWindowPosY = 200; //Modal dialog position Y

var oResult = openStdDlg(prependOrgName(“/_grid/cmds/dlg_runworkflow.aspx”)+“?iObjType=” + CrmEncodeDecode.CrmUrlEncode(sEntityTypeCode) + “&iTotal=” +

CrmEncodeDecode.CrmUrlEncode(a.length) + “&wfId=” + CrmEncodeDecode.CrmUrlEncode(sWorkflowId)+ “&sIds=” + CrmEncodeDecode.CrmUrlEncode(sIds) , a, iWindowPosX, iWindowPosY);

}

Check out the thread

http://axforum.info/forums/showthread.php?t=29333

Final Output

The ribbondiffxml used is following

    <RibbonDiffXml>

            <CustomActions>

                <CustomAction

                Id=CA_MyFirstButton

                Location=Mscrm.Form.new_rip.MainTab.Workflow.Controls._children

                Sequence=31>

                    <CommandUIDefinition>

                        <Button

                        Id=B_MyFirstButton

                        Command=Cmd_JavaScript

                        LabelText=Invite Service Member

                        ToolTipTitle=Invite User

                        ToolTipDescription=Use this workflow to invite Service Member to the portal

                        TemplateAlias=o1

                        Image16by16=/_imgs/ribbon/startdialog_16.png

                        Image32by32=/_imgs/ribbon/startdialog_32.png></Button>

                    </CommandUIDefinition>

                </CustomAction>

            </CustomActions>

            <Templates>

                <RibbonTemplates

                Id=Mscrm.Templates/>

            </Templates>

            <CommandDefinitions>

                <CommandDefinition
Id=Cmd_JavaScript>

                    <EnableRules>

                        <EnableRule
Id=Mscrm.Enabled></EnableRule>

                    </EnableRules>

                    <DisplayRules></DisplayRules>

                    <Actions>

                        <JavaScriptFunction

                            Library=$webresource:new_InOut

                            FunctionName=CallOnDemandWF

                    >

                        </JavaScriptFunction>

                    </Actions>

                </CommandDefinition>

            </CommandDefinitions>

            <RuleDefinitions>

                <TabDisplayRules/>

                <DisplayRules/>

                <EnableRules/>

            </RuleDefinitions>

            <LocLabels/>

        </RibbonDiffXml>

Bye.

Using Change Password ASP.NET control in SharePoint 2010 FBA.


Create a new SharePoint 2010 Empty Project in visual studio 2010.

Right click the project à Add New Itemà Select “Application Page”.

Add the ChangePassword control inside PlaceHolderMain content place holder

<asp:Content ID=”Main” ContentPlaceHolderID=”PlaceHolderMain” runat=”server”>

<asp:ChangePassword
id=”myChangePassword”
newpasswordregularexpressionerrormessage=”Error: Your password must be at least 5 characters long, and contain at least one number and one special character.” runat=”server” CancelDestinationPageUrl=”~/pages/default.aspx” OnContinueButtonClick=”ContinueClickHandler” MembershipProvider=”SqlMembers”  OnChangingPassword=”ChangingPassword” OnChangedPassword=”ChangedPassword”></asp:ChangePassword></asp:Content>

Put the following code for OnChangingPassword and OnChangedPassword Event handler in the code behind. 

 // the username would be in the following format
 // 0#.f|sqlmembers|nishantr
 // so we need to get only the username part
 // otherwise it wont work properly
protected void ChangingPassword(object sender, EventArgs e)
{
System.Web.UI.WebControls.ChangePassword chngPassword = (System.Web.UI.WebControls.ChangePassword)sender;
chngPassword.UserName = chngPassword.UserName.Substring(chngPassword.UserName.LastIndexOf("|") + 1);
}

// add reference to Microsoft.SharePoint.IdentityModel dll
protected void ChangedPassword(object sender, EventArgs e)
{
System.Web.UI.WebControls.ChangePassword chngPassword = (System.Web.UI.WebControls.ChangePassword)sender;
FormsAuthentication.SignOut();
Microsoft.SharePoint.IdentityModel.SPClaimsUtility.AuthenticateFormsUser(new Uri(SPContext.Current.Web.Url), chngPassword.UserName, chngPassword.NewPassword);
}


Check this really helpful pack

http://sharepoint2010fba.codeplex.com/

Hope it helps.

Add reference to Microsoft.SharePoint.IdentityModel.dll


Had trouble finding the above assembly to add reference to it. It wasn’t there in the 14 hive. The location where we can find it is

C:\Windows\assembly\GAC_MSIL\Microsoft.SharePoint.IdentityModel\

Bye.

The type initializer for ‘System.Data.SqlClient.SqlConnection’ threw an exception


I was getting the above error in one of my windows application. Was because of some section getting repeated in the app.config file.

Removing the duplicate section information from the app.config resolved the issue.

Initializing and setting DefaultCrendentials for OrganizationService in CRM 2011


I created a simple windows application just to see how to make use of IOrganizationService within CRM 2011.

Here we need to add references to the following dlls

  1. Microsoft.Xrm.Sdk.
  2. System.ServiceModel.
  3. System.Runtime.Serialization.

This is the sample code

Uri organizationUri = new Uri("http://crmservername/orgname/XRMServices/2011/Organization.svc");
Uri homeRealmUri = null;
ClientCredentials credentials = new ClientCredentials();
// set default credentials for OrganizationService
credentials.Windows.ClientCredential = (NetworkCredential)CredentialCache.DefaultCredentials;
// or
credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
OrganizationServiceProxy orgProxy = new OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null);
IOrganizationService _service = (IOrganizationService)orgProxy;
try
{
    Entity myAccount = new Entity("account");
    myAccount["name"] = "Test Account";
    _service.Create(myAccount);
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message);
}
}