diff --git a/project-management/backend/src/main/java/io/metersphere/service/IssueTemplateService.java b/project-management/backend/src/main/java/io/metersphere/service/IssueTemplateService.java index ec8f51fb65..fb75d3b399 100644 --- a/project-management/backend/src/main/java/io/metersphere/service/IssueTemplateService.java +++ b/project-management/backend/src/main/java/io/metersphere/service/IssueTemplateService.java @@ -493,13 +493,22 @@ public class IssueTemplateService extends TemplateBaseService { for (CustomFieldTemplate customFieldTemplate : customFields) { CustomField customField = customFieldMapper.selectByPrimaryKey(customFieldTemplate.getFieldId()); CustomFieldDao customFieldDao = new CustomFieldDao(); - BeanUtils.copyBean(customFieldDao, customField); - customFieldDao.setDefaultValue(customFieldTemplate.getDefaultValue()); - List columnsField = ReflexObjectUtil.getColumns(customFieldDao, SystemReference.issueFieldColumns); - columns.addAll(columnsField); + if (customField != null) { + BeanUtils.copyBean(customFieldDao, customField); + customFieldDao.setDefaultValue(customFieldTemplate.getDefaultValue()); + List columnsField = ReflexObjectUtil.getColumns(customFieldDao, SystemReference.issueFieldColumns); + columns.addAll(columnsField); + } else { + customFieldDao.setName(StringUtils.EMPTY); + customFieldDao.setScene(StringUtils.EMPTY); + customFieldDao.setType(StringUtils.EMPTY); + customFieldDao.setSystem(null); + customFieldDao.setRemark(StringUtils.EMPTY); + customFieldDao.setDefaultValue(StringUtils.EMPTY); + List columnsField = ReflexObjectUtil.getColumns(customFieldDao, SystemReference.issueFieldColumns); + columns.addAll(columnsField); + } } - List columnIssues = ReflexObjectUtil.getColumns(templateWithBLOBs, SystemReference.issueFieldColumns); - columns.addAll(columnIssues); OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(templateWithBLOBs.getId()), templateWithBLOBs.getProjectId(), templateWithBLOBs.getName(), templateWithBLOBs.getCreateUser(), columns); return JSON.toJSONString(details);