Results 1 to 7 of 7

Thread: Delete Project Tasks when A Project is delete in CE

  1. #1
    oozypal is offline Senior Member
    Join Date
    Jan 2009
    Posts
    43

    Default Delete Project Tasks when A Project is delete in CE

    Hello,

    Can you guys/gals help in doing the following:

    1. Delete all Project Tasks when its Project is deleted
    2. Show warning or some indication when the project task end date is past the project end date
    CE 6.0.1beta2

  2. #2
    davidboris is offline Sugar Community Member
    Join Date
    May 2010
    Posts
    1,113

    Default Re: Delete Project Tasks when A Project is delete in CE

    Hello,

    You can use after_delete logic_hook to delete the related records.
    Thumbs up.

    Skype ID - david__boris

    SugarForge Projects:

    WYSIWYG now in studio!(Version 1.1 is out now!)

    Sugar Feeds on your personalized home pages like iGoogle, My Yahoo!, etc.

    Fab Tools! > Dashlet Not Followed Opportunities for past six Months

  3. #3
    oozypal is offline Senior Member
    Join Date
    Jan 2009
    Posts
    43

    Default Re: Delete Project Tasks when A Project is delete in CE

    Hello,

    I did the logic hook and it works; however, I am not sure how to start the deletion process.

    Can you put on the right track.

    Thank you

    Logic Hook
    PHP Code:
    <?php
    $hook_version 
    1
    $hook_array = Array(); 
    $hook_array['after_save'] = Array(); 
    $hook_array['after_save'][] = Array(1,     'ProjectAssignmentNotification'
                                            
    'custom/modules/Project/email_notes.php',
                                            
    'userNotification'
                                            
    'notifyAssignee'); 


    $hook_array['after_delete'] = Array(); 
    $hook_array['after_delete'][] = Array(1'ProjectAssignmentNotification'
                                            
    'custom/modules/Project/delete_children.php',
                                            
    'deleteChildren'
                                            
    'deleteChild'); 


    ?>
    Deletion File
    PHP Code:
    <?php
        
    class deleteChildren{
        
            function 
    deleteChild(&$bean$event$arguments)
            {
                echo 
    "delete ok";
                break;    
            }
        }

    ?>
    CE 6.0.1beta2

  4. #4
    davidboris is offline Sugar Community Member
    Join Date
    May 2010
    Posts
    1,113

    Default Re: Delete Project Tasks when A Project is delete in CE

    Hello,

    Write following code in function,

    PHP Code:
    $sugarbean = new ProjectTask();
            
    $query "SELECT id FROM project_task WHERE project_id = '" $bean->id "' AND deleted = 0";
            
    $result $sugarbean->db->query($query,true,"Error retrieving project tasks");
            while(
    $row $sugarbean->db->fetchByAssoc($result))
            {
                
    $sugarbean->mark_deleted($row['id']);
            } 
    Thumbs up.

    Skype ID - david__boris

    SugarForge Projects:

    WYSIWYG now in studio!(Version 1.1 is out now!)

    Sugar Feeds on your personalized home pages like iGoogle, My Yahoo!, etc.

    Fab Tools! > Dashlet Not Followed Opportunities for past six Months

  5. #5
    oozypal is offline Senior Member
    Join Date
    Jan 2009
    Posts
    43

    Default Re: Delete Project Tasks when A Project is delete in CE

    Hello,

    It did not work. The project get deleted and the project task are not.

    There is no error.

    The code does not go inside the while loop.

    Any idea?

    OOzy
    CE 6.0.1beta2

  6. #6
    davidboris is offline Sugar Community Member
    Join Date
    May 2010
    Posts
    1,113

    Default Re: Delete Project Tasks when A Project is delete in CE

    Hello,

    Use before_delete logic hook instead.
    Thumbs up.

    Skype ID - david__boris

    SugarForge Projects:

    WYSIWYG now in studio!(Version 1.1 is out now!)

    Sugar Feeds on your personalized home pages like iGoogle, My Yahoo!, etc.

    Fab Tools! > Dashlet Not Followed Opportunities for past six Months

  7. #7
    oozypal is offline Senior Member
    Join Date
    Jan 2009
    Posts
    43

    Default Re: Delete Project Tasks when A Project is delete in CE

    Bingo!! Worked like a charm!

    Thank you

    OOzy
    CE 6.0.1beta2

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Project / Project tasks
    By darcy.rippon in forum Developer Help
    Replies: 5
    Last Post: 2010-07-23, 03:43 PM
  2. Replies: 7
    Last Post: 2009-05-27, 01:36 PM
  3. Replies: 0
    Last Post: 2008-07-08, 01:06 PM
  4. Replies: 2
    Last Post: 2007-07-02, 05:28 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •