Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Character Count on field on my entity.

Posted on by Microsoft Employee

I need to apply Character Count on one of field in my Entity in MS Dynamic CRM 2016.
Thanks in Advance

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Character Count on field on my entity.

    Mark the answer as verified.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Character Count on field on my entity.

    Thank you so much.

    It is realy helpful :)

    Thank once again

  • Suggested answer
    sandeepc Profile Picture
    sandeepc 5,005 on at
    RE: Character Count on field on my entity.

    https://community.dynamics.com/crm/f/117/t/200221

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Character Count on field on my entity.

    Use addOnKeyPress method for Text or numeric field. Multiple lines of Text field doesn't support this method.

    // Call this function on load of form.
    // fieldname: Field whose character are to be counted.
    // fieldCountName: Field where character count is displayed. Single Line of Text
    function setCharacterLength(fieldname, fieldCountName) {
    
    	var nameKeyPressFunction = function (ext) {
    
    		//Get the value from the name field on the form
    		var fieldVal = Xrm.Page.getControl(fieldname).getValue();
    
    		if (fieldVal != null) {
    			var Length = fieldVal.length;
    			Xrm.Page.getAttribute(fieldCountName).setValue(Length.toString());
    		}
    		else{
    			Xrm.Page.getAttribute(fieldCountName).setValue("0");
    		}
    	}
    	Xrm.Page.getControl(fieldname).addOnKeyPress(nameKeyPressFunction);
    }


    Refer this for Multiple lines of text field :

    www.magnetismsolutions.com/.../Dynamics_CRM_2011_Calling_OnKeyDown_With_Javascript.aspx

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans