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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)
Active Discussion

JavaScript XRM control

(1) ShareShare
ReportReport
Posted on by 902

Hi,

I have found this issue recently that if we don't fill value or not use field in form than this field attribute is not found.

Example :

Birthday Field (This field is in form)

Birthday Field ="26=07-2018" then we got value using this method : Xrm.Page.getAttribute('birthdate').getValue();

But

Birthday Field = "" then we got error like this parameter not found using following code :  Xrm.Page.getAttribute('birthdate').getValue() ;

also getting same issue when Set value in field. We didn't get control so How can we set value in empty field ?.

Few days ago we used same function and got null value if we don't fill value. 

Please let me know if you have any suggestion.

Thanks,

*This post is locked for comments

  • Pawar Pravin Profile Picture
    5,237 on at

    Hi keyur,

    If you try with ternary operator in expression then it will not give any error. It doesn't matter where that field is on a form or not it will return null if it not on form or don't have value.

    For example:

    var bdate = Xrm.Page.getAttribute('birthdate') ? Xrm.Page.getAttribute('birthdate').getValue()  : null;

    Hope this help you.... !

    Regards, Pravin

  • Mahendar Pal Profile Picture
    45,095 on at

    In addition to that  before getting value you can simply check if field is avilable on the form or not

    if(Xrm.Page.getAttribute("fieldname")!=null && Xrm.Page.getAttribute("fieldname").getValue()!=null)

    {

    //get value

    }

  • lokesh@dynamisity Profile Picture
    95 on at

    Hi keyur,

      

    Please try to use below code 

    function GetSetDateTimeField()
    {
    // Access the field on the form var field = Xrm.Page.getAttribute("birthdate"); // Verify it does exist on the form if (field != null)
    { // Get its field value; Returns the Date Time value var value = field.getValue(); // Set its field value (Current Date and Time) field.setValue(new Date()); // Set its field value to a specific Date and Time (ex. December 25, 2017) field.setValue(new Date("12/25/2017")) } }

    I hope this will help you 

    Please mark verify if it works

    Thanks and Regard

    Lokesh

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans