Thursday, 10 December 2020

Dashboard

Q.What is a dashboard.

Set default dashboard for user
Use List , View , Personel view in dashboard.
Use web resource in Dashboard.

User of fiddler in MS CRM



Steps to be considered before taking Fiddler Traces for this issue:
---> Cache is cleared completely.
---> No other browser windows are open.
---> Let the fiddler run from the start, meaning before logging into CRM.
Steps for capturing FIDDLER Traces:
You can download the Fiddler tool from : http://www.telerik.com/download/fiddler
Steps :
1.        Open the Fiddler tool.
2.        Click on Tools option.
3.        Click on the Fiddler options.
4.        Select the HTTPS tab.
5.        Put a check mark on Decrypt HTTPS traffic option.
6.        Click on Ok and Save the settings.
7.        Check that Fiddler has started to capture the logs.
8.         Reproduce the issue.
8.        Once done, click on File>Save>Save All Sessions in order to save the trace file.
Refer this link- https://blogs.msdn.microsoft.com/crminthefield/2011/05/19/using-fiddler-http-debugger-for-crm-troubleshooting-and-performance-tuning/

Thursday, 10 May 2018

Working Issue

1. background workflow will not store the user who run the workflow - for this choose Real time work flow

2. User added in Dynamics not showing in  CRM - Check weather user added in other organisation or not.

3. We can create new organisation - with minimal copy.

4. How to set zero value  by using workflow.

5. User added in office 365 is also showing inside unable user in CRM-

6. On update show values before and after updation using plugin

7. What  preEntity.Attributes.Contains("new_10agingofchanceofsuccess")   does ?
Ans- It check if attribute have value or null

8. The plug-in type could not be found in the plug-in assembly:
https://community.dynamics.com/enterprise/b/crmfortressdynamics365/archive/2016/06/23/issue-the-plug-in-type-could-not-be-found-in-the-plug-in-assembly


9.While registering plugin error was coming that - No assembly was selected.
In plugin class was not public
Dll might be wrong


10. https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/sample-code-directory

11. All status reason/ Status code - https://technet.microsoft.com/en-us/library/dn531157.aspx

12. Slow loading issue of CRM -
https://blogs.msdn.microsoft.com/crminthefield/2012/04/09/using-the-crm-diagnostics-page-to-capture-network-performance/

13. How we can export form in word document -

14.CRM data saved from Chrome book is not saving -

15. Liscense assigned to office 365 that user is also showing in CRM -

16.I shared a word  template based on security roles but it is not showing to that particular user who hav that role ?
Ans - Check 1- Enable security role of Word template.
Check 2- Check Security roles , Business Management.
Check 3- In Business Management tab scroll down  check - if Document generation is radio button is selected or not - This I had forgot .

http://www.goisc.com/blog-post/crm-2016-insufficient-permissions-error-when-downloading-a-word-template/

17.Records more than 5000 was not fetching by query expression ?

 var crmService = CRMHelperClass.GetCRMService();
                QueryExpression qe = new QueryExpression();
                qe.EntityName = "opportunity";
                qe.ColumnSet = new ColumnSet();
                // qe.ColumnSet.Columns.Add("XX_estdateoffirstinvoice");
                //qe.ColumnSet.AllColumns = true;
                qe.ColumnSet = new ColumnSet(new string[] { "new_XXX1",new_xxx2  });
                //Condition where task attribute equals account id.
                ConditionExpression condition = new ConditionExpression();
                condition.AttributeName = "statecode";
                condition.Operator = ConditionOperator.Equal;
                condition.Values.Add(0);
                qe.Criteria.AddCondition(condition);
             

                //Code if Opportunity have more than 5000 records
                qe.PageInfo = new PagingInfo();
                qe.PageInfo.Count = 5000;
                qe.PageInfo.PageNumber = 1;
                qe.PageInfo.ReturnTotalRecordCount = true;

                EntityCollection ec = crmService.RetrieveMultiple(qe);

                int totalCount = ec.Entities.Count;
                while (ec.MoreRecords)
                {
                    qe.PageInfo.PageNumber += 1;
                    qe.PageInfo.PagingCookie = ec.PagingCookie;
                    ec = crmService.RetrieveMultiple(qe);
                    totalCount = totalCount + ec.Entities.Count;

                }
                //Code ends
                foreach (Entity r in ec.Entities)
                {
                    statusCode = ((OptionSetValue)r.Attributes["statuscode"]).Value;
                    if (statusCode == 1)  // if Opp in INprogress
                    {
                        if (r.Contains())
                        {
                              "Your logic"
                        }
                    }
                   }
