我想使用保存的搜索检索直接发货/特殊订单采购记录详细信息以及相关的销售订单详细信息。
已保存的搜索必须显示以下列: 1.销售订单日期 2.销售订单编号(文档编号) 3.采购订单日期 4.采购订单编号(文档编号) 5.销售订单项目(装配项目) 6.销售订单数量 7.销售订单项目率 8.销售订单金额 7.采购订单项目(组件/成员项目)。
我创建了一个已保存的搜索并显示以下值:1.SO 日期、SO #、PO 日期、PO #、PO 项目(成员项目)、PO 数量。
我的问题:
当尝试显示 SO 项目、SO 数量、SO 项目率时,它会在采购订单本身中显示项目。即在采购订单中显示相同的项目(成员项目)而不是销售订单项目(装配项目)。
对于获取 SO 项目行值,我使用了条件“应用于交易字段”,它在采购订单中显示相同的项目名称。
而且我也尝试过“从字段创建”条件,它显示空值
我的代码:
保存的搜索:SuiteScript 2.0 版本
var purchaseorderSearchObj = search.create({
type: "purchaseorder",
filters: [
["type", "anyof", "PurchOrd"],
"AND", ["appliedtotransaction.type", "anyof", "SalesOrd"]
],
columns: [
search.createColumn({
name: "trandate",
sort: search.Sort.DESC,
label: "PO Date"
}),
search.createColumn({
name: "datecreated",
join: "appliedToTransaction",
label: "SO Date"
}),
search.createColumn({
name: "tranid",
label: "PO #"
}),
search.createColumn({
name: "tranid",
join: "appliedToTransaction",
label: "SO #"
}),
search.createColumn({
name: "item",
join: "appliedToTransaction",
label: "SO Item"
}),
search.createColumn({
name: "quantity",
join: "appliedToTransaction",
label: "SO Qty"
}),
search.createColumn({
name: "porate",
join: "appliedToTransaction",
label: "SO Item Rate"
}),
search.createColumn({
name: "formulacurrency",
formula: "{appliedtotransaction.quantity} * {appliedtotransaction.porate}",
label: "SO Amount"
}),
search.createColumn({
name: "item",
label: "PO Item"
}),
search.createColumn({
name: "quantity",
label: "PO Qty"
}),
search.createColumn({
name: "rate",
label: "PO Item Rate"
}),
search.createColumn({
name: "formulacurrency",
formula: "{rate} * {quantity}",
label: "Amount"
}),
]
});
var searchResultCount = purchaseorderSearchObj.runPaged().count;
log.debug("searchResultCount:", searchResultCount);
//Retrieving values from the search result
purchaseorderSearchObj.run().each(function(result) {
var soDateValue = result.getValue({ //Sales Order:Date
name: "datecreated",
join: "appliedToTransaction"
});
var poDateValue = result.getValue({ //Purchse Order: Date
name: "trandate"
});
var soNumberValue = result.getValue({ //Sales Order: Document Number
name: "tranid",
join: "appliedToTransaction"
});
var poNumberValue = result.getValue({ //Purchse Order: Document Number
name: "tranid",
});
var itemValue = result.getText({ // Purchse Order: Item
name: "item",
});
var qtyValue = result.getValue({ // Purchse Order: Quantity
name: "quantity",
});
var soItem = result.getText({ //Sales Order: Item
name: "item",
join: "appliedToTransaction"
});
var soQty = result.getValue({ //Sales Order:Quantity
name: "quantity",
join: "appliedToTransaction"
});
var soRate = result.getValue({ //Sales Order: Rate
name: "porate",
join: "appliedToTransaction"
});
var soAmount = result.getValue({ //Sales Order:
name: "formulacurrency",
formula: "{appliedtotransaction.quantity} * {appliedtotransaction.porate}"
});
return true;
});
是否有任何其他方法可以从采购订单中检索销售订单项目行值(装配项目)。
提前致谢。