MS CRM 2011 RibbonButton -Create Custom Button Code On Ribbon

MS CRM 2011 RibbonButton -Create Custom Button Code On Ribbon

Place the below code in

<RibbonDiffXml>
<CustomActions >

<CustomAction Id=”ACKhome” Location=”Mscrm.HomepageGrid.Contact.MainTab.Collaborate.Controls._children” Sequence=”1″>

<CommandUIDefinition>

<Button Id=”ACKhome1″ Command=”ACKCMD” LabelText=”Send” ToolTipTitle=”Send” ToolTipDescription=”Send” TemplateAlias=”o2″ Image16by16=”$webresource:new_Send16″ Image32by32=”$webresource:new_Send32″ />

</CommandUIDefinition>

</CustomAction>

</CustomActions >

<CommandDefinitions>

<CommandDefinition Id=”ACKCMD”>

<EnableRules>

<EnableRule Id=”SendEnableRule”></EnableRule>

</EnableRules>

<DisplayRules></DisplayRules>

<Actions>

<JavaScriptFunction Library=”$webresource:new_SendBtnCode” FunctionName=”SendRibBtn”>

</JavaScriptFunction>

</Actions>

</CommandDefinition>

</CommandDefinitions>
<RuleDefinitions>

<EnableRule Id=”SendEnableRule”>

<SelectionCountRule Minimum=”1″ Maximum=”1″ AppliesTo=”SelectedEntity” />

</EnableRule>

</RuleDefinitions>

Cheers,

Advertisements

Difference between CRM 4.0 and CRM2011 script for using on form customization

Difference between CRM 4.0 and CRM2011 script for using on form customization

 

Request To CRM 4.0 CRM 2011
Set Field Value crmForm.all.CRMFieldSchemaName.DataValue=Value Xrm.Page.getAttribute(CRMFieldSchemaName).setValue(Value);
Get Field Value crmForm.all.CRMFieldSchemaName.DataValue Xrm.Page.getAttribute(CRMFieldSchemaName).getValue();
Set requirement fields For No Requirement—————————— Xrm.Page.getAttribute(“CRMFieldSchemaName”).setRequiredLevel(“none”);
crmForm.all.CRMFieldSchemaName.setAttribute(“req”, 0); Xrm.Page.getAttribute(“CRMFieldSchemaName”).setRequiredLevel(“required”);
crmForm.all.CRMFieldSchemaName_c.className = “n”; Xrm.Page.getAttribute(“CRMFieldSchemaName”).setRequiredLevel(“recommended”);
For Recommended——————————  
crmForm.all.CRMFieldSchemaName.setAttribute(“req”, 1);  
crmForm.all.CRMFieldSchemaName_c.className = “rec”;  
For Required——————————  
crmForm.all.CRMFieldSchemaName.setAttribute(“req”, 2);  
crmForm.all.CRMFieldSchemaName_c.className = “req”;  
Enable/Disable fields crmForm.all.CRMFieldSchemaName.Disabled = true; Xrm.Page.getControl(“CRMFieldSchemaName”).setDisabled(false);
crmForm.all.CRMFieldSchemaName.Disabled = false; Xrm.Page.getControl(“CRMFieldSchemaName”).setDisabled(true);
Hide fields crmForm.all.CRMFieldSchemaName.style.Display = ‘none’; Xrm.Page.ui.controls.get(“CRMFieldSchemaName“).setVisible(false);
crmForm.all.CRMFieldSchemaName _c.style.Display =’none’;
Show fields crmForm.all.CRMFieldSchemaName.style.display = ‘block’;   OR Xrm.Page.ui.controls.get(“CRMFieldSchemaName“).setVisible(false);
crmForm.all.CRMFieldSchemaName.style.display = ‘inline’;
Get Pick list Value crmForm.all.CRMFieldSchemaName.DataValue Xrm.Page.getAttribute(“CRMFieldSchemaName”).getSelectedOption().text;
Set Pick list Value crmForm.all.CRMFieldSchemaName.DataValue= value; Xrm.Page.getAttribute(“CRMFieldSchemaName”).setValue(parseInt(Value));
Get Lookup value var lookupItem = new Array; var lookupItem = new Array;
lookupItem = crmForm.all.CRMFieldSchemaName.DataValue; lookupItem = Xrm.Page.getAttribute(CRMFieldSchemaName).getValue();
if (lookupItem[0] != null) if (lookupItem[0] != null)
{ {
 alert(lookupItem[0].name);  alert(lookupItem[0].name);
 alert(lookupItem[0].id);  alert(lookupItem[0].id);
 alert(lookupItem[0].typename);  alert(lookupItem[0].entityType);
} }
Set Lookup value var lookupData = new Array(); Xrm.Page.getAttribute(“CRMFieldSchemaName”).setValue( [{id: idValue, name: textValue, entityType: typeValue}]);
var lookupItem= new Object(); Or
   lookupItem.id = ‘guid‘; var value = new Array();
   lookupItem.typename = ‘entityname‘; value[0] = new Object();
   lookupItem.name = ‘TextVal‘; value[0].id = ‘guid‘;
   lookupData[0] = lookupItem; value[0].name = ‘TextVal‘;
   crmForm.all.CRMFieldSchemaName.DataValue = lookupData; value[0].entityType = typeValue;
  Xrm.Page.getAttribute(“fieldName”).setValue(value);
   
