Customizing Pre-Fill for Duplicate Records in Sugar7

  • Home
  • Blog
  • Customizing Pre-Fill for Duplicate Records in Sugar7
Customizing Pre Fill for Duplicate Records in Sugar7

Sometimes it becomes crucial to restrict certain fields from being copied as values of certain fields can change when a duplicate record is made. To eliminate the risk of repetition or data modification, customize pre-fill for duplicate records in Sugar7 by the override function on the “Record View” called setupDuplicateFields. Through this functionality, you can alter fields that will be used to pre-fill the duplicated records.

See the example below where highlighted fields in the “blacklist” variable can be unset or reverted to their default value, if provided in the field’s metadata.

({

//The below jsdoc was copied from base RecordView controller in Sugar7

extendsFrom: ‘RecordView’,

/**

* Called when current record is being duplicated to allow customization of

* fields that will be copied into a new record.

*

* Override to setup the fields on this bean prior to being displayed in

* Create dialog.

*

* @param {Object} prefill Bean that will be used for new record.

* @template

*/

setupDuplicateFields: function(prefill){

var duplicateBlackList = [“id“, “status“, “custom_field_c“];

_.each(duplicateBlackList, function(field){

if(field && prefill.has(field)){

//set blacklist field to the default value if exists

if (!_.isUndefined(prefill.fields[field]) && !_.isUndefined(prefill.fields[field].default)) {

prefill.set(field, prefill.fields[field].default);

} else {

prefill.unset(field);

}

}

});

}

})

Rolustech is a SugarCRM Certified Developer & Partner Firm. We have helped more than 600 firms with various SugarCRM customizations and integrations. Contact us today for your FREE consultation session. We will be happy to assist you!