18. To fetch a particular record -
var crmService = CRMHelperClass.GetCRMService();
Entity r = crmService.Retrieve("opportunity", new Guid("41F484DF-4222-E811-8116-5065F38A4BC1"), new ColumnSet(true));
                if (r != null)
                {}

https://community.dynamics.com/crm/b/passiondynamics/archive/2018/01/03/insert-dynamic-values-from-custom-entities-in-an-email-template-microsoft-dynamics-crm

https://community.dynamics.com/crm/b/passiondynamics/archive/2018/01/03/insert-dynamic-values-from-custom-entities-in-an-email-template-microsoft-dynamics-crm
 https://archive.codeplex.com/?p=crmcustomemails
https://community.dynamics.com/crm/b/passiondynamics/archive/2018/01/03/insert-dynamic-values-from-custom-entities-in-an-email-template-microsoft-dynamics-crm


19. Getting error

ACS10002: An error occurred while processing the SOAP body. ACS50000: There was an error issuing a token. ACS50005: Token encryption is required but no encrypting certificate is configured for the relying party.
Trace ID: 6d30e008-0068-4ba7-afcc-e5b688bab38e
Timestamp: 2018-04-23 12:16:08Z

Its a ACS call issue .

20, User Reported that he can login in CRM from IE but cant login from Chrome its displaying error 
Soln- Its a browser issue so go and clear cache of browser.

21.- Work flow issue - In process  I deactivated a process which was created by some one else. So after that when i activated it I got error. Access issue.But in customization I could see that it was enabled.

Remedy - I went in process and I assigned that process to me then I activated it worked.
Also the user who created this workflow was admin was not a CRM user. So the main problem was this only.

22. While updating Notes i am getting error -  Using the fiddler i found that some workflow was disturbing.So I

23. How to add remove user from sandbox -
https://www.inogic.com/blog/2017/07/how-to-add-or-remove-users-from-sandbox-instance-in-dynamics-crm365/

https://docs.microsoft.com/en-us/dynamics365/customer-engagement/admin/manage-sandbox-instances

Well if we enable admin mode then only admin and system customiser will be able to login.

24. How to set a dashboard as default to all users-
Go - setting --> customisation --> entity --> view --> click on set as default
But if some managed code is set as default then first remove it else it will not work.

25. Set default view as created on
setting--> entity --> view --> configure

26. In crm 9 there is no need too use site map to delete area sub area it is in built.
Go in setting --> customisation  --> client extension
https://www.catapulterp.com/edit-site-map-using-new-microsoft-dynamics-sitemap-designer/


27.How to generate Early Bound Class-  I generated early bound class using CRMscvTool
1)Be sure that you have 9.0 version sdk for 9.0 version of CRM - To check sdk version hover on pligin registration tools inside SDK tool.
2)Run CMd as admin
3)You can use service account or account which has admin permission.
4) On line & On Premise have little bite different Command.
5) In CMD browse to CRM svc tools and paste this below command
CrmSvcUtil.exe /url:https://<organizationUrlName>.api.crm.dynamics.com/XRMServices/2011/Organization.svc    /out:<outputFilename>.cs /username:<username> /password:<password>     /namespace:<outputNamespace> /serviceContextName:<serviceContextName>  ---- Online

C:\Users\xxxx\Desktop\xSDK\Tools\CoreTools>CrmSvcUtil.exe /url:https://yyyy.api.crm.dynamics.com/XRMServices/2011/Organization.svc    /out:GeneratedCode.cs /username:uuuu /password:ppppp /namespace:XRM /serviceContextName:angusContext
CrmSvcUtil : CRM Service Utility [Version 9.0.0.9154]
c 2017 Microsoft Corporation. All rights reserved

Code written to C:\Users\xxx\Desktop\xSDK\Tools\CoreTools\GeneratedCode.cs.


6) api.crm.dynamics.com/XRMService - can be get from customisation - developer - organisation


28)CRM rest builder tool - This tool can be used to generate javascript code - for retriving  etc.
https://github.com/jlattimer/CRMRESTBuilder/
Click on release and download the Zip file.Then Import this zip file.

29) How to move customiation from Sandbox to Prod- Create a solution -- add the entity whoes customisation you want to move. then click onn export .
Go in Prod --> customisation --> Import.

