Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

How to set date field in Microsoft portals using javascript

Posted on by Microsoft Employee

Hi All,

I have a requirement to populate a date field on crm portal.

The date is coming from an odata feed, but I am not sure of the correct syntax to populate the field

The data format of the date field is DD/MM/YYYY

i'm sure someone has done this before, but I am unable to find a solution.

Any ideas would be appreciated

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to set date field in Microsoft portals using javascript

    Thank you Ajyendra

  • Verified answer
    ajyendra Profile Picture
    ajyendra 1,730 on at
    RE: How to set date field in Microsoft portals using javascript

    Hi,

    date = new Date('2019-11-12T00:00:00Z');

    year = date.getFullYear();

    month = date.getMonth()+1;

    dt = date.getDate();

    if (dt < 10) {

     dt = '0' + dt;

    }

    if (month < 10) {

     month = '0' + month;

    }

    console.log(dt+'/' + month + '/'+year);

    For Moment you have to use cdn or refernce of moment.js file. You can easily do with in only one statement

    moment("2019-11-12T00:00:00Z").format('DD/MM/YYYY')

    https://community.dynamics.com/crm/b/thinkdynamicdodynamic/posts/set-or-auto-populate-value-in-date-field-crm-portal

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to set date field in Microsoft portals using javascript

    Hi Andrew,

    This is the error I get

    pastedimage1573092002813v1.png

    and this is the data i'm getting from the odata feed

    pastedimage1573092267545v2.png

    Any ideas?

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: How to set date field in Microsoft portals using javascript

    Hello,

    Check this - bernado-nguyen-hoan.com/.../

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans