This topic contains 3 replies, has 0 voices, and was last updated by CFong 6 years, 7 months ago.
-
AuthorPosts
-
April 13, 2018 at 2:41 pm #17925
CFongI’m new to scripting, of any sort.
I have been using the Effective SuiteScript series by erictgrubaugh as my guide. But now I’m a bit stuck and based on the code he wrote what I have should work(?). I’ve run it though the debugger but it doesn’t flag any errors. I’m sure I’ve missed something obvious.
Code:
/**
*
* A test of the search scripting and ui using scripted search and output
*
* @exports test-email-list-generator
*
* @copyright 2018
* @author Caleb <@>
*
* @NApiVersion 2.x
* @NScriptType Suitelet
* @NModuleScope SameAccount
*
*/
define([“N/search”, “N/log”], function(search, log) {
/**
* Definition of the Suitelet script trigger point.
*
* @param {Object} context
* @param {ServerRequest} context.request – Encapsulation of the incoming request
* @param {ServerResponse} context.response – Encapsulation of the Suitelet response
* @Since 2015.2
*
*/
function onRequest(context) {
log.audit({ title: “Request Recieved.” });
context.response.write({
output:
“List of orders that good options for review request. Total count = ” + find_Fulfillments.length
});
}
According to the execution log the script gets this far, but the code below doesn’t seem to run@>Code:
function find_Fulfillments() {
log.audit({ title: “Looking up Fulfillment Records” });
return search.create({
type: search.type.ITEM_FULFILLMENT,
filters: [
// [“mainline”, search.Operator.IS, “T”],
// “AND”,
// [“type”, search.Operator.ANYOF, “ItemShip”],
// “AND”,
[“trandate”, search.Operator.WITHIN, “yesterday”] //today is an option
],
columns: [
“trandate”,
“tranid”,
“entity”
]
}).run().getRange({start: 0, end: 1000});
}
return {
onRequest: onRequest,
};
});
This is a cached copy. Click here to see the original post. -
April 13, 2018 at 5:01 pm #17926
dc92974Didn’t test it, but maybe when you call the function do you need to add the parenthesis?
So instead of this…
Originally posted by CFong
View Post
“List of orders that good options for review request. Total count = ” + find_Fulfillments.length
Try this?
Originally posted by CFong
View Post
“List of orders that good options for review request. Total count = ” + find_Fulfillments().length
CFong replied on 04/13/2018, 05:05 PM: Just tried it.
It threw the following error:
“org.mozilla.javascript.EcmaError: TypeError: Cannot read property “ITEM_FULFILLMENT” from undefined (/SuiteScripts/***email_list_generator.js#38)”
-
April 13, 2018 at 5:17 pm #17927
dc92974Now you’re getting somewhere, at least you’re in the method now. “type” should be capitalized (search.Type.ITEM_FULFILLMENT)
CFong replied on 04/13/2018, 05:34 PM: Hot damn! I think it’s finally making progress!
-
April 13, 2018 at 5:38 pm #17928
CFongBeginnings of success! I still need to work on the rendering of the results, BUT the search is running and a response is being shown!
Thanks dc92974 for your help!
When I get the whole thing running I’ll post the results.
-
AuthorPosts
You must be logged in to reply to this topic.