Last active
January 12, 2024 06:12
-
-
Save cpuwolf/551cf8e589785c8e3e11f4a21c6af4c5 to your computer and use it in GitHub Desktop.
金山文档数据表查询脚本AirScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Get a date object for the current time | |
var d = new Date(); | |
// Set it to one month ago | |
d.setMonth(d.getMonth() - 1); | |
d.setDate(1) | |
// Zero the time component | |
d.setHours(0, 0, 0, 0); | |
// Get the time value in milliseconds and convert to seconds | |
datestr = d.toLocaleDateString("zh-CN") | |
console.log(datestr); | |
// 获取当前工作表 | |
const currentSheet = ActiveSheet | |
console.log(Application.ActiveSheet.Name) | |
Application.Sheets.Item('国外订单自动化').Activate() | |
const sheet = Application.ActiveSheet | |
function fetchAllRecords() { | |
const view = sheet.Selection.GetActiveView() | |
let all = [] | |
let offset = null; | |
while (all.length === 0 || offset) { | |
let records = sheet.Record.GetRecords({ | |
ViewId: view.viewId, | |
Offset: offset, | |
MaxRecords: 1, | |
Fields: ["编号","状态", "日期"], | |
Filter: {"mode": "AND", "criteria": [{ | |
"field": "状态", | |
"op": "Equals", | |
"values": ["待付款"] | |
},{ | |
"field": "日期", | |
"op": "Less", | |
"values": [datestr] | |
},]} | |
}) | |
offset = records.offset | |
all = all.concat(records.records) | |
} | |
console.log(all.length) | |
return all | |
} | |
const recs = fetchAllRecords() | |
console.log(recs) | |
for(var i=0; i< recs.length; i++) { | |
const upded = sheet.Record.UpdateRecords({ | |
Records: [{ | |
id: recs[i].id, | |
fields: { | |
"状态": "已取消", | |
} | |
}], | |
}) | |
console.log(upded); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment