Hi all, My transaction saved search shows total am...
# suitescript
k
Hi all, My transaction saved search shows total amount 140$ on a sales order. But when I did the same search inside a Suitescript, it shows the total except for tax total (135$). My Total Tax shows empty on Suitescript while it is not on saved search. Why is this happening?
Copy code
const salesorderSearchObj = search.create({
      type: search.Type.SALES_ORDER,
      filters: [
        ["type", "anyof", "SalesOrd"],
        "AND",
        ["internalid", "anyof", netsuiteId],
      ],
      columns: [
        search.createColumn({ name: "tranid", label: "Document Number" }),
        search.createColumn({
          name: "taxtotal",
          label: "Amount (Transaction Tax Total)",
        }),
        search.createColumn({
          name: "total",
          label: "Amount (Transaction Total)",
        }),
        search.createColumn({
          name: "shippingamount",
          label: "Amount (Shipping)",
        }),
        search.createColumn({
          name: "formulatext",
          formula: "NVL({discountamount}, 0)",
          label: "Amount Discount",
        }),
      ],
    });
m
Hi @Ken, I'm not sure why the amounts are different, but a tip I can give you is a very useful chrome extension called NetSuite :: Saved Search Export to SS 2.x
After creating the saved search in the UI, access the saved search in edit mode
The extension will embed a link in the right corner of the page
The output will be something like this
It helped me a lot when I started with SuiteScript, even nowadays when I'm not sure about the fields and joins
Hope this tip can help you
k
Thank you , i use the one similar but it seems to be the same thing?
m
Pretty much the same
k
Worked on console, but not on my user event script..??
m
Can you share your UE Script?
What are the output of the UE script, can you also send the result in a json format?
k
yes, i can show u one moment
I found the the reason. This is my function to search
Using netsuiteId gives the following
Hard coded with netsuiteId to “3480040” finally gives the taxtotal
m
Try to replace anyof for is in the where you are filtering netsuiteId
Is it possible?
k
let me try
still empty
m
Ok, but the sales order id is different then the others
k
let me show u when i hard code it with id “3479941”
message has been deleted
m
By the name of you function, you want to get values only from the main line, line items are not important for you, right? Try adding to the filter mainline is true
But It is strange, why when you hard code the id the result is different
k
ok
Would that work for discount as well?
I need to grab total discount
m
The discount is applyed in line items?
k
we have a discount item that is a line item
and we also use cart discount
m
If you set mainline equals to true you wont reach line items
k
ok let me try
I did more troubleshooting, and I saw that my totaltax inside context aftersubmit was empty
Maybe I need to add a delay into after submit??
m
I'm not sure
I would have to understand the hole thing you want to do
This process has to be on time or you can schedule a map reduce perform the things needed?
If you can process it later, you can create a checkbox in the sales order just to say it was processed or not and then you create a map reduce that runs each 5 minutes processing the unprocessed sales orders
Does it make sense for you?
k
The process has to be on time.