Monday 24 December 2018

Role based Dashboards – CRM 2016


Dashboards/charts visibility

  • System charts are like System views, only Users with System Administrator or System Customizer can create and view-able by all users.
  • Personal charts are like Personal views, only visible to User who created them (i.e., Unless the created user shares the personal Dashboard/chart, nobody else can see it, not even a system administrator)
Restrict User to access Dashboards/Charts
  • To restrict users to access System dashboards/Charts
    • Open security role –> Customization tab, set ‘System Chart/System Form’ access level to ‘none’
System charts Access/Privilages
System charts Access/Privileges
  • To restrict users to access Personal dashboards/Charts
    • Open security role –> Core Records tab, set ‘User Chart/User Dashboard’ access level to ‘none’
Personal charts Privileges/Access
Personal charts Privileges/Access
By removing privileges to User, he can’t access any of the Dashboards or Charts in the system.
What if you want to restrict a particular System Dashboard or Chart to all ‘Sales Person’ security role Users but not others? You cannot configure OOB this in CRM (However you can do this by Plug-ins).
we got a new feature Role based dashboards similar to Role based forms.
Role based Dashboards in CRM 2016
  • With CRM 2016, we can manage permissions for Dashboards and control which user can see each dashboards based on security roles.
  • To configure the dashboards based on security roles.
    • Open the Solution –> Dashboards, choose single dashboard and click ‘Enable Security Roles‘ button
Configure dashboards by roles
Configure dashboards by roles
  • Select the “Display only to these select security roles” and select the security roles which are allowed to view this dashboard.
  • Publish the customization’s.

Sunday 23 December 2018

Simple Example - passing the Execution context in Dynamics CRM

How to use the Execution Context in Dynamics CRM ?

From time to time you might need to add some validation to the save event of an entity, this actually used to be an approach I would use on a regular basis but since the introduction of business rules have found myself doing this less and less. But still, knowing the ability is available is handy.
When you define the onsave event function, you must tick the “Pass execution contact as first parameter” option. (See below)
Having done that you can create an onSave function with code similar to the example I have shown below. Note forgetting the “(context)”, which will take the context parameter allowing you to prevent the save when needed.
function onSave(context) {
  var saveEvent = context.getEventArgs();
  if (Xrm.Page.getAttribute("telephone1").getValue() == null) {
    // *** Note: I am using an alert for testing a notification maybe better!
    alert("Put in a phone number!");
    saveEvent.preventDefault();
  }
}
Note: This simple example might be better achieved with a business rule but when you need complex validation that can’t be implemented with a business rule this approach is useful.


 More : https://neilparkhurst.com/2015/11/11/javascript-prevent-save/

Passing Execution Context to Onchange Events


In a previous posting I provided some jscript that can be used to validate phone number formats. In order to invoke the validation for a phone number field I mentioned that you need to create an "on change" event that would pass in the attribute name and attribute description i.e.:


function Attribute_OnChange() {
PhoneNumberValidation("attributeName", "attributeDescription");
}

I thought this would provide a good example for demonstrating the ability to use the execution context because you can obtain the field name and label (by extension) via the execution context which on the surface is a good thing since you avoid hard-coding as in the example above (and you can apply this to all phone number fields in the system). And therefore in theory you could simplify that example as follows:


function PhoneNumberValidation(context) {
var phone = context.getEventSource().getName();
var phoneDesc = Xrm.Page.getControl(context.getEventSource().getName()).getLabel();
 var ret = true;
 var phone1 = Xrm.Page.getAttribute(phone).getValue();
 var phone2 = phone1;
 
 if (phone1 == null)
  return true;
  
 // First trim the phone number
 var stripPhone = phone1.replace(/[^0-9]/g, '');

 if ( stripPhone.length < 10 ) {
  alert("The " + phoneDesc + " you entered must be at 10 digits. Please correct the entry.");
  Xrm.Page.ui.controls.get(phone).setFocus();
  ret = false;
 } else {
  if (stripPhone.length == 10) {
   phone2 = "(" + stripPhone.substring(0,3) + ") " + stripPhone.substring(3,6) + "-" + stripPhone.substring(6,10);
  } else {
   phone2 = stripPhone;
  }
 
 }
 Xrm.Page.getAttribute(phone).setValue(phone2);
 return ret;
}

