I am trying to import vendor list from csv. While creating Issue as Vendor name I have applied validator for existing vendor name. It is affecting while creating vendor manually. But it is not affecting while creating vendor while importing from csv
CSV imports bypass all validation other than "summary is mandatory". You'll need to get your data correct in the source CSV, rather than rely on whatever your validators do.
You could use some script to import issues. I used this script to import a lot of issues from some source (~ 2 000 issues). It could be executed via ScriptRunner. I merged requlred values into a strings with "#" separtor from all sources, parced it into script and create issues.
import com.atlassian.jira.bc.issue.IssueService import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.IssueInputParameters import com.atlassian.jira.project.Project import com.atlassian.jira.project.ProjectManager import com.atlassian.jira.user.ApplicationUser import com.atlassian.jira.util.ErrorCollection /** * Скрипт по заливке запросов из файла Excel */ String[] splitedImpStr = new String[3]; final String prjKeyPrefix = "MSC" String result = ""; ApplicationUser curAppUser = ComponentAccessor.jiraAuthenticationContext.getUser(); ProjectManager prjMng = ComponentAccessor.getProjectManager(); //подготавливаем создание запроса IssueService issueService = ComponentAccessor.getIssueService(); IssueInputParameters inputParameters = issueService.newIssueInputParameters(); //Цикл по созданию запросов for(String curImportedStr: getStringsForImport()){ splitedImpStr = curImportedStr.split("##") if(getValue(splitedImpStr[2]).equals("")) continue; Project curPrj = prjMng.getProjectObjByKey(prjKeyPrefix + getPrjNmb(splitedImpStr[1])); if(curPrj == null) return "Проект не найден" inputParameters.setProjectId(curPrj.getId()) .setIssueTypeId("10903") .setSummary("Еженедельный отчет") .setReporterId("vzverev") .setAssigneeId(curPrj.getLeadUserKey()) .setEnvironment("Enviroment") .setStatusId("6") .setPriorityId("2") .setDueDate(getDueDate(Integer.parseInt(getValue(splitedImpStr[0])))) .addCustomFieldValue(10807, getValue(splitedImpStr[2])); IssueService.CreateValidationResult createValidationResult = issueService.validateCreate(curAppUser, inputParameters); ErrorCollection errorCollection = createValidationResult.getErrorCollection(); result = errorCollection.toString(); if(createValidationResult.isValid()){ IssueService.IssueResult createResult = issueService.create(curAppUser, createValidationResult); if(!createResult.isValid()) return "Bad" } } return result; public String getDueDate(int _week){ Calendar dueDate = Calendar.getInstance(); dueDate.set(Calendar.WEEK_OF_YEAR, _week); return dueDate.get(Calendar.DAY_OF_MONTH) + "/" + (dueDate.get(Calendar.MONTH) + 1) + "/" + dueDate.get(Calendar.YEAR); } public int getPrjNmb(String _forParsing){ String prjNmb = ""; for(Character ch: getValue(_forParsing)) if( ch.isDigit() ) prjNmb += ch; return Integer.parseInt(prjNmb); } public String getValue(String _input){ return _input.substring(_input.indexOf("=") + 1, _input.length()) } public List<String> getStringsForImport(){ List<String> stringsForImport = new ArrayList<String>(); return stringsForImport; }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.