Advertisements

Archive

Posts Tagged ‘Dynamics 365’

IntelliSense in Jscript/TypeScript file – Dynamics 365

In this article, lets see how to configure intellisence with XRM syntaxes in your Jscript/TypeScript files.

To enable IntelliSence, you need to install xrm npm package to your Visual Studio.

Steps to install NPM package:

  • To install npm package, you need to download and install a Visual Studio extension : Package Installer

Intelli - 5

  • Post installation, from your Visual Studio, select ‘Quick Install Package’ from Menu

Intelli - 6

  • From the popup,
    • Select ‘npm’ in the dropdown
    • In the textbox, type ‘@types/xrm
    • Click on ‘Install’

Intelli - 7

  • Post package installation, refresh the project and you should see a new folder ‘node_modules
    • Note: If you dont get the ‘node_modules’ folder, check your project’s physical location and add the folder to your Visual Studio project.

Intelli - 8

  • In above screen, ‘TypeScript’ is my project name and post above steps, I got the ‘node_modules’ project.

Enable IntelliSence in your Jscript/TypeScript file:

  • Open your script file
  • Drag and drop the ‘index.d.ts’ file from ‘node_modules’ folder on to your script file.
    • Alternatively you can also this syntax
      • /// <reference path=“../node_modules/@types/xrm/index.d.ts />

Intelli - 1

  • Start typing ‘Xrm’ and you should see the syntaxes.

Notes:

  • Those who are wondering what is a npm, it is a package manager for the JavaScript programming language.
  • www.npmjs.com hosts thousands of free packages to download and use.

 

Advertisements

Dynamics CE – Demystify ‘Auto Number’

Auto Number‘ feature is available with Dynamics 365 (online) and V9.x versions. With this feature we are no longer dependent on 3rd party ISV solutions for Auto numbering.

Auto Number - 2

In this article I am going to cover a few use cases of Auto Number fields.

How to create an Auto Number field:

As of the date, we can either create a new ‘Auto number’ field or convert an existing field to ‘Auto Number’ only programmatically (i.e., using SDK call).

Creation of an ‘Auto Number’ from Application will be included in next releases.

Lets see how to create a brand new ‘Auto Number’ field and convert an existing ‘Single Line Of Text’ field to ‘Auto Number’ along with few key points.

[Code Snippet] Create a NEW auto number field:

Below is the sample code to create a new Auto Number field ‘new_studentnumber‘ in a custom entity ‘new_student

var studentNumberAttributeRequest = new CreateAttributeRequest{
EntityName = “new_student“,
Attribute = new StringAttributeMetadata{
//Define the format of the attribute
AutoNumberFormat = “STD-{SEQNUM:4}”,
// Set fields Logical and Schema Name
LogicalName = “new_studentnumber“,
SchemaName = “new_studentnumber“,
RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None),
MaxLength = 100,
// Set fields Display Name and Description
DisplayName = new Label(“Student ID”, 1033),
Description = new Label(“Student ID”, 1033)
}
};
_serviceProxy.Execute(studentNumberAttributeRequest);

  • Make sure you ‘Publish‘ customization’s from Application after executing the code.

[Code Snippet] Convert EXISTING field to an auto number field:

Below is the sample code to convert OOB ‘new_name’ field to auto number field in the custom entity ‘new_student‘.

Important note:

  • Field you are converting has to be of type ‘Single Line Of Text’.
  • If you pass a different type of field (Ex- Whole number), code will not throw any exception but no auto number logic will get attached to the field.

// First retrieve the Attribute Metadata
var attributeRequest = new RetrieveAttributeRequest{
EntityLogicalName = “new_student”,
// Pass the attribute name
LogicalName = “new_name”,
RetrieveAsIfPublished = true
};

// Retrieve attribute response
var attributeResponse = (RetrieveAttributeResponse)_serviceProxy.Execute(attributeRequest);

// Now modify the retrieved auto-number attribute
var retrievedAttributeMetadata = attributeResponse.AttributeMetadata;
// Set the auto numbering format
retrievedAttributeMetadata.AutoNumberFormat = “STD-{SEQNUM:3}-{RANDSTRING:6}”;

