locked
Fill in Present Date on DateTime Attribute RRS feed

  • Question

  • After being unable to automatically generate the date on an attribute using a workflow, I am now trying to generate the present date when certain fields are filled in using OnChange.

    My specific example is for a sales process. Once the Sponsor, Existing Solution and Apparent Solution fields have been filled out (contain data), I would like to have the Prospecting field (datetime attribute, date only) date be set to present date once the last field contains data.

    Can anybody help me with this? I have looked all over to find a way to automaticaly generate the datefield and have had no luck in finding a solution.

    Friday, July 30, 2010 9:16 PM

Answers

  • Hi Michael,

    Use below code: In Javascript the comparision operator is "==", and "=" is an assignment operator.

    if(crmForm.all.zy_opportunitytype.DataValue == '1')

    { crmForm.all.zy_prospecting.DataValue = new Date();

    }

    else

    {

    }

    Hope this helps.

     


    Thanks, Ranjitsingh R | http://mscrm-developer.blogspot.com/ | MS CRM Consultant
    • Proposed as answer by Ranjitsingh R Tuesday, August 3, 2010 5:53 AM
    • Marked as answer by Michael Karls Tuesday, August 3, 2010 6:05 PM
    Tuesday, August 3, 2010 5:53 AM

All replies

  • Hi, Michael. Try use following code:

    crmForm.all.<your datetime field name here>.DataValue = new Date();


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Friday, July 30, 2010 9:28 PM
    Moderator
  • Hi Michael,

    Use the OnChange Event on the last field. Check conditions that all fileds filled with data and then use the below code to set the present date on the field:

    crmForm.all.<datetime field>.DataValue = new Date();

    Ex: crmForm.all.scheduledend.DataValue = new Date();

    Hope this helps.


    Thanks, Ranjitsingh R | http://mscrm-developer.blogspot.com/ | MS CRM Consultant
    Saturday, July 31, 2010 4:19 AM
  • Thank you for your help so far. The first instance I need to use it is when a picklist value is set. Then I need the datetime field to be set to the present day. I wrote this code, but it didn't work.....currently working on modifying it

    if(crmForm.all.zy_opportunitytype.DataValue = '1')

    { crmForm.all.zy_prospecting.DataValue = new Date();

    }

    else

    {

    }

    Monday, August 2, 2010 7:06 PM
  • Hi Michael,

    Use below code: In Javascript the comparision operator is "==", and "=" is an assignment operator.

    if(crmForm.all.zy_opportunitytype.DataValue == '1')

    { crmForm.all.zy_prospecting.DataValue = new Date();

    }

    else

    {

    }

    Hope this helps.

     


    Thanks, Ranjitsingh R | http://mscrm-developer.blogspot.com/ | MS CRM Consultant
    • Proposed as answer by Ranjitsingh R Tuesday, August 3, 2010 5:53 AM
    • Marked as answer by Michael Karls Tuesday, August 3, 2010 6:05 PM
    Tuesday, August 3, 2010 5:53 AM
  • Ahh...so simple. Thank you very much Ranjitsingh!
    Tuesday, August 3, 2010 6:06 PM