This topic contains 4 replies, has 0 voices, and was last updated by pcutler 6 years, 4 months ago.

  • Author
    Posts
  • #21247 Score: 0

    rvasquez
    • Contributions: 0
    • Level 1

    The Suitescript documentation says you cannot execute one user event script from another.

    We are creating a sales order during a before submit function. Normally, when a sales order is saved, it calls a before submit function, (let's call it CalculateSalesTax), which calculates sales tax using our sales tax software that's integrated with NetSuite. But when we create a sales order, this second function call never happens. Because you can't call one from the other!

    What workarounds have others tried? Queue up a list of records we want to calculate and schedule a task to process them is the first thing I was thinking of.
    This is a cached copy. Click here to see the original post.

  • #21248 Score: 0

    MChammaTX
    • Contributions: 0
    • Level 1

    Scheduled scripts is a good option but keep in mind your queue/processor usage. If you have too much going through there you will block yourself unless you buy additional bandwidth via a SuiteCloud plus license.

    An alternative would be to call a suitelet, which is an approach I did in the past for the above reason.

    If you are going to go with either of these methods I would suggest moving your code to aftersubmit.

  • #21249 Score: 0

    pcutler
    • Contributions: 0
    • Level 1

    Basically anything except for creating the sales order directly inside the user event script can work. In addition to MChammaTX 's suggestions, some more exotic ideas are:

    1. Call a RESTlet and create the sales order in the RESTlet

    2. Schedule a CSV import with the sales order data

    3. Invoke NetSuite's SOAP WSDL to create the sales order

    4. Send an email and use an email capture plug-in to create the sales order

    5. Create a phone call record that via VOIP integration, dials into AOL, logs into NetSuite, and creates the sales order

    But, jokes aside :-), I'd probably reconsider whether the before load user event script is the best place to be creating the sales order.

    Also, specific to calculating tax, consider upgrading to SuiteTax (beta), which is triggered from within user event scripts.

  • #21250 Score: 0

    rvasquez
    • Contributions: 0
    • Level 1

    Slightly better description of the process:

    We have a custom record (let's call it 'service order') that is created from an outside source and imported into NetSuite. Then we have someone check/update the record in NetSuite, and then they set the status to 'ready to invoice'.

    At that point, when the custom record is saved, a sales order is created. The problem is that tax doesn't calculate since we are creating the sales order with a nlapiCreateRecord/SubmitRecord

    I thought about a mass update or something but we'd still be using a script to save the sales order, so the sales tax wouldn't be calculated. I might have to see if the vendor has any ideas.

  • #21251 Score: 0

    pcutler
    • Contributions: 0
    • Level 1

    Originally posted by rvasquez

    View Post

    Slightly better description of the process:

    We have a custom record (let's call it 'service order') that is created from an outside source and imported into NetSuite. Then we have someone check/update the record in NetSuite, and then they set the status to 'ready to invoice'.

    At that point, when the custom record is saved, a sales order is created. The problem is that tax doesn't calculate since we are creating the sales order with a nlapiCreateRecord/SubmitRecord

    I thought about a mass update or something but we'd still be using a script to save the sales order, so the sales tax wouldn't be calculated. I might have to see if the vendor has any ideas.

    Instead of a user event script, I'd write a scheduled script or map/reduce script that searches for "service order" records with the status of "ready to invoice." The scheduled or map/reduce script can then create the sales order, and in this scenario user event scripts would be triggered tax would be calculated.

You must be logged in to reply to this topic.