Google スライド: ページ, 複製
Google スライド: ページ, 複製 (Google Slides: Page, Duplicate)
指定のスライドページを複製し、次ページに挿入します。ページ指定がない場合は、最終ページを複製します。見出し画像制作業務や集計レポート作成業務など、雛形ページの複製から始めたい業務プロセスで利用します。
Configs
  • U: HTTP認証設定を選択してください *
  • A: Drive内でのファイルID(FILE-ID)をセットしてください *#{EL}
  • B1: スライドページの Object-ID をセットしてください (id.以降の文字列)#{EL}
  • B2: 必要あれば、複製されたスライドページの Object-ID が格納される文字列型データを選択してください (更新)
Script (click to open)
// GraalJS Script (engine type: 2)

//////// START "main()" /////////////////////////////////////////////////////////////////

main();
function main(){ 

//// == Config Retrieving / 工程コンフィグの参照 ==
const strAuthzSetting     = configs.get      ( "AuthzConfU" );   /// REQUIRED
  engine.log( " AutomatedTask Config: Authz Setting: " + strAuthzSetting );
const strInputfileId      = configs.get      ( "StrConfA1" );    /// REQUIRED
  if( strInputfileId    === "" ){
    throw new Error( "\n AutomatedTask ConfigError:" +
                     " Config {A1: FileID} is empty \n" );
  }
let   strPageidOriginal   = configs.get      ( "StrConfB1" );    // NotRequired
const strPocketPageidNew  = configs.getObject( "SelectConfB2" ); // NotRequired


//// == Data Retrieving / ワークフローデータの参照 ==
// (Nothing. Retrieved via Expression Language in Config Retrieving)


//// == Calculating / 演算 ==

/// Get LastPage ID
/// Google Slides API
/// https://developers.google.com/slides/reference/rest/v1/presentations/get

if( strPageidOriginal === "" ){
  // request0, prepare
  let request0Uri = "https://slides.googleapis.com/v1/presentations/" + strInputfileId;
  let request0    = httpClient.begin(); // HttpRequestWrapper
      request0    = request0.authSetting( strAuthzSetting ); // with "Authorization: Bearer XX"
      // https://questetra.zendesk.com/hc/en-us/articles/360024574471-R2300#HttpRequestWrapper
  // request0, try
  const response0 = request0.get( request0Uri ); // HttpResponseWrapper
  engine.log( " AutomatedTask ApiRequest0 Start: " + request0Uri );
  const response0Code = response0.getStatusCode() + "";
  const response0Body = response0.getResponseAsString() + "";
  engine.log( " AutomatedTask ApiResponse Status: " + response0Code );
  if( response0Code !== "200"){
    throw new Error( "\n AutomatedTask UnexpectedResponseError: " +
                      response0Code + "\n" + response0Body + "\n" );
  }
  // response0, parse
  const response0Obj = JSON.parse( response0Body );
  strPageidOriginal = response0Obj.slides[ response0Obj.slides.length - 1 ].objectId;
}

/// Duplicate the Page (via batchUpdate Request)
/// Google Slides API
/// https://developers.google.com/slides/reference/rest/v1/presentations/request#duplicateobjectrequest

// request1, prepare
let request1Uri = "https://slides.googleapis.com/v1/presentations/" +
                  strInputfileId + ":batchUpdate";
let request1Obj = {};
    request1Obj.requests = [];
    request1Obj.requests[0] = {};
    request1Obj.requests[0].duplicateObject = {};
    request1Obj.requests[0].duplicateObject.objectId = strPageidOriginal;
let request1    = httpClient.begin(); // HttpRequestWrapper
    request1    = request1.authSetting( strAuthzSetting ); // with "Authorization: Bearer XX"
    // https://questetra.zendesk.com/hc/en-us/articles/360024574471-R2300#HttpRequestWrapper
    request1    = request1.body( JSON.stringify( request1Obj ), "application/json" );
// request1, try
const response1     = request1.post( request1Uri ); // HttpResponseWrapper
engine.log( " AutomatedTask ApiRequest1 Start: " + request1Uri );
const response1Code = response1.getStatusCode() + "";
const response1Body = response1.getResponseAsString() + "";
engine.log( " AutomatedTask ApiResponse Status: " + response1Code );
if( response1Code !== "200"){
  throw new Error( "\n AutomatedTask UnexpectedResponseError: " +
                    response1Code + "\n" + response1Body + "\n" );
}
// response1, parse
/* 
engine.log( response1Body ); // debug
{
  "presentationId": "1oDCufkoKg3LQeaqBVs5VA0xX3k2d5GxhH8tvmcIXeV4",
  "replies": [
    {
      "duplicateObject": {
        "objectId": "SLIDES_API1432471875_0"
      }
    }
  ],
  "writeControl": {
    "requiredRevisionId": "ssjMIIo3IRFIFg"
  }
}
*/
const response1Obj = JSON.parse( response1Body );
const strPageidNew = response1Obj.replies[0].duplicateObject.objectId;


//// == Data Updating / ワークフローデータへの代入 ==
engine.setData( strPocketPageidNew,    strPageidNew );


} //////// END "main()" /////////////////////////////////////////////////////////////////


