Monday 18 November 2019

Javascript Reference for Dynamics 365 9.0

Javascript Reference for Dynamics 365 9.0



1.       Get the Attribute type
formContext.getAttribute(“Field name”).getAttributeType()
It will Returns a string value that represents the attribute type. Following are the return types
·         Boolean
·         datetime
·         decimal
·         double
·         integer
·         lookup
·         memo
·         money
·         multioptionset
·         optionset
·         string
2.       Get the format type
formContext.getAttribute(“fieldname”).getFormat()
It will Returns a string value that represents the format type. Following are the format types
·         date
·         datetime
·         duration
·         email
·         language
·         none
·         phone
·         text
·         textarea
·         tickersymbol
·         timezone
·         url

3.       Get the Initial Value
formContext.getAttribute(“fieldname”).getInitialValue()
Returns a value that represents the value set for a Boolean, OptionSet or MultiSelectOptionSet attribute when the form is opened.
4.       getIsDirty
formContext.getAttribute(“Fieldname”).getIsDirty()
Returns a Boolean value indicating if there are unsaved changes to the attribute value.
5.       getIsPartylist
formContext.getAttribute(“field name”).getIsPartyList()
Returns a Boolean value indicating whether the lookup represents a partylist lookup. Partylist lookups allow for multiple records to be set, such as the To: field for an email entity record.
6.       getMax
formContext.getAttribute(“Field Name”).getMax()
Returns a number indicating the maximum allowed value for an attribute.
7.       getName
formContext.getAttribute("fieldname").getName()
Returns a string representing the logical name of the attribute.
8.       getOption
formContext.getAttribute(“Fieldname”).getOption(value)
Returns an option object with the value matching the argument (label or enumeration value) passed to the method.
9.       getOptions
formContext.getAttribute(arg).getOptions()
Returns an array of option objects representing valid options for an attribute.
10.   getParent
formContext.getAttribute("fieldname").getParent()
Returns the formContext.data.entity object that is the parent to all attributes
11.   getPrecision
formContext.getAttribute(“fieldname”).getPrecision()
Returns the number of digits allowed to the right of the decimal point.
12.   getRequireLevel
formContext.getAttribute(“fieldName”).getRequiredLevel()
Returns a string value indicating whether a value for the attribute is required or recommended
13.   getSelectedOption
formContext.getAttribute(arg).getSelectedOption()
Returns the option object or an array of option objects selected in an optionset or multiselectoptionset attribute respectively.
14.   getSubmitMode
formContext.getAttribute(arg).getSubmitMode()
Returns a string indicating when data from the attribute will be submitted when the record is saved.
15.   getText
formContext.getAttribute(arg).getText()
Returns a string value of the text for the currently selected option for an optionset or multiselectoptionset attribute.
16.   getUserPrivilege
formContext.getAttribute(arg).getUserPrivilege()
Returns an object with three Boolean properties corresponding to privileges indicating if the user can create, read or update data values for an attribute. This function is intended for use when Field Level Security modifies a user’s privileges for a particular attribute
17.   getValue
formContext.getAttribute(arg).getValue()
Retrieves the data value for an attribute.
18.   isValid
formContext.getAttribute(arg).isValid();
Returns a boolean value to indicate whether the value of an attribute is valid.
19.   removeOnChnage
formContext.getAttribute(arg).removeOnChange(myFunction)
Removes a function from the OnChange event hander for an attribute..
20.   setPrecision
formContext.getAttribute(arg).setPrecision(value);
Sets the number of digits allowed to the right of the decimal point.
21.   setRequiredLevel
formContext.getAttribute(arg).setRequiredLevel(requirementLevel)
Sets whether data is required or recommended for the attribute before the record can be saved.
Note:
Reducing the required level of an attribute can cause an error when the page is saved. If the attribute is required by the server, an error will occur if there is no value for the attribute.
22.   setSubmitMode
formContext.getAttribute(arg).setSubmitMode(mode)
Sets whether data from the attribute will be submitted when the record is saved.
23.   setValue
formContext.getAttribute(arg).setValue(value)
Sets the data value for an attribute.
24.   Set LookupValue
function SetLookupFieldVaue(fieldName, id, name, entityType) {
    if (fieldName != null) {
        var lookupVal = new Array();
        lookupVal[0] = new Object();
        lookupVal[0].id = id;
        lookupVal[0].name = name;
        lookupVal[0].entityType = entityType;
                                formContext.getAttribute(fieldName).setValue(lookupVal);
    }
}
25.   Get Composite fields
formContext.getControl("address1_composite_compositionLinkControl_address1_line1")
26.   Get Control
formContext.getControl(arg);
Gets a control on the form.
27.   Get Control type
getControl(arg).getControlType();
Returns a value that categorizes controls.
ex:iframe,lookup,composite,multiselectoptionset,subgrid,notes,optionset,quickform,webresource,timewall,timecontrol
28.   Show/Hide controls or fields
formContext.getAttribute(arg).setVisible(true)//show
formContext.getAttribute(arg).setVisible(false)//hide

