From e2beed76160d86d1c8ebb3078d948b89f2ffb44f Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sun, 28 Jan 2018 16:07:02 +1100 Subject: [PATCH] CRM-20996 fix db error when using the Copy function for profiles from contribution or event pages --- js/model/crm.uf.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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) { -- 2.25.1