The only difference is that instead of the "phone" and "phoneDesc" parameters being passed into the validation function, the execution context is instead passed in and the phone attribute and its corresponding phoneDesc label are obtained via the context as local variables. The rest stays the same.

In order for this to work, you would update the "on change" event to call the PhoneNumberValidation function directly and check off the "pass execution context as first parameter" as shown:




So that's the theory and I think it demonstrates quite nicely how the execution context can be used. 

Having said that, in this particular example, I prefer using the explicit technique referenced in the original posting. The reason for this is because the on change event in this validation example (and probably relevant for most data validation cases) has a dual function - 

The first is to provide the necessary validation as part of the field on change event as the example above will accomplish quite well. 

The second is to be called from the on save event to make sure that even if users ignore the message from the on change event they will not be able to save the form via the validation from the on save event (the PhoneNumberValidation function returns a true or false value to indicate whether validation was passed or not). And when the function is called from the on change event the specific field context is not going to be there anyway making it necessary to put in some additional logic in order to handle correctly. Therefore what you gain from using the execution context in this example is likely to be offset by requirements for special handling required by the on save event. 

Saturday 22 December 2018

To prevent default save of form in Dynamics crm using javascript

To stop the save event in Javascript all you need is this
event.returnValue = false;
Tanguy the CRM tool guy (and CRM MVP) put something very interesting in the comments but I thought I would promote it to this very small blog post
The new method in CRM 2011 is the following one:
Xrm.Page.context.getEventArgs().preventDefault();
preventDefault : Cancels the save operation, but all remaining handlers for the event will still be executed.

Friday 23 November 2018

Simple javascript codes for Dynamis CRM





Dynamics crm javascript codes

Xrm.Page.getAttribue("").getValue();

Xrm.Page.getAttribute("").setValue("");

Xrm.Page.data.save()










//Saving a from
 Xrm.Page.getAttribute("field1").setValue(1);
   Xrm.Page.getAttribute("field1").setSubmitMode("always");
   setTimeout(function(){Xrm.Page.data.save().then(closeemailform, errorCallback); }, 500);

Thursday 8 November 2018

download dynamics 365 v9

Official link to download dynamics 365 v9

https://www.microsoft.com/en-us/download/details.aspx?id=57478
  • KEY                       
  • Microsoft Dynamics 365 Server (no CAL limit): KKNV2-4YYK8-D8HWD-GDRMW-29YTW

Python application - Dynamics 365


you can access the Microsoft Dynamics 365 using  the following approach.


The following method works for  dynamics 365  V9.0

NOTE: You have to register the CRM app in Azure AAD to get ClientID & secret, later those can be used to get access tokens & interact with CRM web api from outside applications like java/php/.net web applications.


- Installing ` pip install dynamics365crm-python `
- Usage If you will not use the oauth authentication and you already have an access token, call the library like this: - resource = the url of the CRM, example: https://example.crm2.dynamics.com/ ` from dynamics365crm.client import Client client = Client('RESOURCE', 'ACCESS_TOKEN') `
-If you will use the oauth authentication call the library like this: ` from dynamics365crm.client import Client client = Client('RESOURCE',CLIENT_ID', 'CLIENT_SECRET') `
- Get authorization url ` url = client.url_petition("REDIRECT_URL") `
- Exchange the code for an access token ` token =client.exchange_code('REDIRECT_URL', 'CODE') `
- Refresh token ` token = client.refresh_token('REFRESH TOKEN', 'REDIRECT_URL') `
- Set token ` token = client.set_token('TOKEN') ` 

CONTACT ENTITY CRUD 
- Get Contacts can receive orderby, filter, select, top, expand ` list_contacts = client.get_contacts() `
- Create Contact ` create_contact =client.create_contact(firstname="FIRSTNAME", lastname="LASTNAME",middlename="MIDDLENAME", emailaddress1="EMAILADDRESS") `
- Delete Contact ` delete_contact = client.delete_contact('ID') `
- Update Contact ` update_contact = client.update_contact('ID',firstname="FIRSTNAME", lastname="LASTNAME", middlename="MIDDLENAME",emailaddress1="EMAILADDRESS") `

