AnsweredAssumed Answered

Difficulty Manipulating Date Fields When Creating A New Task

Question asked by Zayne Hilsberg on May 13, 2014
Latest reply on May 13, 2014 by Zayne Hilsberg
Hi there!

I'm fairly new to Sugar and I'm trying to manipulate a date field when creating a task. I have already created a before_save logic hook in my accounts module that generates a new task when the "interview date" (DateTime type) field is changed. However, I need the due date of the task to be set to the interview date + 7 days. I have been able to successfully set the wrong due due date by following this how-to. I originally tried this code:
$task->date_due = TimeDate::getInstance($bean->interview_c)->getNow(true)->modify("+7 days")->asDb();
However, this calculated the due date based on the current date. A quick look at SugarCRM's TimeDate.php showed me that this was because getInstance() does not accept any parameters.

I've spent a lot of time googling possible solutions (this is not my first clash with SugarCRM's crazy datetime values) and trying other possible approaches, but I can only find solutions for calculating based off of the current datetime. I am using SugarCRM CE 6.5, so calculated fields and workflow are not solutions available to me.

Does anyone have any idea how I could go about calculating the due date based off of the custom "interview date" field through logic hooks?

Thanks in advance for your time!

Outcomes