應用範例-豐盛牧區(簽到統計)

簽到統計

Table簽到表裡,將簽到日期用Automation自動link到「每週統計-日期」這一欄,link去每週人數做統計。

這個Automation是這樣做的

當一個紀錄進來到「簽到」Table裡,就會執行一段程式碼Script
let tData = base.getTable("簽到");//取得簽到Table
let tOverview = base.getTable("每週人數");//取得每週人數Table

let config = input.config();
let recordId = config.recordId;
let weekNo = config.weekNo;//取得weekNo 我這邊是簽到表裡面的「簽到日期」

//get stream data new record
let queryResult = await tData.selectRecordsAsync();
let record = queryResult.getRecord(recordId); //用recordID取得「簽到」表裡這一筆資料ID

//get overview last record id
let overviewQuery = await tOverview.selectRecordsAsync();//取得「每週人數」裡面的紀錄

let overviewMatchRecord = overviewQuery.records.filter((r,index)=>{
    return r.getCellValue("日期") == weekNo //尋找「每週人數」裡面「日期」等於==「簽到」表裡面的「簽到日期」weekNo的紀錄
})[0];

//update WeekNum to overview record id if exist 找到的話,將「簽到」裡面「每週統計-日期」這個欄位設定值為對應的日期
if(overviewMatchRecord){
    console.log("matched and update");
    await tData.updateRecordAsync(record,{
        每週統計-日期: [{id:overviewMatchRecord.id}] 
    });
}else{
    console.log("unmatched and create");
    //create new and update record
    let newId = await tOverview.createRecordAsync({"日期": weekNo});
    await tData.updateRecordAsync(record,{
        每週統計-日期: [{id: newId}] //如果這個日期不存在於「每週人數」的日期中,就會自動創建一筆這個日期的紀錄
    });
}
「每週人數」這邊會自動統計「簽到」表裡面當週簽到的人數。出席人數你們可以當場算完再輸入
欄位用Count的型態,去計算link field 當天簽到的人有幾個
右上角有個[Apps]裡面有簽到統計圖,可以看到「每週各組簽到的人數統計」也可以再點進去查看每一組是哪些人有簽到
如果習慣用excel的方式看,也可以整成這樣。

這是用條件是count的欄位來做的

設定只有每個簽到日期的簽到紀錄要計算

文章已創建 20

發佈回覆

你的電郵地址並不會被公開。 必要欄位標記為 *

相關文章

開始在上面輸入您的搜索詞,然後按回車進行搜索。按ESC取消。

返回頂部