I was recently asked how to change the values that get entered into the new record when a user copies an existing record.
This post will discuss how to make a simple change to your module’s record view in order to change how fields get prefilled into a duplicated record in Sugar 7.
For many modules, it is important to make sure that certain fields are not copied or that the value of certain fields are changed to some other value like a default. We do this in Sugar 7 in a couple of different places. For example, if you try to copy an existing Task record in Sugar 7 then you will find that the duplicated Task’s status will be set to ‘Not Started’ regardless of the original value.
There is a function on the Record View called setupDuplicateFields that you can override to modify the fields that are used to prefill the duplicated record.
See the custom RecordView controller below as an example. This example takes the fields in the blacklist and unsets them or reverts them to their default value if provided in the field’s metadata.