我使用以下 JSON RESTlet 脚本来导出一些数据。由于限制,它的上限为 1000 行,这远低于我需要导出的总数。我遇到过一些不同的解决方案,但 JSON/RESTlet 对我来说相当新,因此我正在寻找一些关于如何调整代码以循环所有结果的反馈。
function GetSearchResult(){
//array container for search results
var output = new Array();
//get search results
var results = nlapiSearchRecord('transaction','customsearchid',null,null);
var columns = results[0].getAllColumns();
//loop through the search results
for(var i in results){
//create placeholder object place holder
var obj = new searchRow(
//set the values of the object with the values of the appropriate columns
results[i].getValue(columns[0]),
results[i].getValue(columns[1]),
results[i].getValue(columns[2]),
results[i].getValue(columns[3]),
results[i].getValue(columns[4]),
results[i].getValue(columns[5]),
results[i].getValue(columns[6]),
results[i].getValue(columns[7]),
results[i].getValue(columns[8]),
results[i].getValue(columns[9]),
results[i].getValue(columns[10]),
results[i].getValue(columns[11]),
results[i].getValue(columns[12])
);
//add the object …Run Code Online (Sandbox Code Playgroud) 我有一个家庭作业,我完成了最低限度的任务,但在开展工作时,我开始对如何使我的课程变得更好感兴趣.代码的要点是绘制用户定义的形状,并在输入无效输入时提供反馈.我想继续这样做,如果用户输入高度/宽度的str或其中一个坐标给出错误,但我无法确切知道如何做到这一点.这是一个介绍类,所以如果你记住我们只是进入while循环,我们已经过了循环,if/else/etc.
这是我目前的代码:
def draw_user_shape(pen):
shape = input("Please enter a shape: ")
while shape != "square" and shape != "rectangle" and shape != "triangle":
shape = input("Invalid shape, please enter either square, rectangle, or triangle: ")
if shape == "square":
h = input("Please enter a height: ")
while h != int or int(h) < 1:
h = input("That is an invalid height, please enter an positive integer: ")
h = int(h)
c = input("Please enter a color: ")
while c != …Run Code Online (Sandbox Code Playgroud) 我尝试通过 RESTlet API 调用已保存的搜索,并且已部署 RESTlet,但在尝试运行它时,出现以下错误:
错误代码:INVALID_RETURN_DATA_FORMAT
错误消息:数据格式无效。您应该返回 TEXT。
查看我的脚本,我无法确定错误在哪里。下面是我尝试运行的脚本
function GetSearchResult(){
//array container for search results
var output = new Array();
//get search results
var results = nlapiSearchRecord('transaction','customsearchid',null,null);
var columns = results[0].getAllColumns();
//loop through the search results
for(var i in results){
//create placeholder object place holder
var obj = new searchRow(
//set the values of the object with the values of the appropriate columns
results[i].getValue(columns[0]),
results[i].getValue(columns[1]),
results[i].getValue(columns[2]),
results[i].getValue(columns[3]),
results[i].getValue(columns[4]),
results[i].getValue(columns[5]),
results[i].getValue(columns[6]),
results[i].getValue(columns[7]),
results[i].getValue(columns[8]),
results[i].getValue(columns[9]),
results[i].getValue(columns[10]),
results[i].getValue(columns[11]),
results[i].getValue(columns[12])
);
//add the …Run Code Online (Sandbox Code Playgroud)