This topic contains 3 replies, has 0 voices, and was last updated by CFong 6 years, 7 months ago.

  • Author
    Posts
  • #17925

    CFong

    I’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.

  • #17926

    dc92974

    Didn’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)”

  • #17927

    dc92974

    Now 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!

  • #17928

    CFong

    Beginnings 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.

You must be logged in to reply to this topic.