30. I had an requirement to add qty = 1 to a int field  when the form was loading . Also I had to add qty = 1 to already created records.
Ans- First I written a WF to update the qty=1 for existed records. .Create wf --> go in advance slect that view which do not hav qty = 1 then select all records and run workflow.

Then disable this work flow .


31. On opening  crm it was opening in mutiple tab which was making crm to get hanged.
Sol- It was happening only in my machine
Clear cache , history , Add crm as trusted site from internet option ,
IN crm




Friday, 19 January 2018

Templates in CRM

                                                     Templates in MS CRM 

Templates in CRM is used to create a template of particular format and setting data in that template.
Templtes can be of document


Document Template-
To create a template -- go in setting --> click on new  --> select entity -->word deocument --> select entity--> select field .

Save this.

To check this document we can go in that entity and click on word template ribbon . Some time these ribbon can be blank. If we click that template then it will .

Limitation - In MS CRM Email template will not create automatically . You have to manually to go and create Template and putting variables


Working - https://community.dynamics.com/crm/b/meganwalker/archive/2018/01/17/miscellaneous-privileges-on-security-roles-part-three

Tuesday, 31 January 2017

Wednesday, 21 December 2016

SSIS IN MS CRM

ssis step by step

SSIS is a platform for building data integration solutions and it is a service that runs on the SQL Server. SSIS replaces the existing Data Transformation Services (DTS), which was introduced to the market as a component of SQL Server 7.0, and runs a unique package which stores the design of an ETL (Extraction -> Transformation -> Load) process.
Because SSIS in SQL 2005 was difficult to connect to Web Services by default, I did not spend much time into my research for my previous integration projects. Thanks again to Darren Hubert and his friends, who showed me a work around using a CRM proxy class in my last project. I was able to successfully integrate CRM 4.0 using SSIS. Here I would like to share with all of you on what I have learned so that you can leverage it on your next CRM integration projects.
Before we get started, here’s the list of requirements:
  • SQL Server 2005 Standard/Enterprise Edition with SQL Integration Service Installed
  • Microsoft Dynamics CRM 3.0/4.0
  • Visual Studio 2005 Professional Edition
  • CRM SDK , C# and VB.Net knowledge
In this blog, I will use a simple example to show you how to send contact data stored in a SQL database to MSCRM 4.0 via CRM Web Services using SSIS.

Source Data
The source data is from the data from the other system that you would like to send to the CRM system. You source data can be a text file, an Access database, an Oracle database, etc… In this example, I will create a simple Contacts table in a SQL database that’s already existed in environment.
Source Table: Contacts
First Name
Last Name
Phone
Email Address
John
Smith
312-888-8888
Darren
Liu
312-999-9999
Adam
Johnson
312-555-5555
   1: CREATE TABLE [dbo].[Contacts](
   2:     [ContactId] [int] IDENTITY(1,1) NOT NULL,
   3:     [FirstName] [varchar](50) NULL,
   4:     [LastName] [varchar](50) NULL,
   5:     [Phone] [varchar](50) NULL,
   6:     [Email] [varchar](50) NULL,
   7:  CONSTRAINT [PK_Contacts] PRIMARY KEY CLUSTERED 
   8: (
   9:     [ContactId] ASC
  10: )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
  11: ) ON [PRIMARY]
  12: GO
  13:  
  14: INSERT INTO Contacts (FirstName, LastName, Phone, Email)
  15: VALUES ('John','Smith','312-888-8888','jsmith@crowe.com')
  16:  
  17: INSERT INTO Contacts (FirstName, LastName, Phone, Email)
  18: VALUES ('Darren','Liu','312-999-9999','dliu@crowe.com')
  19:  
  20: INSERT INTO Contacts (FirstName, LastName, Phone, Email)
  21: VALUES ('Adam','Johnson','312-555-5555','ajohnson@crowe.com')
  22: GO
Create CRM Proxy Class
The SSIS framework provides a Web Service Task which executes a Web Service method, however it’s difficult to use. To reduce the complexity of the SSIS integration with CRM, generate a CRM Proxy class using Visual Studio. This will make the integration process much smoother and you will encounter less road blocks.
Start a New C# Class Library Project
clip_image002
  • Create a project name “CRM.Proxy”
Sign the Project
clip_image004
  • Right click on the project and select “Properties”.
  • Click on “Signing” tab and check the “Sign the assembly” checkbox.
  • Select “<New>” from “Choose a strong name key file” dropdown.
  • Give it a name for the Key. In this example, I use “integration” as my key name.

clip_image006
  • Click OK.