ACCOUNT ENTITY CRUD
- Get Accounts can receive orderby, filter, select, top, expand ` get_accounts = client.get_accounts() `
- Create Account ` create_account = client.create_account(name="NAME",websiteurl="WWW.WEBSITE.COM") `
- Delete Account ` create_account = client.delete_account('ID') `
- Update Account ` update_account = client.update_account(id="ID",name="NAME") `

OPPORTUNITY ENTITY CRUD
- Get Opportunities can receive orderby, filter, select, top, expand ` list_opportunities = client.get_opportunities() `
- Create Opportunities ` create_opportunities =client.create_opportunity(name="OPPORTUNITY NAME") `
- Delete Opportunities ` delete_opportunities =client.delete_opportunity(id="OPPORTUNITY ID") `
- Update Opportunities ` update_opportunities =client.update_opportunity(id="OPPORTUNITY ID", name="OPPORTUNITY NAME",description="SOME DESCRIPTION") `

LEAD ENTITY CRUD
- Get Leads can receive orderby, filter, select, top, expand ` list_leads = client.get_leads() `
- Create Lead ` create_leads = client.create_lead(fullname="LEAD NAME",subject="LEAD SUBJECT", mobilephone="123456",websiteurl="WWW.WEBSITE.COM", middlename="MIDDLE LEAD NAME") `
 - Delete Lead ` delete_leads = client.delete_lead("ID") `
- Update Lead ` update_leads = client.update_lead(fullname="LEAD NAME",subject="LEAD SUBJECT", mobilephone="123456",websiteurl="WWW.WEBSITE.COM", middlename="MIDDLE LEAD NAME") `

CAMPAIGN ENTITY CRUD
- Get Campaigns can receive orderby, filter, select, top, expand ` list_campaigns = client.get_campaigns() `
- Create Campaign ` create_campaign =client.create_campaign(name="CAMPAIGN NAME", description="SOMEDESCRIPTION") `
- Delete Campaign ` delete_campaign = client.delete_campaign(id="ID") `
- Update Campaign ` update_campaign = client.update_campaign(id="ID",name="CAMPAIGN NAME", description="SOME DESCRIPTION") `
-Requirements - requests
-Tests ` dynamics365crm/test.py `

Friday 5 October 2018

Query to get all the Entity and Entity Field Name in Dynamics crm onpremisis


Query to get all the Entity and Entity Field Name in Dynamics crm onpremisis


USE Contoso_MSCRM
GO

SELECT  EntityView.Name AS EntityName, LocalizedLabelView_1.Label AS EntityDisplayName,
       AttributeView.Name AS AttributeName, LocalizedLabelView_2.Label AS AttributeDisplayName
FROM    LocalizedLabelView AS LocalizedLabelView_2 INNER JOIN
       AttributeView ON LocalizedLabelView_2.ObjectId = AttributeView.AttributeId RIGHT OUTER JOIN
       EntityView INNER JOIN
       LocalizedLabelView AS LocalizedLabelView_1 ON EntityView.EntityId = LocalizedLabelView_1.ObjectId ON
       AttributeView.EntityId = EntityView.EntityId
WHERE   LocalizedLabelView_1.ObjectColumnName = 'LocalizedName'
 AND LocalizedLabelView_2.ObjectColumnName = 'DisplayName'
 AND LocalizedLabelView_1.LanguageId = '1033'
 AND LocalizedLabelView_2.LanguageId = '1033'
 AND EntityView.Name IN ('Account','Contact') //comment this to get all entity 
ORDER BY EntityName, AttributeName

Monday 1 October 2018

SQL Query to get the List of customized Entity in Dynamics CRM



SQL Query to get the List of customized Entity in Dynamics CRM onpremisis



