I wanted to fill the SalesQuotationTable.QuotationDate (Custom field from older version - Type Date) field in all my quotes,
as this field was set to be mandatory. I created a job to assign the Quote Created Date Time into the SalesQuotationTable.QuotationDate field.
try
{
ttsbegin;
sqt.QuotationDate = sqt.createdDateTime
sqt.update();
ttscommit;
}
catch(Exception::Error)
{
ttsabort;
info("Quotation Date is empty");
}
The compiler gave me an error saying "Operand types are not compatible with the operator"
After reading some information regarding the new UTC date Time for AX 2009 I came to learn that there is a new utility named DateTimeUtil which provides a bunch of date operations such as adding days to a date, converting UTC date times to date, and so on.
You can read more about this utility here http://msdn.microsoft.com/en-us/library/cc619601.aspx
The final code looks like this:
static void SetQuotationDate(Args _args)You can find more info about this here:
{
SalesQuotationTable sqt;
;
while select forupdate sqt
{
try
{
ttsbegin;
sqt.QuotationDate = DateTimeUtil::date(sqt.createdDateTime);
sqt.update();
ttscommit;
}
catch(Exception::Error)
{
ttsabort;
info("Quotation Date is empty");
}
}
}
http://kashperuk.blogspot.com/2010/02/utcdatetime-in-dynamics-ax-2009.html
https://community.dynamics.com/product/ax/axtechnical/b/axrajdipdas/archive/2010/02/08/conversion-of-utcdatetime-in-dynamics-ax-2009.aspx
http://msdn.microsoft.com/en-us/library/cc597805.aspx
No comments:
Post a Comment
Thank you for your thoughts. Your comment will appear in my blog shortly after review.
Have a great day!