Archive

Archive for June, 2011

Helpful CRM 2011 JavaScript Code snippets

How to get the logical name of the entity for the current record in CRM 2011 using Javascript

Code Snippet:  var entityName = Xrm.Page.data.entity.getEntityName();

For instance , if the current record is contact the above code will return a string “contact”

If you want to get current user id in crm 2011 form you can use Xrm.Page.context, you have to use

getUserId() method for this you can use it like below

Xrm.Page.context.getUserId()

Categories: CRM 2011 Tags:

How to create charts in MS Dynamics crm 2011 and add them to a Dashboard?

June 20, 2011 Leave a comment

Microsoft Dynamics CRM 2011  provides a new feature to customize  visualization chart against a single entity view,  so we can see graphical representation of data using your CRM views.  This helps to analyze the data in a better manner. CRM 2011 provide 5 different type of charts namely

  • Column Charts,
  • Bar Charts, 
  • Line Charts,
  • Pie Charts and
  • Funnel Charts.

Now I am going to discuss how to create charts against a entity view. We can show graphic visualization between any two fields of an entity which are related to each other. For this purpose let us take an example to create chart for contact entity’s two fields “created on” Vs “fullname” of contact.

Now we can use following steps to create chart.

step – 1   Goto  the settings area and open your solution package.

step -2  Click on the contact entity and  double click on the chart from the left menus.

step – 3 Now we can make a new chart for contact entity.

 In above image we can see  picklist field of different view and second field for chart name  now we can select 2 fields name of entity from picklist for which want want to see chart.

Now we can see no. of contact createdon different weeks in the form of a bar chart.

Now I will be discussing how to create dashboard for charts and list?

Follow the steps below.

Step -1 Goto workplace, then to Dashboard.

Step – 2  Click the new button from Dashboard ribbon tool bar (See highlighted in the image below)

Step -3   Select the layout for dashboard.

Step -4  Please provide a name to the Dashboard. If you look closely on the dashboard section you will see 4 different images 1) Represent adding a chart 2) Represent adding a list 3) Represent adding a Web resource etc. Here we will be adding a Chart, so click on the chart image.

Step 5- On clicking the chart image a new window will open (see image below).  Now simply select an entity and view along with the Chart you want to add.  Once done click ‘Ok’ button.

Now you can see dashboard for contact entity records.

Hope this helps.

Categories: CRM 2011 Tags:

Data Relation using Data Set in .Net

DataSet:

The DataSet class represents a memory-resident database. It is a container for the DataTable and DataRelation classes.DataRelationIt is a Class to establish relation with more than one data in the dataset.

DataRelation class constructor takes three arguments to establish relationship with other table.
1. Strdatarelationname(String type).
2. Parent table columan name.
3. Child table columan name.

To get all data againsed parent table column name you have to use GetChildRows method, which takes one
arguments( Strdatarelationname). and after getting all fields value of child table you can go further with your own code whatever you want.

Here below code gives you example to relate two table using particular field of table.

DataSet ds = null;
protected void Page_Load(object sender, EventArgs e)
{
ds = new DataSet();
ds.Tables.Add(MakeAuthorData());
ds.Tables.Add(MakeBookData());

DataRelation relation = new DataRelation(“Book2Author”, ds.Tables[“Authors”].Columns[“AuthorId”], ds.Tables[“Books”].Columns[“AuthorId”]);
ds.Relations.Add(relation);

grdAuthors.DataSource = ds.Tables[“Authors”].DefaultView;
grdAuthors.DataBind();

grdBooks.DataSource = ds.Tables[“Books”].DefaultView;
grdBooks.DataBind();

foreach (DataRow artistRow in ds.Tables[“Authors”].Rows)
{
string fname = (string)artistRow[“FirstName”];
string lname = (string)artistRow[“LastName”];
labReport.Text += “” + fname + ” ” + lname;
foreach (DataRow bookRow in artistRow.GetChildRows(relation)) //Get child table fields
{
string title = (string)bookRow[“Title”];
labReport.Text += “” + title;

}
}
}
private DataTable MakeAuthorData()
{
DataTable table = new DataTable();
table.TableName = “Authors”;

DataColumn idCol = new DataColumn();
idCol.ColumnName = “AuthorId”;
idCol.DataType = typeof(Int32);
idCol.AllowDBNull = false; idCol.Unique = true;

DataColumn firstNameCol = new DataColumn(“FirstName”, typeof(string));
DataColumn lastNameCol = new DataColumn(“LastName”, typeof(string));

table.Columns.Add(idCol);
table.Columns.Add(firstNameCol);
table.Columns.Add(lastNameCol);

DataRow r1 = table.NewRow();
r1[0] = 10;
r1[1] = “A”;
r1[2] = “a”;
table.Rows.Add(r1);

DataRow r2 = table.NewRow();
r2[0] = 20;
r2[“FirstName”] = “B”;
r2[“LastName”] = “b”;
table.Rows.Add(r2);

DataRow r3 = table.NewRow();
r3[0] = 30; r3[“FirstName”] = “C”;
r3[“LastName”] = “c”;
table.Rows.Add(r3);

DataRow r4 = table.NewRow();
r4[0] = 40; r4[“FirstName”] = “D”;
r4[“LastName”] = “d”;
table.Rows.Add(r4);
return table;
}

