Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Unable to set date field from result set returned by Xrm.WebApi.retrieverecord (javascript)

Posted on by 17

Unable to set date field

Xrm.WebApi.retrieveRecord(cmLogicalName, cmGuid, "?$select=lvt_completiondate").then(

                function success(result) {

                    debugger;

                    var duedatebasedonCM = result["lvt_completiondate@OData.Community.Display.V1.FormattedValue"]; //"28/02/2019"

                    Xrm.Page.getAttribute("lvt_duedate").setValue(duedatebasedonCM); //no error // Value is not set

                    },

                function (error) {                

                }

            );

*This post is locked for comments

  • Verified answer
    Manasi Profile Picture
    Manasi 17 on at
    RE: Unable to set date field from result set returned by Xrm.WebApi.retrieverecord (javascript)

    Converted the date as below and it worked.

    duedatebasedonCM=new Date(duedatebasedonCM);

  • Bhavika A. Vala Profile Picture
    Bhavika A. Vala 70 on at
    RE: Unable to set date field from result set returned by Xrm.WebApi.retrieverecord (javascript)

    Please validate your date format.  Is there same format for both date field?

  • Verified answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Unable to set date field from result set returned by Xrm.WebApi.retrieverecord (javascript)

    Hi,

    You need to convert Date object before set the value .Try with this -

           Xrm.Page.getAttribute("lvt_duedate").setValue(new Date(result["lvt_completiondate@OData.Community.Display.V1.FormattedValue"]));

    Check here for more info-

    http://himbap.com/blog/?p=2874

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans