locked
Get/Request a fieldname by Jscript RRS feed

  • Question

  • Dear All,

    Probaly i have a really simple question, which ofcourse i can't find out myself.
    I need to get or request the name of a field in an onChange event.

    An example:
    You can request the name of an entity:
    var a = crmForm.ObjectTypeName;
    But how do you do this for a field? I've really searched all the books on my shelf and spend an hour on the internet.
    So if its even possible, how can i accomplish this?

    Im using CRM4.0 by the way.
    The goal is that the fieldname is put in a variabele so i can put that in an URL. The variabele refers to a JS that must be called.
    Friday, April 24, 2009 1:38 PM

Answers

  • Here's what you need:

    alert(event.srcElement.id);

    This will give you the name of the field that your OnChange is coming from.  However, be aware that if you use crmForm.all.new_field.FireOnChange(); to call the above code that you will get the name of the field where event.srcElement.id resides.  It's short enough of a line of code that you shouldn't need to worry about using the FireOnChange method, but I just wanted to make you aware in case you have more complex needs and tried that.

    Also, if you aren't aware, there is a developer's forum where you might get responded to faster than posting here in the deployment forum.

    Fronk
    http://dmcrm.blogspot.com
    • Marked as answer by Jim Glass Jr Friday, April 24, 2009 7:32 PM
    Friday, April 24, 2009 7:12 PM

All replies

  • Here's what you need:

    alert(event.srcElement.id);

    This will give you the name of the field that your OnChange is coming from.  However, be aware that if you use crmForm.all.new_field.FireOnChange(); to call the above code that you will get the name of the field where event.srcElement.id resides.  It's short enough of a line of code that you shouldn't need to worry about using the FireOnChange method, but I just wanted to make you aware in case you have more complex needs and tried that.

    Also, if you aren't aware, there is a developer's forum where you might get responded to faster than posting here in the deployment forum.

    Fronk
    http://dmcrm.blogspot.com
    • Marked as answer by Jim Glass Jr Friday, April 24, 2009 7:32 PM
    Friday, April 24, 2009 7:12 PM
  • Thank you for your input.
    Only we already had it figured out:

    var thisF = arguments.callee.toString();
    var thisField = thisF.substr(9, thisF.indexOf('_') - 9);

    It is a little bit longer though.

    Monday, April 27, 2009 11:42 AM