web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Dynamics CRM 2013 - UpperCase (javascript)

(0) ShareShare
ReportReport
Posted on by

Hello,

I try to convert a field with the follow code:

function UpperCaseField(fieldName) {

   var value = Xrm.Page.getAttribute(fieldName).getValue();

   if (value != null) {

      Xrm.Page.getAttribute(fieldName).setValue(value.toUpperCase());

   }

}

However it happens nothing! What is wrong?

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    i forgot, how i know if the javascript is able?

  • ScottDurow Profile Picture
    21 on at

    Hi

    The code looks fine. How are you calling this - from an on change event? Can your press F12 and check the console for errors?

  • Suggested answer
    Daryl LaBar Profile Picture
    500 Most Valuable Professional on at

    There are 2 main issues I can think of.  Your code is not being called, or your field name is incorrect.

    Check that your function is in a js file that has been added to the form, and that it has been published.  Make sure that you have your field name correct and that it is all lower case.

  • Inogic Profile Picture
    703 on at

    Your code looks fine.

    function UpperCaseField(fieldName) {

        var value = Xrm.Page.getAttribute(attributename).getValue();

        if (value != null)

        {

            Xrm.Page.getAttribute(attributename).setValue(value.toUpperCase());

        }

    }

     

    Can you please check the field Name that you are passing to UpperCaseField function. The pass field name inside quotation.

     

    If are passing the field name as shown in below screenshot then you only need to pass fieldname enclosed in double quotes as shown in below screenshot.

    6180.S.jpg

    Hope this will help you.

    Thanks,

    Sam

  • Suggested answer
    Community Member Profile Picture
    on at

    have you tried calling the uppercase function outside the assignment?

    function UpperCaseField(fieldName) {

       var field = Xrm.Page.getAttribute(fieldName);

       var value;

       if (field != null)

           value = field.getValue();

       if (value != null) {

           value = value.toUpperCase();

           field.setValue(value);

       }

    }

    It's always a good idea to get a field and check for it before get/set values, as it will otherwise result in a null error.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans