Suitescript 2.0 - Journal entry from Invoice - netsuite

I'm working on creating a journal entry from an invoice if the invoice is checkmarked on a field. This is a little more complicated than I'm used to, so I wanted to ask for a little guidance.
What I need to do is:
afterSubmit(){}:
Get invoice number and related sales order number (Done - easy)
Retrieve the lineCount (Done)
Loop through lines to getValue for item and amounts (Done - I know how to do this)
Create a journal entry (Able to initiate this)
Apply the values from the invoice line data for both credit and debit (Unsure)
The parts I'm not sure about:
Is getValue the best way to retrieve the line item data? Do I have an object at this point that I can iterate through? How do I look at this object with a logDebug() or the debugger? Or if there is another way to get the sublist, how do I see the sublist data?
Should I actually get the invoice values on beforeSubmit() and then create the JE with afterSubmit()? Can I use the values in an afterSubmit() function?
What is the method to pull out line data and apply with setSublistValue()?
If anyone can guide me on this last process, it would help.
Thanks.

Related

How to add a column to the Sub record inventory detail?

How to add a column to the Sub record inventory detail?
just like expiration date on inventory number subrecord on Item Receipt, can we have a custom field for manufacturing date in inventory number subrecord. Is there any feature need to be enabled? Does NetSuite have any functionality of Production/Manufacturing date? or any way to create a custom field in inventory number subrecord that is visible in IR subrecord?
In Netsuite go to
Customization -> Lists, Records, Fields -> Item Number Fields
If you have a production run you either have lot numbered or serialized inventory. You can make the field applicable to all Lot Numbered or all Serialized or to just specific skus.
Note that the items need to have been created as lot numbered or serialized items. If the items you want to use were not created as such then you’ll need to replace them with new items. If you want to use the same skus for the new items you’ll need to rename the original items.

System note data in one line on saved search

We have a three level approval for purchase orders. I have received a requirement to show who approved at each level and the timestamp against every PO in saved search,
When I started creating this search, I am struggling to get the data for every PO in one line, as the system note data has one line each for every approval.
Can you please advise on how to get these multiplelines on a single line for every PO?
Thanks,
Check out the undocumented NS_CONCAT function for saved searches.
Here's an example answered earlier:
How to list my Sales Reps for a customer on one line?

How do I update a list item after adding it with Power Automate

I can't figure out how to do a very simple update of a column value in Power Automate in SharePoint online. I've seen examples of how to update an item on another list, but nothing that updates a value on the same item that was just added and triggered the workflow. Can anybody give me an example and maybe a very brief explanation?
I want to multiply the values of two columns and add it to a third column on the same item which will be blank. I used the formula to update the column I want using values from other columns. =[Dollar Amount]*[% Chance] but it says invalid syntax. There seems to be nothing intuitive in this new power automation and it's a horrible failure compared to how easy it used to be. MS is always making these mistakes.
The first method, you could use a calculated column.
=[% Chance]*[Dollar Amount]
Second method,use Flow.
Test result:
It's Power Automate, not power automation. Details matter.
First, try to set the column value when you create the item. Then you won't have to edit it. If you already know the values for [Dollar amount] and [% Chance] (Chance, really? Or Change?), then you can use these to generate the value before you create the item. You can do that in a variable or with a Compose action. Then create the item and refer to the variable or the Output of the compose action.
If this is not an option, you can use the Edit Item action and get the ID for the item from the action above that you used to create the item.
You say "MS is always making these mistakes." - It's more likely that the problem is a mismatch of data types, e.g. using text fields in calculations, or typos, or wrong syntax. That's not a mistake made by MS. Again, details matter.
Edit after comments: If the workflow is triggered by an item getting created, then you can use an Edit Item action and refer to the ID from the trigger item.

How to loop through all line items of a sales order and get the earliest term start date

We are building out the ARM module of Netsuite and our director of Accounting would like the Contract Start date on the header level to be populated with the earliest Term Start date from the line items on the sales order.
I'm just starting this project and am new to Suite Script. I'm hoping to get pointed in the right direction and work f rom there.
To filter earliest date from lines, you first need to fetch all the dates which can be done using record.getSublistValue which requires a set of parameters which you can find here. Once you have filtered out the date, you can set it on body field using record.setValue and you can find its documentation here.
To get the record, it depends on which script-type you are working on, like if you are sripting in User-Event, you will receive newRecord in its script parameter. Whereas if you are working on some scheduled/map-reduce script, you might have to load the record using record.load from N/record module.
You can also do this in the UI without SuiteScript.
Create a saved search with results as Term Start Date with a summary of Minimum.
Add any criteria that you may need (such as Term Start Date is not empty)
Add a filter of Internal Id.
Create the custom field, and under Validation and Defaulting select the previously created saved search. Make sure that stored value is checked off for the custom field!
Look into the article "Creating Custom Fields with Values Derived from Summary Search Results" in the help center for more information!

Is it possible to compare 2 different sheets on Excel, update data then insert into a new table all the changes that were made?

Right now, I have a running list of all my data for the all my products. The list will show an ID that identifies the product and then show the status of that product and the date of that status. Every week I get more data on the same product_ID but I am wondering if there is a way to use VBA to update another table to show only one product ID and the most recent status for that? If possible I would then want to insert information into a third table (sheet) that keeps track of the changes made
I am new to using this program and would like to see if this is viable before trying to mess around with it. I hope I explained everything correctly.
Thanks!

Resources