0

I have an older version of sugarcrm 4.5 running.

Dont brake that aint broken.

I have a script i wrote that adds 30 days from current date to expected close date when creating a new opportunity, but the problem is everytime you edit the opportunity it adds 30 days, and not just when its is new. How do i tel Sugar to only look for new. this is in editview.php not a logic hook as i want to display the date in the field when creating.

Heres my code

var currentTime = new Date();
document.getElementsByName('date_closed')[0].value = (year = currentTime.getFullYear())+'-'+(month = currentTime.getMonth() + 2)+'-'+(day = currentTime.getDate());

regards

4

1 回答 1

0

这应该通过 before save 逻辑钩子来完成 - 您可以测试记录是否在钩子中有 id。如果它没有 id,那么你可以假设它是一个新记录。

可以在此处找到有关逻辑挂钩的更多信息(您使用的是非常旧的 SugarCRM 版本,因此并非本文档中的所有内容都适用)

http://developers.sugarcrm.com/docs/OS/5.2/-docs-Developer_Guides-Developer_Guide_5.2-DevGuide%205.2.1.47.html

于 2013-04-03T11:40:49.373 回答