Adding Attach File button on Custom Activity Type Entity
22 May 2012 1 Comment
in MS CRM 2011, Step By Step MS CRM 2011
MS CRM 2011 introduced a new feature to create custom activity type entity. While creating custom activity type entity, even if we will enable Notes (include attachments), we won’t get Attach File button just like we used to get in any custom entity where Notes is enabled. So what if you want to get that button?? you just need to follow this post
To create custom Attach File button we need
- A Webresource to form notes URL.
- We need Attach File image to show it in custom Ribbon button.
- We need to create custom Ribbon Button.
Let’s first create webresource to open notes dialog.
Let’s first create a solution and add our custom activity to that solution. Once entity is added create a new web resource let’s say Notes.js and add below function to that webresourc
function FileAttachment()
{
var EntityID =Xrm.Page.data.entity.getId(); // to get entity id
var ServicerURL=Xrm.Page.context.getServerUrl(); // to get server url
var NotesURL=ServicerURL+”/notes/edit.aspx?hideDesc=1&pId=”+ EntityID +”&pType=”;
var etc = Xrm.Page.context.getQueryStringParameters().etc; // to get entity type code, make sure not to hard code it, because it could changed in another deployment
var features = ‘copyhistory=no,top=110,left=280,width=600,height=30′;
openStdWin(NotesURL +etc,”",features);
}
Save and close webresourc and publish it.
Let’s create a .png image webresource to store image for attachment ribbon button. Follow below steps to create image webresource
- Navigate to Solution->Webresourc and click New
- Enter below information
- Name: AddAttachment_16.png
- Display Name: AddAttachment_16
- Type: PNG format
- Language: English
** we need to upload attachment_16.png, You can find this image for attachment in sdk\resources\images\ribbon folder.
we need to follow same steps to create webresourc for attachment_32.png image.
Now we have our web resources ready so let’s create our custom ribbon button. Export solution as unmanaged state and unzip solution. We need to edit customization.xml file in visual studio and add below code for Ribbon definition:
<RibbonDiffXml>
<CustomActions>
<CustomAction Id=”MYDEMO.Form.new_CustomActivity.MainTab.Actions.attachment.CustomAction” Location=”Mscrm.Form.new_CustomActivity.MainTab.Actions.Controls._children” Sequence=”41″>
<CommandUIDefinition>
<Button Id=”MyDemo.Form.new_CustomActivity.MainTab.Actions.attachment” Command=”MYDEMO.Form.new_CustomActivity.MainTab.Actions.attachment.Command” Sequence=”29″ ToolTipTitle=”$LocLabels:MYDEMO.Form.new_CustomActivity.MainTab.Actions.attachment.LabelText” LabelText=”$LocLabels:MYDEMO.Form.new_CustomActivity.MainTab.Actions.attachment.LabelText” ToolTipDescription=”$LocLabels:MYDEMO.Form.new_CustomActivity.MainTab.Actions.attachment.Description” TemplateAlias=”o1″ Image16by16=”$webresource:MyDemo_Attachment_16.png” Image32by32=”$webresource:MyDemo_Attachment_32.png” />
</CommandUIDefinition>
</CustomAction>
</CustomActions>
<Templates>
<RibbonTemplates Id=”Mscrm.Templates”></RibbonTemplates>
</Templates>
<CommandDefinitions>
<CommandDefinition Id=”MYDEMO.Form.new_CustomActivity.MainTab.Actions.attachment.Command”>
<EnableRules>
<EnableRule Id=”MYDEMO.Form.new_CustomActivity.MainTab.Actions.attachment.Command.EnableRule.FormStateRule” />
</EnableRules>
<DisplayRules />
<Actions>
<JavaScriptFunction FunctionName=”FileAttachment” Library=”$webresource:MyDemo_Attachment.js” />
</Actions>
</CommandDefinition>
</CommandDefinitions>
<RuleDefinitions>
<TabDisplayRules />
<DisplayRules />
<EnableRules>
<EnableRule Id=”MYDEMO.Form.new_CustomActivity.MainTab.Actions.attachment.Command.EnableRule.FormStateRule”>
<FormStateRule State=”Existing” Default=”false” InvertResult=”false” />
</EnableRule>
</EnableRules>
</RuleDefinitions>
<LocLabels>
<LocLabel Id=”MYDEMO.Form.new_CustomActivity.MainTab.Actions.attachment.Description”>
<Titles>
<Title languagecode=”1033″ description=”attachment Description” />
</Titles>
</LocLabel>
<LocLabel Id=”MYDEMO.Form.new_CustomActivity.MainTab.Actions.attachment.LabelText”>
<Titles>
<Title languagecode=”1033″ description=”Attach File” />
</Titles>
</LocLabel>
</LocLabels>
</RibbonDiffXml>
Zip your solution and import it. Now you should be able to see attachment button in your custom entity under action group like below
Enjoy!!
make sure to rate this post if you like it
Get Parent Customer ID based on contact id
30 Apr 2012 Leave a Comment
in MS CRM 2011
sometime we have requirement to get contact’s parent customer id, if you have same requirment you can use below code, make sure
function ParentCustomerID(ContactId) {
var context = Xrm.Page.context;
var serverUrl = context.getServerUrl();
var ODataPath = serverUrl + “/XRMServices/2011/OrganizationData.svc”;
var retrieveParentCustomer= new XMLHttpRequest();
retrieveParentCustomer.open(“GET”, ODataPath + “/ContactSet(guid’” + ContactId+ “‘)”, false);
retrieveParentCustomer.setRequestHeader(“Accept”, “application/json”);
retrieveParentCustomer.setRequestHeader(“Content-Type”, “application/json; charset=utf-8″);
retrieveParentCustomer.onreadystatechange = function() {
retrieveParentCustomerCallBack(this);
};
retrieveParentCustomer.send();
}
function retrieveParentCustomerCallBack(retrieveParentCustomer) {
if (retrieveParentCustomer.readyState == 4 /* complete */) {
if (retrieveParentCustomer.status == 200) {
var retrievedParent = this.parent.JSON.parse(retrieveParentCustomer.responseText).d;
alert(retrievedParent.ParentCustomerId.Id); //for id
alert(retrievedParent.ParentCustomerId.Name); //for name
}
}}
Enjoy !!!
Are you interested in your connection list ??
25 Apr 2012 1 Comment
in MS CRM 2011, Sitemap, Step By Step MS CRM 2011
If you are a sales person and using MS CRM 2011, I am sure you will be interested in your connection lists, so that you can easily associated/disassociate yourself with MS CRM records like account contact. So how can you see your connection through OOB way, you need to follow below steps:
- Navigation Setting->Administration->Users->select your record and open it.
- Navigate to Connection from left navigation items under common section.
You can see all of your connected record.
But what about getting list of your connection directly from left navigation from MS CRM home page that will be great right ? we can easily create link in left navigation are to show view in MS CRM 2011.
So what we need to get that list :
- Need to create Custom view to display connected entity record with you.
- Need to get GUID of that view.
- Modify site map to add new sub area item.
Here is step by step instruction
Create a Custom View to Show connected records and get View ID
- Create a new Solution and add connection entity in your solution.
- Navigation to Views under connection entity and select New.
- Enter “My Connection” under name field and click Ok.
- Click on “Edit filter criteria” under common tasks.
- Add filter criteria like below and click Ok.
- Click on “Add columns” to add required colums (make sure to add Connected From field).
- Press F11 to get view URL.
- Copy View ID from last, like below
http://Server:port/organization/tools/vieweditor/viewManager.aspx?appSolutionId=%7b739D3A05-017B-E111-88DE-000C296BC8C9%7d&entityId=%7bC7866019-D3D1-40D7-B483-381FCDCCFFB2%7d&id=%7bD7A29797-EF8D-E111-8B09-000C296BC8C9%7d#
- Save and Close view.
- Set this view as Default from more actions.
Now we have created a view and fetched it’s guid, so let’s modify our site map.
You can customize site map manually or customize using wonderful tool Sitemap Editor.
I have used sitemap editor here, first you need to connect to your organization using sitemap editor once you are connected Click on “Load SiteMap” button to load default sitemap from your CRM.
Let’s say we want to create sub area item under My work, follow below steps to create new sub area
- Navigation to Site Map->Area(Workplace)->Group(MyWork).
- Right click on Group(myWork) and select Add SubArea.
- Enter below information
Id : “MyConnection”
Entity: Connection
Icon: specify icon this subarea.
Title : My Connection
Description: To Show my connection.
URL: _root/homepage.aspx?etn=connection&viewid=%7bC4EB2710-A6A1-4CFD-BC94-664416807432%7d&viewtype=1039 //make sure to replace viewid with the id that we created
- Click on Save button to save configuration for subarea.
- Click on “Update SiteMap” to update sitemap in MS CRM 2011.
- Start MS CRM you should get your “My Coonection” subarea under MyWork.
Enjoy !!!
A managed solution cannot overwrite the SavedQuery component with Id=xxxx-xxx-xxx-xxx-xxxx.. Error
23 Apr 2012 Leave a Comment
in MS CRM 2011
Are you getting below error when trying to import managed solution exported from your dev environment where Activity feed is configured.
A managed solution cannot overwrite the SavedQuery component with Id=xxxx-xxx-xxx-xxx-xxxx which has an unmanaged base instance.The most likely scenario for this error is that an unmanaged solution has installed a new unmanaged SavedQuery component on the target system, and now a managed solution from the same publisher is trying to install that same SavedQuery component as managed. This will cause an invalid layering of solutions on the target system and is not allowed.
If yes, you need to remove Activity feed configuration from source system before exporting your solution. You need to follow below steps
- Open your Dev envornment.
- Navigate to Activity Feeds Configuration under Setting->System.
- Delete all configuration records except for user entity.
- Delete user entity record.
Now you can export your solution, make sure to click on “Publish All Customization” during export step.
Once solution imported into production envirnment, you can configure activity feed again.
Enjoy !!!
reference : http://blogs.msdn.com/b/crm/archive/2012/01/26/activity-feeds-solution-amp-development-environment.aspx
MS CRM 2011 Technical Interview Question Part -1
18 Apr 2012 2 Comments
in MS CRM 2011
I have seen many times, where CRM developers asking for common interview question in CRM development forums. I am writing this post to collect some common question on MS CRM technical side that can crm developers community
- Explain some new features in MS CRM 2011.
- What are the different webservice available in MS CRM 2011.
- Which service can be used to access metadata information.
- What are the different ways to consume MS CRM webservice from client side?
- Rest Vs Soap.
- Difference between Dialog and Workflow.
- What is Solution?
- Difference between Managed and unmanaged solution.
- Is it possible to register plugin through solution?
- What is field level security?
- How can we use auditing in MS CRM 2011.
- What is the use of document location entity in MS CRM 2011.
- How can we create a custom Ribbon button.
- How can we rename a custom Ribbon button.
- How can we open a custom webpage from ribbon button.
- How can we use Filtered views in MS CRM 2011.
- What is Webresource and what the different types of webresource.
- How can deploy a Silverlight webresource in MS CRM 2011.
- What is the use of subgrids?
- What are the basic steps involved in developing plugin.
- What is the use of tracingService in plugin development.
- What are the new messages introduced for plugins in MS CRM 2011?
- What is sandbox plugin.
- What are the different ways to create custom report for MS CRM 2011.
- Difference between Early bound and late bound.
Enjoy !!
Getting Current User Date and Time Format setting using Javascript MS CRM 2011
11 Apr 2012 5 Comments
in MS CRM 2011
If you are looking to get current user Date and Time format you can use below code for the same
function RetrieveUserSettingRecord() {
var context;
var serverUrl;
var ODataPath;
context = Xrm.Page.context; //get context
serverUrl = context.getServerUrl();
ODataPath = serverUrl +“/XRMServices/2011/OrganizationData.svc”;
var UserID = Xrm.Page.context.getUserId(); //get current user id from context
var RetrieveUserSetting = new XMLHttpRequest();
RetrieveUserSetting.open(“GET”, ODataPath + “/UserSettingsSet(guid’” + UserID + “‘)”, true);
RetrieveUserSetting.setRequestHeader(“Accept”, “application/json”);
RetrieveUserSetting.setRequestHeader(“Content-Type”, “application/json; charset=utf-8″);
RetrieveUserSetting.onreadystatechange =function() {
RetrieveUserSettingCallBack(this);
};
RetrieveUserSetting.send();
}
function RetrieveUserSettingCallBack(retrievedUserSetting) {
if (retrievedUserSetting.readyState == 4 /* complete */) {
if(retrievedUserSetting.status == 200) {
var retrievedUser = this.parent.JSON.parse(retrievedUserSetting.responseText).d;
if (retrievedUser.TimeFormatString != null)
alert(retrievedUser.TimeFormatString);
if (retrievedUser.DateFormatString != null)
alert(retrievedUser.DateFormatString);
}}
}
Enjoy !!
Show Loading message during function execution in CRM Form
21 Mar 2012 Leave a Comment
in JS Script, MS CRM 2011, MS CRM 4.0
I found one question in CRM Development form where user asked to show some processing message during long function execution, we have done this in many projects, so I thought to write this post so that it can be help CRM developers. if you are doing some processing or calling any webservice which is taking time to execute and you want to show loading messsage to user you can use below function
function showLoadingMessage() {
tdAreas.style.display = ‘none’;
var newdiv = document.createElement(‘div’);
newdiv.setAttribute(‘id’, “msgDiv”);
newdiv.valign = “middle”;
newdiv.align = “center”;
var divInnerHTML = “<table height=’100%’ width=’100%’ style=’cursor:wait’>”;
divInnerHTML += “<tr>”;
divInnerHTML += “<td valign=’middle’ align=’center’>”;
divInnerHTML += “<img alt=” src=’/_imgs/AdvFind/progress.gif’/>”;
divInnerHTML += “<div/><b>Working…</b>”;
divInnerHTML += “</td></tr></table>”;
newdiv.innerHTML = divInnerHTML;
newdiv.style.background = ‘#FFFFFF’;
newdiv.style.fontSize = “15px”;
newdiv.style.zIndex = “1010″;
newdiv.style.width = document.body.clientWidth;
newdiv.style.height = document.body.clientHeight;
newdiv.style.position = ‘absolute’;
document.body.insertBefore(newdiv, document.body.firstChild);
document.all.msgDiv.style.visibility = ‘visible’;
}
it will display message like below
once processing is done you can hide this message using below code
document.all.msgDiv.style.visibility = ‘hidden’;
Enjoy !!!
Microsoft Dynamics CRM Q2 2012 Service Update Video
09 Mar 2012 Leave a Comment
in MS CRM 2011
Check out this video for Q2 2011 Service Update : http://www.youtube.com/watch?v=5HVqc5MthbI&feature=uploademail
Send Email through Code using Late Bound MSCRM 2011
02 Mar 2012 Leave a Comment
in MS CRM 2011
If you want to send mail through sdk using late bound you can use below function
private void CreateMail(IOrganizationService service,Guid _ contactid,Guid _From)
{
//create activityparty
Entity Fromparty = new Entity(“activityparty”);
Entity Toparty = new Entity(“activityparty”);
//set partyid
//You can refer http://msdn.microsoft.com/en-us/library/gg328549.aspx to get acitivity party entity attribute
Toparty[“partyid"]= new EntityReference(“contact”, _ contactid));
Fromparty["partyid"]= new EntityReference(“systemuser”, _From));
//create email and set attributes
Entity _Email = new Entity(“email”);
_Email["from"] = new Entity[] { Fromparty };
_Email["to"] = new Entity[] { Toparty };
_Email["directioncode"] = true;
_Email["regardingobjectid"] = new EntityReference(“contact”, _contactid);
Guid EmailID = service.Create(_Email);
}
Enjoy !!!
Display mixed content error in IE
27 Feb 2012 Leave a Comment
in MS CRM 2011, SilverLight Tags: production environment
During one of our release we started getting bellow error, while we tried to access our custom silverlight dashboard in MS CRM 2011.
we were not getting this error in our development environment, it was comming only in production environment. when I tried to search about this error I found http://msdn.microsoft.com/en-us/library/ie/ee264315%28v=vs.85%29.aspx and I enabled below setting and it worked








