向Task添加自定义属性?

时间:2013-07-01 09:50:14

标签: asana

如何通过API向Task添加自定义属性/数据。例如,我们想添加客户联系电话或交易金额等字段e.t.c

2 个答案:

答案 0 :(得分:2)

我们目前不支持向任务添加任意元数据,尽管这是我们正在考虑的事情。与此同时,许多客户所做的是简单地将数据以易于解析的形式放入便条字段中,该形式运行良好并且还允许人们阅读任务。门票号码。

这不是一个非常优雅的解决方案,但它确实有效。

答案 1 :(得分:2)

https://asana.com/developers/documentation/getting-started/custom-external_data

  

自定义外部数据允许客户端应用程序将特定于应用程序的元数据添加到API中的任务。自定义数据包括可用于检索对象的字符串ID和可存储字符串的数据blob。

请参阅https://asana.com/developers/api-reference/tasks

上的ArrayList<String> list = new ArrayList<>(); list.add("A7750 0.0 28.30"); list.add("A7741 0.0 31.40"); list.add("A7760 0.1 31.40"); list.add("A7741 0.1 31.40"); list.add("A7750 0.3 28.30"); list.add("A7750 0.6 28.36"); // add if you want more ... // Create map for different tags and their list Map<String, List<String>> mapOfTagAndList = new HashMap<>(); // Enter the tags and their list into the map for (int i = 0; i < list.size(); i++) { String s = list.get(i); String tag = s.split(" ")[0]; List<String> listWithTag = new ArrayList<>(); if(!mapOfTagAndList.containsKey(tag)) { listWithTag.add(s); mapOfTagAndList.put(tag, listWithTag); } else { listWithTag = mapOfTagAndList.get(tag); listWithTag.add(s); mapOfTagAndList.put(tag, listWithTag); } } // Print the tags and their lists for (Map.Entry<String, List<String>> entry : mapOfTagAndList.entrySet()) { String tag = entry.getKey(); System.out.println("tag = "+tag); List<String> tagList = entry.getValue(); System.out.println("list for the tag = "+tagList); } 字段