Tab Hide crmForm.all.tabIndexTab.style.visibility = “hidden”; Xrm.Page.ui.tabs.get(Tab Index).setVisible(false);
Xrm.Page.ui.tabs.get(Tab Index).setVisible(true);
OR
Xrm.Page.ui.tabs.get(Tab Name).setVisible(true);

 

 

Sql Server 2008 Joins

Sql Server 2008 Joins

The join conditions combine with the WHERE and HAVING search conditions to control the rows that are selected from the base tables referenced in the FROM clause.

Inner joins (the typical join operation, which uses some comparison operator like = or <>). These include equi-joins and natural joins.

Inner joins can be specified in either the FROM or WHERE clauses.

  • Outer joins. Outer joins can be a left, a right, or full outer join.

Outer joins are specified with one of the following sets of keywords when they are specified in the FROM clause:

  • LEFT JOIN or LEFT OUTER JOIN

The result set of a left outer join includes all the rows from the left table specified in the LEFT OUTER clause, not just the ones in which the joined columns match. When a row in the left table has no matching rows in the right table, the associated result set row contains null values for all select list columns coming from the right table.

  • RIGHT JOIN or RIGHT OUTER JOIN

A right outer join is the reverse of a left outer join. All rows from the right table are returned. Null values are returned for the left table any time a right table row has no matching row in the left table.

  • FULL JOIN or FULL OUTER JOIN

A full outer join returns all rows in both the left and right tables. Any time a row has no match in the other table, the select list columns from the other table contain null values. When there is a match between the tables, the entire result set row contains data values from the base tables.

Note : Outer joins can be specified in the FROM clause only.

  • Cross joins

Cross joins return all rows from the left table. Each row from the left table is combined with all rows from the right table. Cross joins are also called Cartesian products.

Cheers,

SQL SERVER – What is – DML, DDL, DCL and TCL

SQL SERVER – What is – DML, DDL, DCL and TCL – Introduction and Examples

DML

DML is abbreviation of Data Manipulation Language. It is used to retrieve, store, modify, delete, insert and update data in database.

Examples: SELECT, UPDATE, INSERT statements

DDL

DDL is abbreviation of Data Definition Language. It is used to create and modify the structure of database objects in database.

Examples: CREATE, ALTER, DROP statements

DCL

DCL is abbreviation of Data Control Language. It is used to create roles, permissions, and referential integrity as well it is used to control access to database by securing it.

Examples: GRANT, REVOKE statements

TCL

TCL is abbreviation of Transactional Control Language. It is used to manage different transactions occurring within a database.

Examples: COMMIT, ROLLBACK statements

Cheers,

MS CRM 2011 JavaScript Events Part 2

MS CRM 2011 Xrm Form Reference

Xrm.Page.context

Xrm.Page.context provides access to the context object. The context object provides methods to retrieve information specific to an organization, a user, or parameters that were passed to the form in a query string.


