スプレッドシートのメニューバーに新しいメニューを追加する
//トリガーをメニューに追加 function onOpen() { var ui = SpreadsheetApp.getUi() //メニュー名を決定 var menu = ui.createMenu("勤務データコピー"); //メニューに実行ボタン名と関数を割り当て: その1 menu.addItem("勤務データコピー","sampleCodeForOpenSheetById"); //スプレッドシートに反映 menu.addToUi(); }
GASでスプレッドシートの指定のセルのデータを取得する
指定のセルの値を取得した後、重複した要素のみを取り出して配列にセット。
取得した際は2次元配列になっていたため、1次元配列に戻さないと、filterがうまく動作しませんでした。
function GetMyData(){ //シートIDを指定して取得 const sheet = SpreadsheetApp.openById("1i4eAiIjKR3FuKFTiosDMC1LhRxX-hJ3G2Fi9QFR4fa4"); //セルを指定して取得 var array = sheet.getRange("C3:C343").getValues(); //1次元配列で取り出す const list = array.reduce((pre,current) => {pre.push(...current);return pre},[]); //重複要素だけ取り出す let result = list.filter(function(x, i, self) { return self.indexOf(x) == i; }); console.log(result); }
PUTによるデータ登録
Kintone データ登録 (PUT)
/* if(now_yearsold !== record['yearsold'].value) { //年齢データ登録 var body = { 'app': kintone.app.getId(), 'id': kintone.app.record.getId(), 'record': { 'yearsold': { 'value': record['yearsold'].value } } }; kintone.api(kintone.api.url('/k/v1/record.json', true), 'PUT', body, function(resp) { // success console.log(resp); }, function(error) { // error console.log(error); }); }*/
Welcartの必須を設定する&必須のアスタリスクをつける
/** * マンション名・部屋番号入力チェック */ function ag_usces_filter_customer_check($mes) { $address3 = $_POST["customer"]["address3"]; if(WCUtils::is_blank($address3)) { $mes .= "部屋番号を入力してください。<br />"; } return $mes; } add_filter('usces_filter_customer_check', 'ag_usces_filter_customer_check', 10); /*別の配送先を指定された場合*/ function ag_usces_filter_customer_check2($mes) { if ( isset($_POST['delivery']['delivery_flag']) && $_POST['delivery']['delivery_flag'] == 1 ) { if ( WCUtils::is_blank($_POST["delivery"]["address3"]) ){ $mes .= "部屋番号を入力してください。<br />"; } return $mes; } } add_filter('usces_filter_delivery_check', 'ag_usces_filter_customer_check2', 10); add_action('usces_action_essential_mark','my_action_essential_mark',10,2); function my_action_essential_mark($data,$field) { global $usces_essential_mark; $essential = array('address3'); if(in_array($field,$essential)){ $usces_essential_mark[$field] = '<em>*</em>'; } }
■
Kintoneの日付のフォーマットを変更する方法
moment.js
をONにしましょう。
曜日の変換はこちら
テーマにショートコードを使う時の呪文
<?php echo do_shortcode('[ショートコード]'); ?>
忘れすぎ。