SELECT
DISPLAYNAME.LABEL 'Display Name',
EV.NAME 'Logical Name',
ObjectTypeCode 'Object Type Code'
FROM
ENTITYVIEW EV INNER JOIN
LOCALIZEDLABELLOGICALVIEW DISPLAYNAME
ON (EV.ENTITYID = DISPLAYNAME.OBJECTID) AND (DISPLAYNAME.OBJECTCOLUMNNAME = 'LOCALIZEDNAME')
WHERE
LANGUAGEID = 1033 -- Add this if you want to filter records using language Id. For Example : LANGUAGEID 1033 is English
AND ISCUSTOMENTITY = 1 -- Remove this if you want to show the system entities as well
--AND ISACTIVITY = 0 -- Add this if you want to filter out the activity entity
AND EV.NAME NOT LIKE '%MSDYN%' -- Add this if you want to remove like post album, filter, etc
ORDER BY 2

Monday 24 September 2018

Chrome update bug in dynamics CRM

Chrome update bug in dynamics CRM

Bug : when you create a second contact using quick Create in Account from. the quick create form wont display completely.

solution : Copy paste the following code in the quick create form in contact Entity.



function chromeFix() {
var isChrome = !!window.chrome && !!window.chrome.webstore; //checks browser
if (isChrome) {
if (window.top.document.getElementsByClassName("mscrm-globalqc-iframe")[0].style.height == "0px") {

window.top.document.getElementsByClassName("mscrm-globalqc-iframe")[0].style.height = "200px"; //your quick view form height
}
}
}

Friday 31 August 2018

Entity Type Codes in Dynamics CRM


Entity Type Codes in Dynamics CRM On-premisis verion