Xrm.Page.context provides access to the following functions:

  • getAuthenticationHeader: Deprecated. Returns the encoded SOAP header necessary to use Microsoft Dynamics CRM web service calls using JScript.
  • getCurrentTheme Returns a string representing the current Microsoft Office Outlook theme chosen by the user.
  • getOrgLcid: Returns the LCID value that represents the Microsoft Dynamics CRM Language Pack that is the base language for the organization.
  • getOrgUniqueName: Returns the unique text value of the organizations name.
  • getQueryStringParameters: Returns an array of key value pairs representing the query string arguments that were passed to the page.
  • getServerUrl: Returns the base server URL. When a user is working offline with Microsoft Dynamics CRM for Microsoft Office Outlook, the URL is to the local Microsoft Dynamics CRM Web services.
  • getUserId: Returns the GUID value of the SystemUser.id value for the current user.
  • getUserLcid: Returns the LCID value that represents the Microsoft Dynamics CRM Language Pack that is the user selected as their preferred language.
  • getUserRoles: Returns an array of strings representing the GUID values of each of the security roles that the user is associated with.
  • isOutlookClient: Returns a Boolean value indicating if the user is using Microsoft Dynamics CRM for Microsoft Office Outlook.
  • isOutlookOnline: Returns a Boolean value indicating whether the user is connected to the Microsoft Dynamics CRM server while using Microsoft Dynamics CRM for Microsoft Office Outlook with Offline Access. When this function returns false, the user is not connected to the server. The user is interacting with an instance of Microsoft Dynamics CRM running on the local computer.
  • prependOrgName: Prepends the organization name to the specified path.

 

 

Xrm.Page.ui

Xrm.Page.ui contains methods to retrieve information about the user interface as well as collections for several subcomponents of the form.

Methods


The following table lists the methods of Xrm.Page.ui.

Method Description
close Closes the form.
getCurrentControl Returns the control object that currently has focus on the form.
getFormType Indicates the form context for the record.
getViewPortHeight Returns the height of the viewport in pixels.
getViewPortWidth Returns the width of the viewport in pixels.
refreshRibbon Causes the ribbon to re-evaluate data that controls what is displayed in it.

 

 

Xrm.Page.data.entity

Xrm.Page.data.entity provides methods to retrieve information specific to the record displayed on the page, the save method, and a collection of all the attributes included in the form. Attribute data is limited to attributes represented by fields on the form.

Methods


The following table lists the methods of Xrm.Page.data.entity.

Method Description
addOnSave Sets a function to be called when the record is saved.
getDataXml Returns a string representing the xml that will be sent to the server when the record is saved.
getEntityName Returns a string representing the logical name of the entity for the record.
getId Returns a string representing the GUID id value for the record.
getIsDirty Returns a Boolean value that indicates if any fields in the form have been modified.
removeOnSave Removes a function from the OnSave event hander.
save Saves the record. This method has three possible parameters.

 

 

 

 

 

Xrm.Page.data.entity Attribute Methods

The attribute object provides methods to retrieve information and perform actions on attributes. It also contains a Controls Collection.

Examples shown here are in the Sample: SDK.AttributeSamples.js library.

Methods


The following table lists the methods of the attribute object.

