Suyati Technologies
  • Services
    • Salesforce Services
      • Sales Cloud
      • Service Cloud
      • Marketing Cloud
      • Einstein
      • Experience Cloud
      • Mulesoft
      • Commerce cloud
      • Finance cloud
      • CPQ
      • Consultation
      • Implementation
      • Integration
      • Custom Development
      • Salesforce DevOps
      • Support & Maintenance
      • App Development
      • Managed Services
    • IT Services
      • Content Management Services
      • Analytics
      • RPA
      • Front end Technologies
      • Microsoft Applications
      • Cloud
      • DevOps
      • Snowflake
  • Approach
    • Development Methodology
    • Engagement Model
    • Consulting
  • Intel
    • Blog
    • eBooks
    • Webinars
    • Case Studies
  • About Us
    • Management Team
    • Advisory Board
    • Our Story
    • Testimonials
  • Careers
  • Contact Us
Suyati Technologies
  • Services
    • Salesforce Services
      • Sales Cloud
      • Service Cloud
      • Marketing Cloud
      • Einstein
      • Experience Cloud
      • Mulesoft
      • Commerce cloud
      • Finance cloud
      • CPQ
      • Consultation
      • Implementation
      • Integration
      • Custom Development
      • Salesforce DevOps
      • Support & Maintenance
      • App Development
      • Managed Services
    • IT Services
      • Content Management Services
      • Analytics
      • RPA
      • Front end Technologies
      • Microsoft Applications
      • Cloud
      • DevOps
      • Snowflake
  • Approach
    • Development Methodology
    • Engagement Model
    • Consulting
  • Intel
    • Blog
    • eBooks
    • Webinars
    • Case Studies
  • About Us
    • Management Team
    • Advisory Board
    • Our Story
    • Testimonials
  • Careers
  • Contact Us
Suyati Technologies > Blog > MS Dynamics CRM 2016 – New Client Side features

MS Dynamics CRM 2016 – New Client Side features

by Naveen Kumar February 10, 2016
by Naveen Kumar February 10, 2016 0 comment

ms-dynamics-crm-2016
In our previous blog we have seen the new and cool features of MS Dynamics 2016. In this piece, we will take a tour of the New Client Scripting method introduced in Dynamics CRM 2016. The client scripting method offered by this release can be utilized to create a unique user experience and make it more interactive while data is entered into the CRM forms.
Method – getValue
This method was previously available only for attribute collection. Using it, we could get field value after the field was updated, and only if the cursor was unfocused from that field. Now, it is possible to capture the value of field right when users start entering value in the field.
We can use this method as shown below:
Xrm.Page.getControl(field name).getValue();
If you want the user to enter value as per our specific pattern or regular expression, we can use the code mentioned below:
function OnfieldKeyPress() {
var fieldValue = Xrm.Page.getControl(“field name here”).getValue().toString().replace(/[^0-9]/g, “”);
Xrm.Page.getAttribute(“field name here”).setValue(fieldValue);
}
This method will work only if we call this on a Keypress event. So let us try to understand how to call a function on Keypress event for a text field.
Event –Keypress
The following three Keypress methods are added to the 2016 version:

  • addOnKeyPress()

 This is used to attach a function with a Keypress event:
Xrm.Page.getControl (fieldname).addOnKeyPress(function name);
If we add this statement in function which is called at the loading of the form, then OnFieldKeyPress function will be attached with Keypress event of field.

  • removeOnKeyPress()

This is used to remove/detach a function that is attached with a Keypress event:
Xrm.Page.getControl(fieldname).removeOnKeyPress(function name);

  •  fireOnKeyPress()

This is used to call Keypress event handler for text or a number field.
Xrm.Page.getControl(field name).fireOnKeyPress();
So addOnKeyPress and removeOnKeyPress basically attach or delete the already attached function with Keypress event while fireOnKeyPress enables Keypress event for text or number fields.
Example:
New Key Press Method on telephone number field
First we will setup a function on the new addOnKeyPress event for the main telephone field.
Xrm.Page.getControl(‘telephone1’).addOnKeyPress(function() { });
Then we will retrieve the value from the main telephone field to get the keys that the user had entered.
var userInput = Xrm.Page.getControl(‘telephone1’).getValue();
Then we will build a regex to replace any of the inputted keys that are not “(“, “)”, “-“, or a number.
userInput = userInput.replace(/[^\d-()]+/g, ”);
Lastly, we will replace the main telephone value with the new clean version of the user’s input
Xrm.Page.getAttribute(‘telephone1’).setValue(userInput);
It’s just that easy!  Now if a user presses an invalid character in the main telephone field, it will automatically delete the character so that the field will not be saved with invalid data.
JavaScript Code 
SetKeyPressMethodOnTelephoneNumber = function () {
Xrm.Page.getControl(‘telephone1’).addOnKeyPress(function () {
var userInput = Xrm.Page.getControl(‘telephone1’).getValue();
userInput = userInput.replace(/[^\d-()]+/g, ”);
Xrm.Page.getAttribute(‘telephone1’).setValue(userInput);
});
}
 Note: – Call these Methods on Form load Event
