The CSV file and the CSV Import script shown below demonstrate how to import custom fields of various types.
CSV file:
Name,Category,UserUDF,URLUDF,MultiListUDF,TaskUDF,IntegerUDF,ListUDF,DateUDF,FloadUDF,StringUDF,MemoUDF "Products","Folder","jsmith;pdagley;slaw","http://www.trackstudio.com - TrackStudio", "multiListValue3;multiListValue4","#2;#4;#5","54","listValue2","12/16/05 3:38 PM", "5.6","stringUdf value","memo UDF value" "Customer Support","Folder","cparmenter;smanske","http://localhost:8888/TrackStudio - local TrackStudio instance", "multiListValue1;multiListValue2;multiListValue4","#15;#16;#18;#22;#23","33","listValue2","12/30/05 3:40 PM", "43.6","str val2","memval2"
CSV Import script:
Map taskMap = new HashMap(); String locale = sc.getUser().getLocale(); DateFormatter df = new DateFormatter(sc.getUser().getTimezone(), locale); taskMap.put(CSVImport.TASK_NAME, inputMap.get("Name")); taskMap.put(CSVImport.TASK_CATEGORY_ID, CSVImport.findCategoryIdByName((String) inputMap.get("Category"))); Map udfMap = new HashMap(); if (inputMap.get("MemoUDF") != null) udfMap.put("MemoUDF", inputMap.get("MemoUDF")); if (inputMap.get("DateUDF") != null && !inputMap.get("DateUDF").equals("")) udfMap.put("DateUDF", sc.getUser().getDateFormatter().parse( df.parseToCalendar((String)inputMap.get("DateUDF")))); if (inputMap.get("FloadUDF") != null) udfMap.put("FloadUDF", inputMap.get("FloadUDF")); if (inputMap.get("IntegerUDF") != null) udfMap.put("IntegerUDF", inputMap.get("IntegerUDF")); if (inputMap.get("StringUDF") != null) udfMap.put("StringUDF", inputMap.get("StringUDF")); if (inputMap.get("ListUDF") != null) udfMap.put("ListUDF", inputMap.get("ListUDF")); if (inputMap.get("MultiListUDF") != null) udfMap.put("MultiListUDF", inputMap.get("MultiListUDF")); if (inputMap.get("TaskUDF") != null) udfMap.put("TaskUDF", inputMap.get("TaskUDF")); if (inputMap.get("UserUDF") != null) udfMap.put("UserUDF", inputMap.get("UserUDF")); if (inputMap.get("URLUDF") != null) udfMap.put("URLUDF",inputMap.get("URLUDF")); taskMap.put(CSVImport.TASK_UDF_MAP, udfMap); return taskMap;