Method Description
addOnChange Sets a function to be called when the attribute value is changed.See also removeOnChangeAttribute Types: All
fireOnChange Causes the OnChange event to occur on the attribute so that any script associated to that event can execute.Attribute Types: All
getAttributeType Returns a string value that represents the type of attribute.Attribute Types: All
getFormat Returns a string value that represents formatting options for the attribute.Attribute Types: All
getInitialValue Returns the initial value for Boolean or optionset attributes.Attribute Types: Boolean, optionset
getIsDirty Returns a Boolean value indicating if there are unsaved changes to the attribute value.Attribute Types: All
getMax Returns a number indicating the maximum allowed value for an attribute.Attribute Types: money, decimal, integer, double
getMaxLength Returns a number indicating the maximum length of a string or memo attribute.Attribute Types: string, memo
getMin Returns a number indicating the minimum allowed value for an attribute.Attribute Types: money, decimal, integer, double
getName Returns a string representing the logical name of the attribute.Attribute Types: All
getOption Returns an option object with the name matching the argument passed to the method.Attribute Types: optionset
getOptions Returns an array of option objects representing the valid options for an optionset attribute.Attribute Types: optionset
getParent Returns the entity object that is the parent to the attribute.Attribute Types: All
getPrecision Returns the number of digits allowed to the right of the decimal point.Attribute Types: money, decimal, double, and integer
getRequiredLevel Returns a string value indicating whether a value for the attribute is required or recommended.See also setRequiredLevelAttribute Types: All
getSelectedOption Returns the option object that is selected in an optionset attribute.Attribute Types: optionset
getSubmitMode Returns a string indicating when data from the attribute will be submitted when the record is saved.See also setSubmitModeAttribute Types: All
getText Returns a string value of the text for the currently selected option for an optionset attribute.Attribute Types: optionset
getUserPrivilege Returns an array of privileges that contain Boolean values indicating if the user can create, read or update data values for an attribute.Attribute Types: All
getValue Retrieves the data value for an attribute.See also setValue.Attribute Types: All
removeOnChange Removes a function from the OnChange event hander for an attribute.See also addOnChangeAttribute Types: All
setRequiredLevel Sets whether data is required or recommended for the attribute before the record can be saved.See also getRequiredLevel.Attribute Types: All
setSubmitMode Sets whether data from the attribute will be submitted when the record is saved.See also getSubmitMode.Attribute Types: All
setValue Sets the data value for an attribute.See also getValue.Attribute Types: All

Cheers,

MS CRM 2011 JavaScript Events Part 1

