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)

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

I have the same question (0)
  • 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

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