Add CRM Web Services
Add CRM Web Service and CRM Discovery Service to the CRM.Proxy project. Visual Studio will automatically run WSDL.exe in the background to create a proxy class for these two CRM Web Services which we will use later on in building the SSIS package.
  • Right click on Crm.Proxy project in the solution pane, then select “Add Web Reference…”.
  • In the URL text box, type in the CRM Web Service URL and give “CrmSdk” as the Web reference name. My CRM Web Service URL in this example is http://localhost:5555/mscrmservices/2007/CrmService.asmx

clip_image008

clip_image010
  • Compile the Crm.Proxy Project in Release Mode.

Deploy CRM Proxy Class to SSIS
In order to use the Crm.Proxy library in our SSIS package, we need to GAC the Crm.Proxy.dll and also copy the Crm.Proxy.dll to the .Net Framework 2.0 folder. The default location of the .Net Framework folder is C:\Windows\Microsoft.Net\Framework\v2.0.50727.
To GAC the Crm.Proxy.dll, you can simply drag and drop the dll file to C:\Windows\assembly folder.
clip_image012
Create SSIS Package
Start a New Integration Service Project
clip_image014
After creating the project, follow the steps below to setup the SSIS package.
  • Rename Package.dtsx to Contact.dtsx.
  • Right click on Data Source in the Solution Pane and then select “New Data Source”.
  • Follow the instruction on the wizard to create a database connection to the database contains your source data. In this example, I named my data source “CRMDB”.

clip_image016
  • Right click on Connection Managers pane to add a “New Connection From Data Source…”.
Add Control Flow Items
Drag and drop “Data Flow Task” from the Toolbox to the Control Flow Design Pane.
clip_image018
Add Data Flow Items
Double click on the Data Flow Task item and it will take you the Data Flow Design Pane. In here we will specify the source data and also write script to send data to CRM.
Specify Source Data
  • Drag and drop OLE DB Data Source to the design pane.
  • Double click OLE DB Source to open up the OLE DB Source Editor.
  • Select “CRMDB” from the OLE DB Connection Manager drop down box.
  • Select “Table or view” from Data Access Mode drop down box.
  • Select “Contacts” from Name of the table or the view drop down box.
  • Click OK.
clip_image020
Setup Script Component
  • Drag and drop Script Component to the design pane.
  • Select Transformation and then click OK.
clip_image022
  • Double click the script component to open up the Script Transformation Editor.
  • Select the column that you would like to send to MSCRM from the Input Column window. In this example, I selected FirstName, LastName, Phone and Email.

clip_image024
  • Remove Output in the Inputs and Outputs section since we are not output anything in this example.
clip_image026
  • Click on the Script tab, click on Design Script button. Visual Studio for Applications windows should open.
Add CRM Proxy Class to SSIS
Since we generated and GAC the Crm.Proxy library in the step above, we will add a reference to the proxy class in this step.
  • Right click on Reference and select “Add Reference…”.
  • Select Crm.Proxy from the list of the .Net components and then click Add.

clip_image028 clip_image030
Coding the Package
In order to complete the script, we also need to add the following reference: System.Web.dll, System.Web.Services.dll and System.Xml.dll. Then add the following imports statement
Imports Crm.Proxy.CrmSdk
Imports System.Xml
Imports System.Web.Services
Lastly, copy and paste the following code to the ScriptMain section:
   1: Public Class ScriptMain
   2:     Inherits UserComponent
   3:     Dim Service As CrmService
   4:  
   5: Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
   6:  
   7:      ‘Create Contact object
   8:         Dim contact As New contact()
   9:  
  10:         contact.firstname = Row.FirstName
  11:         contact.lastname = Row.LastName
  12:         contact.telephone1 = Row.Phone
  13:         contact.emailaddress1 = Row.Email
  14:  
  15:         Service.Create(contact)
  16:     End Sub
  17:  
  18:     Public Overrides Sub PreExecute()
  19:         MyBase.PreExecute()
  20:  
  21:         ‘Create CRM Service
  22:         Service = New CrmService()
  23:         Service.Credentials = System.Net.CredentialCache.DefaultCredentials
  24:         Service.Url = "http://localhost:5555/MSCrmServices/2007/CrmService.asmx"
  25:         Dim token As New CrmAuthenticationToken()
  26:       
  27:         ‘In this example, my organization name is MicrosoftCRM
  28:         token.OrganizationName = "MicrosoftCRM"
  29:         Service.CrmAuthenticationTokenValue = token
  30:         Service.PreAuthenticate = True
  31:     End Sub
  32:  
  33: End Class