Xrm NameSpaces:

  • Xrm.Page – Xrm.Page is the new crmForm, or if you are just starting: Xrm.Page is the JavaScript namespace where you can access CRM form Components ( UI Elements ) and fields.
  • Xrm.Page.ui – This namespace contains functions for manipulation of the form UI. This includes tabs, sections and fields.
  • Xrm.Page.context – Provides access to the context object. The context object provides methods to retrieve information specific to an organization, a user, or parameters that were passed to the form in a query string. ( http://msdn.microsoft.com/en-us/library/gg328399.aspx )
  • Xrm.Page.data.entity – Provides methods to retrieve information specific to the record displayed on the page, the save method and a collection of all the attributes included in the form. Attribute data is limited to attributes represented by fields on the form. ( http://msdn.microsoft.com/en-us/library/gg334720.aspx )

* Note: There are more methods, namespaces and general objects, but these are sufficient for an introduction.

* Note: Calling crmForm from the IE debugging tools no longer functions as it once did. To obtain the old functionality for debugging purposes, use:

crmForm = window.frames[0].crmForm;

Xrm = window.frames[0].Xrm;

It is also important to note that when developing for CRM 2011, you should use the “Xrm” methods rather than the older crmForm methods in your javascript.


Xrm.Page ( formerly crmForm )

Xrm.Page is the new crmForm, or if you are just starting: Xrm.Page is the JavaScript namespace where you can access CRM form Components ( UI Elements ) and fields. Almost everything that you need to do to the CRM form you can get to through here. Of note, crmForm still does exist and can be used within scripts.

Xrm.Page.getAttribute(“new_field”); This function returns an attribute on the form using the lowercase schema name. The object that it returns can be used to update the field data, fire onChange, tell if it is dirty, add additional CRM appropriate events, etc.
Xrm.Page.getControl(“new_field”); This retrieves a control of a field, which can be used to change visibility, enable or disable the field, get the type, etc.

 

 

Xrm.Page.ui

Xrm.Page.ui.getFormType(); This returns a numeric value for the type of form that is currently being displayed, i.e.: update, create, etc. (The exact numbers corresponding to each type are not covered in this post.)
Xrm.Page.ui.getViewPortWidth(); Returns how many pixels wide the view is.
Xrm.Page.ui.getViewPortHeight(); Returns how many pixels high the view is.
Xrm.Page.ui.getCurrentControl(); Returns the current active control.
Xrm.Page.ui.controls.get(“new_field”); Works just like Xrm.Page.getControl() except the Xrm.Page.ui.controls namespace has a few more functions for dealing with controls.
Xrm.Page.ui.tabs.get(“tabName”); This works like getControl except that it is for tabs. It will return a tab object that you can use to change the properties of the tab, the most useful of which include the visibility and the sections object.

Xrm.Page.context

Xrm.Page.context.getUserId(); This will return the GUID of the current user
Xrm.Page.context.getUserRoles(); Returns the current user’s role/roles.
Xrm.Page.context.isOutlookClient(); Returns whether or not a user is in the Outlook client. If you need to use a different version of a javascript function or Outlook does not support a particular feature, you can use this.
Xrm.Page.context.isOutlookOnline(); For the times when you need to determine if the outlook client is online, use this. e.g.: If you have an oData call to retrieve certain data from somewhere else in the system or you have mapping code that depends on an external web service, use this to determine if you’re online.
Xrm.Page.context.getOrgUniqueName(); Returns the unique org name for the current active organization. This is helpful for On-Premise installations that have multiple organizations or online instances.
Xrm.Page.context.getServerUrl(); Returns the url of the server.
Xrm.Page.context.getAuthenticationHeader(); Returns the authentication header required to make SOAP calls.

 

Xrm.Page.data.entity

Xrm.Page.data.entity.getId(); Returns the current entity’s GUID
Xrm.Page.data.entity.getEntityName(); Returns the current entities schema/logical name.
Xrm.Page.data.entity.save(); Forces a manual save of the entity. – Note: this function can also take an “Action”
Xrm.Page.data.entity.getIsDirty(); Determines whether or not the form is dirty, i.e. if there are any unsaved changes.

Cheers,

Asp.net With C# Sending Email (Send Password to the Email):

Asp.net With C# Sending Email (Send Password to the Email):

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using BAL;

using System.Data;

using System.Data.Sql;

using System.Data.SqlClient;

using System.Net.Mail;

using System.Web.Mail;

using System.Net;

 

 

public partial class ForgotPassword : System.Web.UI.Page

{

string forgotPwd;

string email;

string pwd = “myswamimyguru”;

protected void Page_Load(object sender, EventArgs e)

{

 

}

 

protected void btnSendSms_Click(object sender, EventArgs e)

{

BusinessAccessLayer BAL = new BusinessAccessLayer();

 

DataSet datasetValues = null;

string userid = txtRetUserId.Text;

 

try {

//datasetValues   = BAL.RetrieveforgotPwdBAL(userid);

//forgotPwd = datasetValues.Tables[0].Rows[0][“Ppassword”].ToString();

//email = datasetValues.Tables[0].Rows[0][“EmailId”].ToString();

 

txtFrom.Text = “srivivekcollegeofengineering@gmail.com”;

txtTo.Text = email;

txtSubject.Text = “Forgot Password”;

txtMailBody.Text = “Your Password is” + forgotPwd + ” Please Login with the credentials”;

}

catch (Exception ex)

{

throw;

}

finally

{

 

BAL = null;

}

}

protected void btnGetDetails_Click(object sender, EventArgs e)

{

System.Net.Mail.MailMessage mailMessege = new System.Net.Mail.MailMessage(txtFrom.Text, txtTo.Text, txtSubject.Text, txtMailBody.Text);

 

SmtpClient SMTPServer = new SmtpClient(“smtp.gmail.com”, 587);

mailMessege.IsBodyHtml = false;

 

NetworkCredential nCred = new NetworkCredential(txtFrom.Text, pwd);

SMTPServer.DeliveryMethod = SmtpDeliveryMethod.Network;

SMTPServer.UseDefaultCredentials = false;

SMTPServer.Credentials = nCred;

SMTPServer.EnableSsl = true;

SMTPServer.Timeout = 20000000;

 

try

{

SMTPServer.Send(mailMessege);

}

catch (Exception ex) {

Label1.Text = ex.ToString();

}

}

}

 

In the web.config add the following code

 

<system.net>

<mailSettings>

<smtp deliveryMethod=”SpecifiedPickupDirectory”>

<specifiedPickupDirectory pickupDirectoryLocation=”C:\mail”/>

</smtp>

</mailSettings>

</system.net>

Cheers,