private DataTable MakeBookData()
{
DataTable table = new DataTable();
table.TableName = “Books”;

DataColumn idCol = new DataColumn();
idCol.ColumnName = “Id”;
idCol.DataType = typeof(Int32);
idCol.AllowDBNull = false;
idCol.Unique = true;
idCol.AutoIncrement = true;

DataColumn authorCol = new DataColumn(“AuthorId”, typeof(Int32));
DataColumn nameCol = new DataColumn(“Title”, typeof(string));
DataColumn priceCol = new DataColumn(“Price”, typeof(double));

table.Columns.Add(idCol);
table.Columns.Add(authorCol);
table.Columns.Add(nameCol);
table.Columns.Add(priceCol);
DataRow r1 = table.NewRow();
r1[1] = 30;
r1[2] = “Java”;
r1[3] = 49.99;
table.Rows.Add(r1);

DataRow r2 = table.NewRow();
r2[1] = 10;
r2[2] = “C#”;
r2[3] = 19.99;
table.Rows.Add(r2);

DataRow r3 = table.NewRow();
r3[1] = 40; r3[2] = “Javascript”;
r3[3] = 24.99;
table.Rows.Add(r3);

DataRow r4 = table.NewRow();
r4[1] = 40; r4[2] = “Oracle”;
r4[3] = 24.99;
table.Rows.Add(r4);
return table;
}
}

Happy Coding.

Categories: .Net Tags:

How to programmatically change the password of currently logged in user in Dot Net Nuke?

If you want to change password of currently logged in user. Then following code can be helpful for you.

Boolean changepass = UserController.ChangePassword(this.UserInfo,
YourOldPassword.Text, YourNewPassowrd.Text);

if (changepass)
{
DotNetNuke.UI.Skins.Skin.AddModuleMessage
(this, “Your Password has been changed successfully”,
DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.GreenSuccess);

}

Thanks

Categories: DotNetNuke Tags:

Some Important DotNetNuke Skin Tokens!!

DotNetNuke is a great ASP .Net based CMS with is widely used across the system. It supports many exciting features which makes management, extension of website really easy, Allowing you to concentrate on your business need. DNN  is structured in a modular way, depending upon your need you can choose between modules to be included in your website. The same modular approach has been used to Skin DNN. Skinning defines how a DNN will appear.

Following are some very useful token which can be used while creating a DNN skin.

Name Token Description
Logo [LOGO] This holds a graphics file which represents the
entity or the topic your site is about. This is
commonly referred to a banner, but don’t confuse
this with the DNN banner skin object listed next.
Banner [BANNER] This is a place holder for advertising banners.
Menu [NAV] This is the menu or navigational control of the site.
In the past, the tokens [SOLPARTMENU] and
[MENU] have been used.
Search [SEARCH] This allows users to search the content within your
site, or now, with later versions of DNN, the web.
Language [LANGUAGE] On a multilingual DNN site, it allows the user to
change his/her preferred language.
Current Date [CURRENTDATE] This simply displays the current date based on the
location of the web server.
Breadcrumb [BREADCRUMB] Lists out the hierarchical location of the page you’re
currently on.
Username [USER] This will display your username when you’re
logged in or Register when you’re not. When it
displays your username, it will link the user to their
account settings. When it displays Register, it will
link to a page where the user may register.
Login [LOGIN] Allows users to log in and log out.
Copyright [COPYRIGHT] Displays a simple copyright notice.
Name Token Description
Terms of Use [TERMS] Links to a page where the terms of use are located.
Privacy
Statement
[PRIVACY] Links to a page where the privacy statement is
mentioned.
DotNetNuke
Copyright
[DOTNETNUKE] Displays copyright information on DotNetNuke
and links to its site.
Help [HELP] Displays the text Help as a link to the site’s
administrator.
Host Name [HOSTNAME] Displays a link to the host portal within the DNN
install.
Tree View
Menu
[TREEVIEWMENU] Serves as a navigational menu with expandable and
collapsible nodes. This is typically used on the left
side of a DNN skin.
Links [LINKS] Displays a list of links to the parent and sibling
levels of pages within the site. This makes it easier
for search engines to index your site.