// Update the auto-number attribute
var updateRequest = new UpdateAttributeRequest{
Attribute = retrievedAttributeMetadata,
EntityName = “new_student”,
};

// Execute the request
_serviceProxy.Execute(updateRequest);

  • Make sure you ‘Publish‘ customization’s from Application after executing the code.

Key Points:

  • Auto number fields will be Read-only and you cannot override the value from Form.
  • But you can override the value from code using SDK Insert call.
  • As you would notice below, Even though the ‘Name’ is an Auto number field, I could create a ‘Student’ record from code by setting ‘Name’ to ‘Rajeev’.  If you dont set a ‘Name’ field value from code, system would populate the auto number.

Auto Number - 1

  • In a single Entity, you can have multiple auto number type fields with the same format.
  • You can alter the auto number format of a field at any point of time by using ‘UpdateAttributeRequest’ SDK call (Refer 2nd code snippet above).
  • In the Auto number format, use ‘Random String’ tag (i.e., {RANDSTRING:number}) which help you to avoid duplicates or collisions, especially when offline clients trying to create auto-numbers.
    • For example, CNR-{RANDSTRING:4} format will generate an auto number with a random string of 4 character length (i.e., ‘CNR-WXYZ‘)

Auto Number - 3

  • The random string placeholders are optional.You can include more than one random string placeholder in an Auto Number Format.

🙂

 

Dynamics 365 Spring Release 2018

Microsoft has released Spring ’18 release notes for Microsoft Business Applications and can be downloaded from here

D365_Spring_18

Refer this link for all latest updates on Dynamics 365

Dynamics 365 – Create/Modify Views using App Designer

In this article, I am going to detail, how views can be created or modified using App Designer.

Open ‘App Designer’:

  • To start off, go to ‘My Apps’ by navigating to ‘Settings –> Application –> My Apps’

Views - 1.PNG

  • Open the ‘Sales’ app in ‘App Designer’ by clicking ‘OPEN IN APP DESIGNER’

Views - 2

Add/Edit Views:

Once the ‘App Designer’ loads, lets see how to modify Account’s ‘Active Accounts’ view

  • From the ‘App Designer’ window, under ‘Entity View’ section, select the ‘Views’ tab from ‘Account’ row.
  • On the right side ‘Public Views’ tab, select the View you want to modify (i.e., ‘Active Accounts’ in my case)
  • After selecting the view from right window, back to ‘Views’ tab and expand, open the ‘Active Accounts’ to Edit

Views - 3

  • To add new column, click on ‘Add’ button, choose Primary or Related entity to add the fields from and drag and Drop the column you want.

Views - 4

  • Expand the ‘Filter Criteria’ tab to update the filter

Views - 5

  • To add new view, click ‘Create New’ from your ‘App Designer’

Views - 6

With the ‘App Designer’, you can perform all the view customizations, which you can do with conventional view editor.

Refer article  for more details.

🙂

Dynamics 365 – Capture events from Editable subgrid and set main form fields

To answer one of the queries posted on my blog, in this article I am going to detail, capturing the events from Editable sub grid and Get/Set the form fields.

To simplify the explanation, I am taking below use case

  • On Account from configure ‘Contacts’ editable sub grid
  • On change of ‘Business Phone’ from ‘Contact’ sub grid
    • Read the new ‘Business Phone’ value
  • SubGridEvent_3
    • Set the ‘Telephone’ field on Account form with the Contacts ‘Business Phone’

SubGridEvent_4

below are the execution steps

Add ‘Editable Grid’ on Account Form:

  • Add a ‘Contact’ sub grid on the Account form (You can leverage OOB Contacts grid as well)
  • To convert read only grid to Editable grid, Double click on ‘Sub grid’ and go to ‘Controls’ -> Add Control
  • Choose ‘Editable Grid’ option from the list

Add Sub Grid

  • Select ‘Web’ checkbox

Add Sub Grid_1

  • Click ‘OK’

Register ‘onchange’ event on sub grid field:

  • Double click on ‘Sub grid’ and go to ‘Events’
  • Select the Field as ‘Business Phone’ and the Event as ‘OnChange’

SubGridEvent_2

  • Add click ‘+Add’ to add your Jscript function name
    • Function : businessPhoneOnChange
  • Make sure you select the ‘Pass execution context as first parameter’ checkbox