clip_image032
Execute the SSIS Package
After done coding the SSIS package, right click on the Contact.dtsx package and then select Execute Package. After the package executed successfully, we should see the records in MSCRM.
clip_image034
Deploy SSIS Package
After successfully test the package, deploying the package is pretty easy. Just follow the steps below.
  • Right click on the CRM Integration project and the select Properties.
  • Click on the Deployment Utility tab and set Create Deployment Utility to True.
clip_image036

  • Recompile the CRM Integration project. You should now see CRM Integration.SSISDeploymentManifest in the bin\Deployment folder.
  • Double click on CRM Integration.SSISDeploymentManifest and follow the wizard to deploy the SSIS package.
After the package is deployed to your SQL server, setup a SQL agent job to execute the package according to your integration time interval.
Summary
That’s it! Hopefully you have gotten the idea of how to leverage the power of SSIS to send data to CRM. In the example here, I only demonstrated how to create records in CRM. In the actual integration implementation, you will also need to consider how to update/delete/link records, and also error handling. I hope this will help you in your next CRM integration project.

Monday, 19 December 2016

Javascript

Javascript basic



Useful CRM 2011 JavaScript 

One of the noticeable changes between CRM 4.0 and CRM 2011 is the JavaScript object model. It has changed a bit. Below are some of the commonly used functions used to manipulate CRM forms. Let us know if you have a commonly used function that should be included in the list of CRM 2011 JavaScript tidbits below.
One of the tools we highly recommend is the JavaScript CRM 4 to CRM 2011 converter tool:
Get the value from a CRM field:

1
var varMyValue = Xrm.Page.getAttribute("CRMFieldSchemaName").getValue() ;
Set the value of a CRM field:

1
Xrm.Page.getAttribute("po_CRMFieldSchemaName").setValue('My New Value');
Hide/Show a tab/section:

1
2
Xrm.Page.ui.tabs.get(5).setVisible(false);
Xrm.Page.ui.tabs.get(5).setVisible(true);
Call the onchange event of a field:

1
Xrm.Page.getAttribute("CRMFieldSchemaName").fireOnChange();
Get the selected value of picklist:

1
Xrm.Page.getAttribute("CRMFieldSchemaName").getSelectedOption().text;
Set the requirement level:

1
2
3
Xrm.Page.getAttribute("CRMFieldSchemaName").setRequiredLevel("none");
Xrm.Page.getAttribute("CRMFieldSchemaName").setRequiredLevel("required");
Xrm.Page.getAttribute("CRMFieldSchemaName").setRequiredLevel("recommended");
Set the focus to a field:

1
Xrm.Page.getControl("CRMFieldSchemaName").setFocus(true);
Stop an on save event:

1
event.returnValue = false;
Return array of strings of users security role GUIDs:

1
Xrm.Page.context.getUserRoles()
Hide/Show Tabs and Sections:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function setVisibleTabSection(tabname, sectionname, show) {
    var tab = Xrm.Page.ui.tabs.get(tabname);
    if (tab != null) {
        if (sectionname == null)
            tab.setVisible(show);
        else {
            var section = tab.sections.get(sectionname);
            if (section != null) {
                section.setVisible(show);
                if (show)
                    tab.setVisible(show);
            }
        }
    }
}

JavaScriptEvents

Java Script events are related to forms and the controls inside the forms only.
 Each form has OnLoad and OnSaveevents, which can accept JavaScript.
Each fields has the OnChange event,which can also accept JavaScript.

You can also add events for the Tabcontrol to track the TabStateChangeevent and to IFRAMEs to trackthe OnReadyStateCompleteevent(seeFigure21.36).

                       Commonly used Methods
Get the value from a CRM field
var value = Xrm.Page.getAttribute(“CRMFieldSchemaName”).getValue();

Set the value of a CRM field
Xrm.Page.getAttribute(“CRMFieldSchemaName “).setValue(“New Value”);

Get the value from a CRM OptionSet field
var value = Xrm.Page.getAttribute(“CRMOptionSetSchemaName”).getValue();

Get the text from a CRM OptionSet field
var text = Xrm.Page.getAttribute(“CRMOptionSetSchemaName”).getText();

Set the value of a CRM OptionSet field
Xrm.Page.getAttribute(“CRMOptionSetSchemaName”).setValue(1); // OptionSet Value

Get the selected text of a CRM OptionSet field
Xrm.Page.getAttribute(“CRMOptionSetSchemaName”).getSelectedOption().text;