So, are you satisfied with the workaround given? Do share us your ideas.
To know more about Suyati’s expertise in Microsoft Dynamics CRM, please write to us at services@suyati.com.

About the author:

naveen-kumar-suyatiNaveen Kumar

Naveen Kumar is currently working as a Software Developer at Suyati Technologies. He has around 3 years of experience in Microsoft .NET technologies and owns a vast and dedicated experience in Microsoft Dynamics CRM development. Naveen’s MS Dynamics CRM specialization involves CRM2011, CRM 2013, CRM 2015, and CRM 2016 along with tremendous expertise in C#, HTML, CSS, jQuery, and JavaScript. He likes reading books, listening to music, cooking, playing volleyball and basketball. Besides these, Naveen loves to paint when is free.

0 comment
0
FacebookTwitterLinkedinTumblr
previous post
Open Source Options for Personal Finance Management
next post
STEP training at Suyati

You may also like

What you need to know before kick-starting cloud...

January 13, 2022

An Eye-opener into the Future Trends in Salesforce...

January 13, 2022

Seven Key IT Outsourcing Trends to Expect in...

January 13, 2022

How to Select the Right Partner for a...

January 13, 2022

On Premises vs Cloud CRM: Which is Better?

September 28, 2021

Choosing between Cloud and On-Premise Servers for your...

September 28, 2021

Broken Customer Experience? What’s the Fix?

August 19, 2020

Are Remote Proctored Exams a New Reality?

August 18, 2020

10 Exciting Features in Salesforce’s new Summer ’20...

August 17, 2020

Importance of Data Analytics in Developing Smart Cities

August 11, 2020

Leave a Comment Cancel Reply

Save my name, email, and website in this browser for the next time I comment.

Keep in touch

Twitter Linkedin Facebook Pinterest

Recent Posts

  • What you need to know before kick-starting cloud implementation

    January 13, 2022
  • An Eye-opener into the Future Trends in Salesforce Commerce Cloud

    January 13, 2022
  • Seven Key IT Outsourcing Trends to Expect in 2022

    January 13, 2022

Categories

  • Twitter
  • Linkedin
  • Facebook
  • Instagram
  • Services
    • Salesforce Services
      • Sales Cloud
      • Service Cloud
      • Marketing Cloud
      • Einstein
      • Experience Cloud
      • Mulesoft
      • Commerce cloud
      • Finance cloud
      • CPQ
      • Consultation
      • Implementation
      • Integration
      • Custom Development
      • Salesforce DevOps
      • Support & Maintenance
      • App Development
      • Managed Services
    • IT Services
      • Content Management Services
      • Analytics
      • RPA
      • Front end Technologies
      • Microsoft Applications
      • Cloud
      • DevOps
      • Snowflake
  • Approach
    • Development Methodology
    • Engagement Model
    • Consulting
  • Intel
    • Blog
    • eBooks
    • Webinars
    • Case Studies
  • About Us
    • Management Team
    • Advisory Board
    • Our Story
    • Testimonials
  • Careers
  • Contact Us

© 2021 Suyati Technologies


Back To Top
Suyati Technologies

Popular Posts

  • 1

    What are the Top 3 risks for implementing a CX Program?

    August 30, 2019
  • 2

    Do you need a separate CX Team at your company?

    September 2, 2019
  • 3

    How to build Employee Advocacy for your Business?

    September 3, 2019
  • 4

    What is Salesforce CRM and What Does it Do?

    February 19, 2014
  • 5

    Tips to Reduce Salesforce Pricing

    February 17, 2015
© 2021 Suyati Technologies

Read alsox

Adopting Salesforce community cloud to your business

February 25, 2016

How Blockchain is contributing to Manufacturing 4.0

June 26, 2018

The best open source wearables of 2015

February 23, 2016

By continuing to use this website you agree with our use of cookies. Read More Agree