/*
Notes:
- You can build a system to automatically duplicate template page or last page. GoogleSlidesDuplicate
- For example, if you want to automate the notification of "Monthly Sales Report", define as follows:
    - The template page is automatically duplicated (Google Slides: Page, Duplicate)
    - The report text part is automatically replaced (Google Slides: Page, Replace Strings)
    - The embedded graph is automatically updated (Google Slides: Page, Refresh Charts)
    - The slide page is automatically converted to a PNG image (Google Slides: Page, Generate PNG)
    - The email with the PNG image attached will be sent automatically. (ThrowEmail Event)
Notes-ja:
- Googleスライド内の雛形ページや末尾ページが自動複製される仕組みを構築できます。GoogleSlidesDuplicate
- たとえば「月次売上レポート」の通知業務を自動化したい場合は、以下のような業務プロセスを定義します。
    - 雛形ページが自動複製され、(※Google スライド: ページ, 複製)
    - 貼り付けられている埋め込みグラフが自動更新され、(※Google スライド: ページ, 文字列全置換)
    - 報告テキスト部が当月文に自動置換され、(※Google スライド: ページ, 全グラフ更新)
    - 当該スライドページがPNG画像に自動変換され、(※Google スライド: ページ, PNG画像生成)
    - PNG画像が添付されたメールが自動的に送信される。(※ ThrowEmail イベント)

APPENDIX-en
- FILE-ID/PresentationID in Drive (Chars following "/d/")
    - docs.google.com/presentation/d/1p33hGJFUNYixBmMeaV81nsOVYGUUrZIFyErinFp3CI8
- Object-ID of Slide Page (Chars following "id.")
    - docs.google.com/presentation/d/1p33hGJFUNYixBmMeaV81nsOVYGUUrZIFyErinFp3CI8/edit#slide=id.g613777c84a_0_0
- Setting example of "HTTP Authentication" (OAuth2)
    - Authorization Endpoint URL:
        - https://accounts.google.com/o/oauth2/auth?access_type=offline&approval_prompt=force
    - Token Endpoint URL:
        - https://accounts.google.com/o/oauth2/token
    - Scope:
        - https://www.googleapis.com/auth/presentations
    - Client ID, Consumer Secret:
        - ( from https://console.developers.google.com/ )
        - Redirect URLs: https://s.questetra.net/oauth2callback
APPENDIX-ja
- FILE-ID/PresentationID in Drive ("/d/" 以降の文字列)
    - docs.google.com/presentation/d/1p33hGJFUNYixBmMeaV81nsOVYGUUrZIFyErinFp3CI8
- Object-ID of Slide Page ("id." 以降の文字列)
    - docs.google.com/presentation/d/1p33hGJFUNYixBmMeaV81nsOVYGUUrZIFyErinFp3CI8/edit#slide=id.g613777c84a_0_0
- "HTTP認証"(OAuth2)の設定例
    - Authorization Endpoint URL:
        - https://accounts.google.com/o/oauth2/auth?access_type=offline&approval_prompt=force
    - Token Endpoint URL:
        - https://accounts.google.com/o/oauth2/token
    - Scope:
        - https://www.googleapis.com/auth/presentations
    - Client ID, Consumer Secret:
        - ( from https://console.developers.google.com/ )
        - Redirect URLs: https://s.questetra.net/oauth2callback
*/

Download

2021-05-15 (C) Questetra, Inc. (MIT License)
https://support.questetra.com/ja/addons/google-slides-page-duplicate-2021/
Addonファイルのインポートは Professional でのみご利用いただけます

Notes

  • Googleスライド内の雛形ページや末尾ページが自動複製される仕組みを構築できます。GoogleSlidesDuplicate
  • たとえば「月次売上レポート」の通知業務を自動化したい場合は、以下のような業務プロセスを定義します。
    • 雛形ページが自動複製され、(※Google スライド: ページ, 複製)
    • 貼り付けられている埋め込みグラフが自動更新され、(※Google スライド: ページ, 文字列全置換)
    • 報告テキスト部が当月文に自動置換され、(※Google スライド: ページ, 全グラフ更新)
    • 当該スライドページがPNG画像に自動変換され、(※Google スライド: ページ, PNG画像生成)
    • PNG画像が添付されたメールが自動的に送信される。(※ ThrowEmail イベント)

Capture

指定のスライドページを複製し、次ページに挿入します。ページ指定がない場合は、最終ページを複製します。見出し画像制作業務や集計レポート作成業務など、雛形ページの複製から始めたい業務プロセスで利用します。
指定のスライドページを複製し、次ページに挿入します。ページ指定がない場合は、最終ページを複製します。見出し画像制作業務や集計レポート作成業務など、雛形ページの複製から始めたい業務プロセスで利用します。

Appendix

See also

コメントを残す

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください

%d人のブロガーが「いいね」をつけました。