How to do it...

To create and try a Python code server action, follow these steps:

  1. Create a new server action: on the Settings top menu, select the Technical | Actions | Server Actions menu item, and click on the Create button at the top
    of the record list.
  2. Fill out the Server Action form with the following values:
    • Action Name: Send Reminder
    • Base Model: Task
    • Action To Do: Execute Python Code
  1. In the Python code text area, remove the default text and replace it with the following:
if not record.date_deadline: 
    raise Warning('Task has no deadline!') 
deadline_dt = datetime.datetime.strptime( 
    obj.date_deadline, '%Y-%m-%d') 
delta = deadline_dt.date() - datetime.date.today() 
days = delta.days 
if days==0: 
    msg =  'Task is due today.' 
elif days < 0: 
    msg = 'Task is %d day(s) late.' % abs(days) 
else: 
    msg = 'Task will be due in %d day(s).' % days 
record.message_post(msg, subject='Reminder', subtype='mt_comment') 
  1. Save the Server Action and click on Add in the 'More' Button at the top-right to make it available in the Project task's More button.
  2. Now, click on the Project top menu and select the Search | Tasks menu item. Pick a random task, set a deadline date on it, and then try the Send Reminder option in the More button.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.227.111.33