29.   Progress dialog box
OOB Feature added in D365 9.0
Xrm.Utility.showProgressIndicator(message)//to show the progress indicator
Xrm.Utility.closeProgressIndicator()//to stop the progress indicator

Friday 15 November 2019

Deploying the SSIS Package

Deploying the SSIS Package

In Visual Studio, right-click on the project and select Deploy.
deploy SSIS project
This will start the SSIS deployment wizard. Keep in mind this will deploy the entire project, with all packages included. If you want to deploy an individual package, you can right-click on the package itself and choose Deploy (since SSIS 2016).
In the first step of the wizard, we need to choose the destination (several steps are skipped since we started the wizard from Visual Studio). Enter the server name and make sure the SSIS catalog has already been created on that server. If you want, you can also create a folder to store the project in.
Select destination in Integration Services Deployment Wizard
At the next step, you get an overview of the actions the wizard will take. Hit Deploy to start the deployment.
Review selections in the Integration Services Deployment Wizard
The deployment will go through a couple of steps:
SSIS deployment successful
The project has now been deployed to the server and you can find it in the catalog:
SSIS project in catalog as seen in Management Studio

Executing an SSIS Package on the Server

To execute the package, simply locate it in the catalog folder, right-click it and hit Execute…
Execute package from SSMS
You will be taken to a dialog where you can edit certain properties, such as the connection managers, parameters if any, the amount of logging and so on.
execute package
Click on OK to start the execution of the package. A pop-up will open asking you if you want to open one of the catalogs built-in reports.
sql server management studio
Click Yes. This will take you to the Overview report, where can see the package has successfully executed.
overview report
To learn more about the catalog reports, check out the tip Reporting with the SQL Server Integration Services Catalog.

Scheduling the SSIS Package with SQL Server Agent

Manually executing packages is one thing, but normally you will schedule packages so your ETL can run in a specific time windows (probably at night). The easiest option is SQL Server Agent. You can right-click on the Jobs node to create a new job:
create new job
In the General pane, enter a name for the job, choose an owner and optionally enter a description:
enter properties job
In the Steps pane, you can create a new job step.
create new job step
In the job step configuration, you can enter a name for the step. Choose the SQL Server Integration Services Package type, enter the name of the server and select the package.
job step config
In the configuration tab, you can optionally set more properties, just like when executing a package manually. Click OK to save the job step. In the Schedules tab, you can define one or more schedule to execute the package on predefined points in time. Click New… to create a new schedule. In the schedule editor, you can choose between multiple types of schedules: daily, weekly or monthly. You can also schedule packages to run only once. In the example below we have scheduled the job to run every day at 1AM, except in the weekend.
job schedule
Click OK twice to exit the editors. The job is now created and scheduled.

Wednesday 9 October 2019

Debugging in new Release of Dynamics CRM

For Button:
1. Set Input parameter as “Primary Control” for
2. You can put debugger in script
function onClick(primaryControl)
//function to build URL and open new window
{
debugger;
var functionName = “onClick: “;
var executionContext = primaryControl;
try {
//your code
} catch (e) {
throwError(functionName, e.message);
}
}
3. Open console window (F12) and the script will start debug automatically.
For Form/Field:
1. Make sure you have checked “Pass execution context as first parameters” form/field event properties.
2. You can put debugger in script
Java Script
function onLoad(executionContext)
//function to build URL and open new window
{
debugger;
var functionName = ” onLoad: “;
try {
//your code
}
} catch (e) {
throwError(functionName, e.message);
}
}
3. Open console window(F12) and the script will start debug automatically.

Monday 12 August 2019

Creating a full data set copy of your instance - Dynamics 365


Usually Microsoft asks the customers to do a copy of their instance to debug an issue. 

you need to follow the below mentioned steps.




Follow below steps for Copy of Instance:
1.       Browse to the Office 365 admin center and sign in using Office 365 Global administrator credentials.
2.       Click Admin centers > Dynamics 365.
3.       Choose the Instances tab.
4.       Select an instance, and then click Copy


Note: The org will be in “Administration Mode,” So please select the Support Instance click on Admin button and uncheck the Administration Mode check box

Retrieve records using Query Expression & C# SDK in CRM

Tested with CRM 2015

