1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

AsanaとGoogle Apps Scriptを連携する、使い方編

Last updated at Posted at 2021-06-02

こんにちは、な~です。

今日は、前回紹介した、AsanaManagerオブジェクトを使ってみましょう!
代表的なものを紹介します。

タスクの読み込み

/**
 * テスト用タスクの読み込み
 */
function read() {
  const token = '';
  const taskId = '';

  //オブジェクトを作成する
  const asanaManager = new AsanaManager(token);
  //タスクIDのデータを取得する
  console.log(asanaManager.getTaskData(taskId));
}

タスクの作成

/**
 * タスクの作成
 */
function create() {

  const token = '';

  const workspaceId = '';
  const projectId = "";
  const name = '追加したいタスク名';
  const planText = 'タスクの内容!!!!!!';
  const tanto = ''; //IDで指定

  const objTask = {
    "data": {
      "workspace": workspaceId,
      "projects": [projectId],
      "name": name,
      "notes": planText,
      "assignee": { "gid": tanto, "resource_type": "user" }
    }
  };
  //オブジェクトを作成する
  const asanaManager = new AsanaManager(token);
  //処理を呼ぶ
  console.log(asanaManager.createTask(objTask));
}

セクションの移動

/**
 * セクションの移動
 */
function move() {
  const token = '';
  const sectionId = '';
  const taskId = '';

  //オブジェクトを作成する
  const asanaManager = new AsanaManager(token);
  const objSetSection = {
    "data": {
      "task": taskId
    }
  };
  asanaManager.addTaskToSection(sectionId, objSetSection);
}

サブタスクを作成する

/**
 * サブタスクを作成する
 */
function subTask() {
  const token = '';
  const taskId = '';
  const workspaceId = '';
  const name = '追加したいタスク';
  const planText = 'タスクの内容!!!!!!';
  const tanto = '';


  const objSubtask = {
    "data": {
      "workspace": workspaceId,
      "name": name,
      "notes": planText,
      "assignee": { "gid": tanto, "resource_type": "user" }
    }
  };
  const asanaManager = new AsanaManager(token);
  asanaManager.createSubtask(taskId, objSubtask);
}

タスクの更新

/**
 * タスクの更新
 */
function update() {
  const token = '';
  const taskId = '';
  const tanto = '';

  const objUpdateTask = {
    "data": {
      "notes": '更新するよ!',
      "assignee": { "gid": tanto, "resource_type": "user" }
    }
  };
  //オブジェクトを作成する
  const asanaManager = new AsanaManager(token);

  //処理を呼ぶ
  asanaManager.updateTask(taskId, objUpdateTask)
}

こんな感じでAsanaを操作できます。

1
3
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?