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)

Get the database value of a Bit field:

(0) ShareShare
ReportReport
Posted on by 382

Hi All,

// example GetBitValue("telephone1");
function GetBitValue(fieldname) {
    return Xrm.Page.data.entity.attributes.get(fieldname).getValue();
}
firstly for the above in place of fieldname both the places should I use "telephone1" i.e with quotation marks or what..
and secondly is the function "GetBitValue" valid for crm 2015  and what is meant by bit Field..
because am getting the error  : "GetBitValue" is udefined..
I have this in the below url  6th one
plz..help me with this .

*This post is locked for comments

I have the same question (0)
  • Rajkumar Rajaraman Profile Picture
    on at

    For Bit field, walkthrough this:

    www.infinite-x.net/.../crm-bit-fields-creating-a-consistent-user-experience

    Get and Set Bit fields using javascript refer this,

    intersection3.com/.../dynamics-crm-2015-javascript-reference

  • Suggested answer
    Mahendar Pal Profile Picture
    45,095 on at

    Hello,

    "firstly for the above in place of fieldname both the places should I use "telephone1" i.e with quotation marks or what " ---------

    This is a correct code only where GetBitValue("telephone1") is calling of the method, so here you are passing telephone1 field, if you want to get another field you will be sending like this only, for example GetBitValue("address1_city")

    "Ssecondly is the function "GetBitValue" valid for crm 2015  and what is meant by bit Field.."

    The same function will work for CRM 2015 as well. Bit field is another field (actually "two optionset") that is used to get true or false option, so if you want get value of your bit field you need to just pass name of your bit field to this method

    Make sure you are not missing any { otherwise you will get error, you could share your updated code here for inquery

  • Mohammed Waseem Profile Picture
    382 on at

    Hi HIMBAP,

          // JavaScript source code

    GetBitValue("telephone1");

    function GetBitValue(fieldname) {

       var first= Xrm.Page.data.entity.attributes.get(fieldname).getValue();

       alert(first):

    }

    above is the code and I have added this on on change event of phone field and am calling GetBitValue   i.e first function

    is it the right way..?

  • Mohammed Waseem Profile Picture
    382 on at

    am getting the Error :'GetBitValue' is undefined

  • Suggested answer
    Mahendar Pal Profile Picture
    45,095 on at

    If you want to call then you need one more method like below, and you need to call GetValue method onchange of the field, just function name without any ()

    function GetValue()

    {

    GetBitValue(Xrm.Page.getAttribute("telephone1"));

    }

    function GetBitValue(fieldname) {

      var first= Xrm.Page.data.entity.attributes.get(fieldname).getValue();

      alert(first);

    }

  • Verified answer
    Community Member Profile Picture
    on at

    In this line:

       alert(first):

    you end with a colon, not a semicolon;

    I think this is therefore failing syntax checks, so the function does not get defined.

    Other than that, you want to call a function that calls this function, as mentioned above. Or pass in the execution context, or just call GetBitValue and pass the field name with quotes round it "telephone1"

    I would suggest you rename this function anyway, since you are actually fetching a value which is not from a bit field, but text in this case. Your function is really just "GetValue". This might make things clearer to anyone else, or you, trying to troubleshoot in future, otherwise their first reaction is likely to be "why are you trying to get a bit value from a text field?" (even though you are not).

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