Get the selected value of a CRM OptionSet field
Xrm.Page.getAttribute(“CRMOptionSetSchemaName”).getSelectedOption().value;

Get the text and value of a CRM Lookup field
var lookupObject = Xrm.Page.getAttribute(“CRMLookupSchemaName”).getValue();
lookupObject[0].name; // text of lookup
lookupObject[0].id; // Guid of lookup

Set the value of a CRM Lookup field
var lookupData = new Array();
var lookupItem = new Object();
lookupItem.id = “4A2A54CB-349C-E111-8D26-1CC1DEE8DA78″; // Guid of record
lookupItem.name = “New Contact”; // Entity record name
lookupItem.entityType = “EntitySchemaName”;
lookupData[0] = lookupItem;
Xrm.Page.getAttribute(“CRMLookupSchemaName”).setValue(lookupData);

Disable CRM field
Xrm.Page.ui.controls.get(“CRMFieldSchemaName”).setDisabled(true);

Hide CRM field
Xrm.Page.ui.controls.get(“CRMFieldSchemaName”).setVisible(false);

Hide a Tab in CRM
Xrm.Page.ui.tabs.get(“tabName”).setVisible(false);

Hide a Section in CRM
var tab = Xrm.Page.ui.tabs.get(“tabName”);
tab.sections.get(“sectionName”).setVisible(false);

Set the Requirement level in CRM
Xrm.Page.getAttribute(“CRMFieldSchemaName”).setRequiredLevel(“required”);
Xrm.Page.getAttribute(“CRMFieldSchemaName”).setRequiredLevel(“none”);
Xrm.Page.getAttribute(“CRMFieldSchemaName”).setRequiredLevel(“recommended”);

Set Focus on a field in CRM
Xrm.Page.ui.controls.get(“CRMFieldSchemaName”).setFocus(true);

Cancelling Onsave Event in CRM
event.returnValue = false;
return false;

Check IsDirty in CRM field
var isDirty = Xrm.Page.getAttribute(“CRMFieldSchemaName”).getIsDirty();
alert(isDirty); // returns true if the field is dirty

Check IsDirty for all the fields in CRM
var isDirty = Xrm.Page.data.entity.getIsDirty();
alert(isDirty); // returns true if any of the field is dirty in the entire form.

Force Submit a read only field in CRM
Xrm.Page.getAttribute(“CRMFieldSchemaName”).setSubmitMode(“always”);

Preventing an attribute to be saved in CRM form
Xrm.Page.getAttribute(“CRMFieldSchemaName”).setSubmitMode(“never”);

Get Unique Organization Name in CRM
Xrm.Page.context.getOrgUniqueName();

Get Server url in CRM
Xrm.Page.context.getServerUrl();

Get the record Id in CRM
Xrm.Page.data.entity.getId();

Get the User Id in CRM
Xrm.Page.context.getUserId();

Get the Entity Schema Name in CRM
Xrm.Page.data.entity.getEntityName();

Get the UserRole Id’s in CRM
var userRoles = Xrm.Page.context.getUserRoles();
for (var i = 0; i < userRoles.length; i++)
{
var userRole = userRoles[i]; // returns the Role Id
}

Get the Form Type in CRM
Xrm.Page.ui.getFormType();

Form Types in CRM
Is the user creating a new record?
Xrm.Page.ui.getFormType() == “1”

Is the user updating an existing record?
Xrm.Page.ui.getFormType() == “2”

Is the user unable to update this record?
Xrm.Page.ui.getFormType() == “3”

Is this record deactivated?
Xrm.Page.ui.getFormType() == “4”

Is the user using the Quick Create form?
Xrm.Page.ui.getFormType() == “5”

Is the user using the Bulk Edit form?
Xrm.Page.ui.getFormType() == “6”

Save a record in CRM
Xrm.Page.data.entity.save(); // for saving a record
Xrm.Page.data.entity.save(“saveandclose”); // for save and close
Xrm.Page.data.entity.save(“saveandnew”); // for save and new

* How to retrivie fields that are added in a custoum web page- http://www.powerxrm.com/incorporating-custom-html-page-into-dynamics-crm-form/ 

https://msdn.microsoft.com/en-us/library/gg328046.aspx

http://www.kingswaysoft.com/blog/2013/06/18/Limitations-with-CRM-FetchXML

Some Example on Real time Javascript  that I faced - 
1.Set background color to field to yellow - 

2. Hide "+" in look up. So user cannot add new items in Entity.