Let us see a simple example to retrieve records using Query Expression,
Task: Get a Contact record with the following values, where Full Name = Arun Potti
Retrieve Multiple - FetchXML SDK
Solution: Follow the below Steps,
Step 1: Include the below References in your project, you can get the same from Latest SDK.
Goto the path, SDK -> Bin for the dlls
Microsoft.Crm.Sdk.Proxy
Microsoft.Xrm.Sdk
Step 2: Include the below Framework Assemblies in your project,
Reference Manager - ConnectToCRM
Step 3: Add the below namespaces in your class file,
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using System.ServiceModel.Description;
using Microsoft.Xrm.Sdk.Query;
Step 4: First we have to connect to CRM, for details Click Here
Step 5: User the below method to retrieve record, and it accepts the below parameters
Query Expression Retrieve Record Parameters
private static EntityCollection GetEntityCollection(IOrganizationService service, string entityName, string attributeName, string attributeValue, ColumnSet cols)
{
QueryExpression query = new QueryExpression
{
EntityName = entityName,
ColumnSet = cols,
Criteria = new FilterExpression
{
Conditions =
{
new ConditionExpression
{
AttributeName = attributeName,
Operator = ConditionOperator.Equal,
Values = { attributeValue }
}
}
}
};
return service.RetrieveMultiple(query);
}
Final usage of the function is as follows,
EntityCollection ec = GetEntityCollection(_service, "contact", "fullname", "Arun Potti", new ColumnSet("fullname", "parentcustomerid", "gendercode", "birthdate", "creditlimit", "donotsendmm"));
Step 6: Final Code is here,
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using System.ServiceModel.Description;
using Microsoft.Xrm.Sdk.Query;

namespace Retrieve_Record
{
class Program
{
static IOrganizationService _service;
static void Main(string[] args)
{
EntityCollection ec = null;
ConnectToMSCRM("arunpotti@XXXXXX.onmicrosoft.com", " XXXXXX", "https:// XXXXXX.api.crm5.dynamics.com/XRMServices/2011/Organization.svc");
Guid userid = ((WhoAmIResponse)_service.Execute(new WhoAmIRequest())).UserId;

if (userid == Guid.Empty) return; //Check for CRM Connection Establishment. If Not return, other wise will proceed to next step

ec = GetEntityCollection(_service, "contact", "fullname", "Arun Potti", new ColumnSet("fullname", "parentcustomerid", "gendercode", "birthdate", "creditlimit", "donotsendmm"));

if(ec.Entities.Count > 0) //Check for EntityCollection count
{
string output = string.Empty;
foreach (var item in ec.Entities)
{
//String
if (item.Attributes.Contains("fullname")) //Check for fullname value exists or not in Entity Collection
output += "Full Name : " + item.Attributes["fullname"] + "\n";

//Lookup
if (item.Attributes.Contains("parentcustomerid")) //Check for parentcustomerid exists or not in Entity Collection
output += "Company : " + ((EntityReference)item.Attributes["parentcustomerid"]).Name + "\n";

//OptionSet
if (item.Attributes.Contains("gendercode")) //Check for gendercode exists or not in Entity Collection
output += "Gender : Name - " + item.FormattedValues["gendercode"] + ", Value - " + ((OptionSetValue)item.Attributes["gendercode"]).Value + "\n";

//Date
if (item.Attributes.Contains("birthdate")) //Check for birthdate exists or not in Entity Collection
output += "Birthday : " + ((DateTime)item.Attributes["birthdate"]).ToLocalTime().ToShortDateString().ToString() + "\n";

//Currency
if (item.Attributes.Contains("creditlimit")) //Check for creditlimit exists or not in Entity Collection
output += "Credit Limit : " + ((Money)item.Attributes["creditlimit"]).Value + "\n";

//Two Options
if (item.Attributes.Contains("donotsendmm")) //Check for donotsendmm exists or not in Entity Collection
output += "Send Marketing Materials : Name - " + item.FormattedValues["donotsendmm"] + ", Value - " + ((Boolean)item.Attributes["donotsendmm"]).ToString();
}
Console.WriteLine(output);
Console.ReadKey();
}
}

private static void ConnectToMSCRM(string UserName, string Password, string SoapOrgServiceUri)
{
try
{
ClientCredentials credentials = new ClientCredentials();
credentials.UserName.UserName = UserName;
credentials.UserName.Password = Password;
Uri serviceUri = new Uri(SoapOrgServiceUri);
OrganizationServiceProxy proxy = new OrganizationServiceProxy(serviceUri, null, credentials, null);
proxy.EnableProxyTypes();
_service = (IOrganizationService)proxy;
}
catch (Exception ex)
{
Console.WriteLine("Error while connecting to CRM " + ex.Message);
Console.ReadKey();
}
}

private static EntityCollection GetEntityCollection(IOrganizationService service, string entityName, string attributeName, string attributeValue, ColumnSet cols)
{
QueryExpression query = new QueryExpression
{
EntityName = entityName,
ColumnSet = cols,
Criteria = new FilterExpression
{
Conditions =
{
new ConditionExpression
{
AttributeName = attributeName,
Operator = ConditionOperator.Equal,
Values = { attributeValue }
}
}
}
};
return service.RetrieveMultiple(query);
}
}
}
Step 7:  You can see the below output,
Retrieve Multiple - FetchXML SDK Output

Git Basic working

  Develop = dev   r