SugarClub
SugarClub
  • User
  • Site
  • Search
  • User
SugarClub
SugarClub
  • User
  • Site
  • Search
  • User
DevClub
DevClub
Dev Tutorials Remove custom fields created via package installation
  • Dev Blog
  • Answers & Best Practices
  • Dev Tutorials
  • Developer Events
  • Developer Suggestions
  • Members
  • Tags
  • Event Recaps
  • Sub-Groups
  • More
  • Cancel
  • New
Click here to join "DevClub" to engage in the conversation with this group and curate your SugarClub experience.
  • Adding a google reCAPTCHA in a Web-to-Lead form
  • Developer Tutorials
  • Did you know? Copying related records is a breeze!
  • Getting Started with SugarCRM Development
  • How to write code for SugarCloud webinar Q&A
  • HOW TO: enforce ACL on Tags
  • On-Boarding new Sugar Developers
  • Programatically manage Dropdown List
  • Remove custom fields created via package installation
  • Sugar 10.0 (Q2 2020) Customization Guide
  • Sugar Developer Blog Style Guide
  • Sugar Developer Tools
  • Sugar Developer Webinar - Q2 2020 (10.0.0)
  • Sugar Developer Webinar - Q3 2020 (10.1.0)
  • Tutorial:  How to register custom platforms in Sugar instances via Platform extension

Remove custom fields created via package installation

Hi,

    I've attached the manifest we use to install a package into sugar. It works fine and all hunky dory. But when we uninstall the package, it leaves all these custom fields in the tables. How do I remove them?

Kind Regards,
Madhav Shenoy

Hi Madhav Shenoy

Use below code in post_uninstall.php . this will help you

    $fieldsByModule = array(
        'Campaigns' => array(
            'is_scheduled_c',
        ),
    );


    require_once('modules/DynamicFields/DynamicField.php');


    foreach ($fieldsByModule as $moduleName => $fields) {
        foreach($fields as $field){
            $dyField = new DynamicField();
            $dyField->bean = BeanFactory::getBean($moduleName);;
            $dyField->module = $moduleName;
            $dyField->deleteField($field);
        }
    }






post_uninstall script is a solution i agree but Why not you create each custom field file and copy file like this? this will aautomaticallydelete it from database and from code directory also.Its easy to manage also whenever you want to change/update field just test at local and replace file in package.

    array (

  'from' => '<basepath>/SugarModules/custom/Extension/modules/Campiagns/Ext/Vardefs/sugarfield_yourFiled.php',

  'to' => 'custom/Extension/modules/Campiagns/Ext/Vardefs/sugarfield_yourFiled.php',

    ),

This document was generated from the following discussion: Remove custom fields created via package installation

1172._manifest.php.zip

  • Share
  • History
  • More
  • Cancel
Anonymous
Related
Recommended