Hope this helps!!

Categories: DotNetNuke Tags:

How to populate a parent form lookup field value in a child form without using fetch xml in CRM 2011

June 11, 2011 Leave a comment

If we want to retrieve data of a lookup field of parent form in a child form lookup field then we can use very easy javascript code without fetch xml in CRM 2011.

Let your parent form entity be Case(Incident) in which we need to retrieve a field name Customer of type   lookup (Having two types of values i.e. contact and account) in this lookup field.

The child  entity name casetask   having 1:N relationship(Case to Case task) and  Casetask entity has a lookup field of  Customer Contact in Casetask form so we can retrieve the custtomer data which is filled in Case entity(Customer field)  in the Casetask entity (Customer Contact  field )

So we can use  following  javascript code.

Define the function SETVALUE()

function SETVALUE()
{
if (Xrm.Page.ui.getFormType() == 1)  //Check if  form is in create mode
{
var oType =crmForm.ObjectTypeCode;
if (window.top.opener.parent != null)
{
if ( (window.top.opener.parent != null) &&
    (window.top.opener.parent != null) &&
    (window.top.opener.parent.document != null) &&
    (window.top.opener.parent.document.crmForm != null)) // Check if parent form is null
{
var parentForm = window.top.opener.parent.crmForm;
if (parentForm.ObjectTypeName == “incident”) // Check if parent form type is same or different
    {
var lookupData = new Array();
var lookupItem= new Object();

if (parentForm.all.new_customerid.DataValue && parentForm.all.new_customerid.DataValue[0].id  ) //Check parent customer id field is not null 
{
var contactname   = parentForm.all.new_contact.DataValue[0].name  ;
lookupItem.id= parentForm.all.new_contact.DataValue[0].id ;
lookupItem.name = contactname ;
lookupItem.entityType = “contact” ;
lookupData[0] = lookupItem;
Xrm.Page.getAttribute(“new_customerid”).setValue( lookupData );                
}
 }
}
}

}
}

Categories: CRM, CRM 2011 Tags:

How to add a subgrid in a crmForm for displaying related records in crm 2011

June 8, 2011 Leave a comment

CRM 2011 brings along really cool and easy to use features. Today we will talk  about one of them and that is, how to show a sub grid of a related entity on a master entity.

How does it help to show related entity grid on a CRM 2011 form?

The answer is simple, it is all about usability if you can see all the communication activities of a contact on the same form without clicking or going to a new tab isn’t it wonderful. It saves you time and improves user experience.

How to do it?

Let us take a scenario to answer this question. Suppose you have an entity in CRM 2011 by name Organization now you want to show all employees of this organization in a sub grid on organization entity. For doing so please follow the following steps

1- Go to your solution and open organization entity form as shown in the image below

Image 1

CRM 2011 Form Customization screen

Customization screen

2- Now goto insert tab in left top of the organization form as shown in image below.

 

 

3- Click on the subgrid button.

Image2

How to add Sub Grid

4- select tab  in which you want to add subgrid.

image3

5- After clicking on the subgrid button (that appears on the top of the form) you will see it requires the following

Name ,Label,checkbox for display label on the form and in the datasource section you can see

1- Picklist of records (select only related record ).

2- Entity picklist(for which you want to add picklist).

3.Picklist of different views you can select according to your need.Edit and New button are also available if you want to update or make a new view as per your requirements

Now you can select different checkbox from Additional options section according to your need

Image4

Hope this helps

Categories: CRM 2011 Tags:
%d bloggers like this: