From: Seamus Lee Date: Sun, 28 Jan 2018 05:07:02 +0000 (+1100) Subject: CRM-20996 fix db error when using the Copy function for profiles from contribution... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e2beed76160d86d1c8ebb3078d948b89f2ffb44f;p=civicrm-core.git CRM-20996 fix db error when using the Copy function for profiles from contribution or event pages --- diff --git a/js/model/crm.uf.js b/js/model/crm.uf.js index c6c769e84b..a6ab2982ae 100644 --- a/js/model/crm.uf.js +++ b/js/model/crm.uf.js @@ -687,8 +687,17 @@ return _.omit(ufFieldModel.toStrictJSON(), ['id', 'uf_group_id']); }) ); - var copyLabel = ' ' + ts('(Copy)'); - copy.set('title', copy.get('title').slice(0, 64 - copyLabel.length) + copyLabel); + var new_id = 1; + CRM.api3('UFGroup', 'getsingle', { + "return": ["id"], + "options": {"limit": 1, "sort": "id DESC"} + }).done(function(result) { + new_id = Number(result.id) + 1; + var copyLabel = ' ' + ts('(Copy)'); + var nameSuffix = '_' + new_id; + copy.set('title', copy.get('title').slice(0, 64 - copyLabel.length) + copyLabel); + copy.set('name', copy.get('name').slice(0, 64 - nameSuffix.length) + nameSuffix); + }); return copy; }, getModelClass: function(entity_name) {