SubGridEvent_1

  • Save and Publish the form

JScript function:

function businessPhoneOnChange(execContext) {
try {
var formContext = execContext.getFormContext();

// Read the changed Business Phone’ value from sub grid
var entityObject = formContext.getData().getEntity();
var contactBusinessPhone = entityObject.attributes.getByName(“telephone1”).getValue();
// showAlert(“Business Phone – ” + contactBusinessPhone);

// Set the ‘Phone’ field on ‘Account’ form
parent.Xrm.Page.getAttribute(“telephone1”).setValue(contactBusinessPhone);
} catch (e) {
showAlert(“Error in businessPhoneOnChange – ” + e.description);
}
}

function showAlert(message) {
var alertStrings = { confirmButtonLabel: “Yes”, text: message };
var alertOptions = { height: 120, width: 400 };
Xrm.Navigation.openAlertDialog(alertStrings, alertOptions).then(
function success(result) {
console.log(“Alert dialog closed”);
},
function (error) {
concole.log(error.message);
}
);
}

🙂

God Mode – Level Up – Dynamics 365 Chrome Extension

February 22, 2018 Leave a comment

Imagine a scenario, where you have to create/update a record by using any of the below options from the browser

  • By passing the required field checks
  • Make any hidden fields, tabs, sections visible
  • Enable all the read-only fields which are locked

The answer is ‘God Mode’ by installing a chrome browser extension Level up for Dynamics CRM/365.

Level up - Chrome extension

After installing the extension, you would get the ‘Level Up’ icon on your chrome address bar.

Using God mode:

  • Open the record you would want to use ‘God Mode’
  • Choose ‘God Mode’ option from the Level Up Menu

God Mode

  • Up on choosing the ‘God Mode’ all required fields would become optional and all your hidden/disables fields become visible and enabled.

God Mode - Enabled

Note:

  • Even though the option is flexible and easy to use, it has to be used judiciously to avoid any misuse.

🙂

 

Sandbox vs Production Instances – Dynamics 365

February 14, 2018 Leave a comment

Other day I got a question around ‘Instance Types’ in Dynamics 365. In this article I am going to provide quick notes around ‘Instance Types’.

What is Instance Type:

‘Instance type’ allows you to categorize your Dynamics 365 instance (i.e., Either Production instance or Test instance).

D 365 - Instance Type

  • There are 2 types of ‘Instance Types’ available in D 365
    • Production
    • Sandbox
  • Production Instance :
    • An Instance of type ‘Production’ is considered as your LIVE environment which was made available to your end users.
    • You cannot perform some admin actions on your Production instances.
    • For example, you cannot reset the instance and you cannot copy an instance to another Production instance.
    • You cannot set ‘Admin Mode’ on your production instances.
    • If you subscribe CRM 30 days trail, you will get ‘Production’ instance by default. You can change the ‘Instance Type’ to ‘Sandbox’ by using ‘Edit’ option.
  • Sandbox Instance:
    • A Sandbox instance is the place to safely develop and test your application changes with low risk.
    • A Sandbox instance type can be your test instance or UAT.
    • As an example, you can Reset (i.e., Becomes Vanilla)/Copy/Delete your sandbox instance.
    • In ‘Sandbox’, its easy to replicate your Production instance by using ‘Copy’ feature.
    • You can set ‘Admin Mode’.

What is an Admin Mode:

D 365 - Sandbox Instance

  • Let’s take a scenario where you want to reset your instance and deploy a fresh build. During this time you don’t want your non-admin users access the instance.
  • With ‘Admin Mode’ turned on, only Users with ‘System Admin’ or ‘System Customizers’ can log-in to the system where as regular users would not be allowed to log-in.
  • With this mode enabled, all asynchronous operations will be cancelled.  This includes workflows, sending email, Exchange sync, and Yammer.

D 365 - Admin Mode

  • You can only place Sandbox instances in administration mode.

Key Points:

  • A production instance is must to get a sandbox instance. To add a new ‘Sandbox’ instance you need to purchase it as additional instance. How to add a new Instance
  • You cannot reset ‘Production’ instance. Workaround is you have to changing instance type to ‘Sandbox’ and reset then switch to Production.

Refer Link to explore more.

🙂