You can retrieve the type codes for all entities by running the following SQL Query in CRM database.
1
select * from EntityView order by ObjectTypeCode
Type codes below 10000 are reserved for Microsoft CRM systementities. Custom entities have a value greater than or equal to 10,000. Note that custom entity object type codes may change during import and are not guaranteed to be the same between systems.
The following table shows the type codes for system entities.
Entity NameObjectTypeCode
Account1
Contact2
Opportunity3
Lead4
Annotation5
BusinessUnitMap6
Owner7
SystemUser8
Team9
BusinessUnit10
PrincipalObjectAccess11
RolePrivileges12
SystemUserLicenses13
SystemUserPrincipals14
SystemUserRoles15
AccountLeads16
ContactInvoices17
ContactQuotes18
ContactOrders19
ServiceContractContacts20
ProductSalesLiterature21
ContactLeads22
TeamMembership23
LeadCompetitors24
OpportunityCompetitors25
CompetitorSalesLiterature26
LeadProduct27
RoleTemplatePrivileges28
Subscription29
FilterTemplate30
PrivilegeObjectTypeCodes31
SalesProcessInstance32
SubscriptionSyncInfo33
SubscriptionTrackingDeletedObject35
ClientUpdate36
SubscriptionManuallyTrackedObject37
TeamRoles40
PrincipalEntityMap41
SystemUserBusinessUnitEntityMap42
PrincipalAttributeAccessMap43
PrincipalObjectAttributeAccess44
PrincipalObjectAccessReadSnapshot90
RecordCountSnapshot91
Incident112
Competitor123
DocumentIndex126
KbArticle127
Subject129
BusinessUnitNewsArticle132
ActivityParty135
UserSettings150
ActivityMimeAttachment1001
Attachment1002
InternalAddress1003
CompetitorAddress1004
CompetitorProduct1006
Contract1010
ContractDetail1011
Discount1013
KbArticleTemplate1016
LeadAddress1017
Organization1019
OrganizationUI1021
PriceLevel1022
Privilege1023
Product1024
ProductAssociation1025
ProductPriceLevel1026
ProductSubstitute1028
SystemForm1030
UserForm1031
Role1036
RoleTemplate1037
SalesLiterature1038
SavedQuery1039
StringMap1043
UoM1055
UoMSchedule1056
SalesLiteratureItem1070
CustomerAddress1071
SubscriptionClients1072
StatusMap1075
DiscountType1080
KbArticleComment1082
OpportunityProduct1083
Quote1084
QuoteDetail1085
UserFiscalCalendar1086
SalesOrder1088
SalesOrderDetail1089
Invoice1090
InvoiceDetail1091
SavedQueryVisualization1111
UserQueryVisualization1112
RibbonTabToCommandMap1113
RibbonContextGroup1115
RibbonCommand1116
RibbonRule1117
RibbonCustomization1120
RibbonDiff1130
ReplicationBacklog1140
FieldSecurityProfile1200
FieldPermission1201
SystemUserProfiles1202
TeamProfiles1203
AnnualFiscalCalendar2000
SemiAnnualFiscalCalendar2001
QuarterlyFiscalCalendar2002
MonthlyFiscalCalendar2003
FixedMonthlyFiscalCalendar2004
Template2010
ContractTemplate2011
UnresolvedAddress2012
Territory2013
Queue2020
License2027
QueueItem2029
UserEntityUISettings2500
UserEntityInstanceData2501
IntegrationStatus3000
ConnectionRole3231
ConnectionRoleAssociation3232
ConnectionRoleObjectTypeCode3233
Connection3234
Equipment4000
Service4001
Resource4002
Calendar4003
CalendarRule4004
ResourceGroup4005
ResourceSpec4006
ConstraintBasedGroup4007
Site4009
ResourceGroupExpansion4010
InterProcessLock4011
EmailHash4023
DisplayStringMap4101
DisplayString4102
Notification4110
ActivityPointer4200
Appointment4201
Email4202
Fax4204
IncidentResolution4206
Letter4207
OpportunityClose4208
OrderClose4209
PhoneCall4210
QuoteClose4211
Task4212
ServiceAppointment4214
Commitment4215
UserQuery4230
RecurrenceRule4250
RecurringAppointmentMaster4251
EmailSearch4299
List4300
ListMember4301
Campaign4400
CampaignResponse4401
CampaignActivity4402
CampaignItem4403
CampaignActivityItem4404
BulkOperationLog4405
BulkOperation4406
Import4410
ImportMap4411
ImportFile4412
ImportData4413
DuplicateRule4414
DuplicateRecord4415
DuplicateRuleCondition4416
ColumnMapping4417
PickListMapping4418
LookUpMapping4419
OwnerMapping4420
ImportLog4423
BulkDeleteOperation4424
BulkDeleteFailure4425
TransformationMapping4426
TransformationParameterMapping4427
ImportEntityMapping4428
RelationshipRole4500
RelationshipRoleMap4501
CustomerRelationship4502
CustomerOpportunityRole4503
Audit4567
EntityMap4600
AttributeMap4601
PluginType4602
PluginTypeStatistic4603
PluginAssembly4605
SdkMessage4606
SdkMessageFilter4607
SdkMessageProcessingStep4608
SdkMessageRequest4609
SdkMessageResponse4610
SdkMessageResponseField4611
SdkMessagePair4613
SdkMessageRequestField4614
SdkMessageProcessingStepImage4615
SdkMessageProcessingStepSecureConfig4616
ServiceEndpoint4618
AsyncOperation4700
WorkflowWaitSubscription4702
Workflow4703
WorkflowDependency4704
IsvConfig4705
WorkflowLog4706
ApplicationFile4707
OrganizationStatistic4708
SiteMap4709
ProcessSession4710
WebWizard4800
WizardPage4802
WizardAccessPrivilege4803
TimeZoneDefinition4810
TimeZoneRule4811
TimeZoneLocalizedName4812
Solution7100
Publisher7101
PublisherAddress7102
SolutionComponent7103
Dependency7105
DependencyNode7106
InvalidDependency7107
Post8000
PostRole8001
PostRegarding8002
PostFollow8003
PostComment8005
PostLike8006
Report9100
ReportEntity9101
ReportCategory9102
ReportVisibility9103
ReportLink9104
TransactionCurrency9105
MailMergeTemplate9106
ImportJob9107
WebResource9333
SharePointSite9502
SharePointDocumentLocation9508
Goal9600
GoalRollupQuery9602
Metric9603
RollupField9604

Git Basic working

  Develop = dev   r