How to get a entity's Primary Key field Value RRS feed

  • Question

  • Hi all,

    I get a problem on getting the entity's primary key field value.

    For any other fields, I was able to use "crmForm.all.attributeName.DataValue" to get the value. But I couldn't do so for primary key field. It returns with an error message ...
    "There was an error with this field's customizaed event.
    Field: window
    Event: onload
    Error: 'crmForm.all.attributename.DataValue' is null or not an object"

    Any ideas?
    Thank you

    Wednesday, January 27, 2010 8:23 PM


All replies

  • Hi,
    I know it's simple, but have you checked the syntax and the spelling first? The error you're getting is the same if either is wrong, and it's worth checking the simple things first.


    www.crmconsult.info www.chorusit.com
    Wednesday, January 27, 2010 8:42 PM
  • Also, you may need to check if the record is created or update in your script as the primary key will only be available for update in the OnLoad event.
    Best Regards, Donna
    Wednesday, January 27, 2010 9:17 PM
  • Thank you very much, Robert and Donna.

    I just relized that there was no such PK field in the form. Although, I do have a PK attribute. Then I tried to add this PK attribute into the form as a field, I could not find it in "Add Fields" list....

    Is it because that PK is a system attribute? What should I do to get the PK value?

    Thank you,
    Wednesday, January 27, 2010 9:53 PM
  • =) Everything is very simple! Try to use following code:

    if (crmForm.FormType != 1)

    This code placed on onload event handler of form will give you PK value.
    Truth is opened the prepared mind

    My blog (english)
    Мой блог (русскоязычный)free countersLocations of visitors to this page
    Thursday, January 28, 2010 12:27 AM
  • Thank you veeeeeeeeeeeeeeeeeeeeeeeery much, Andriy. It works as prospected.

    Thursday, January 28, 2010 6:18 PM