Add field Netsuite amortization schedule - netsuite

I would like to add a few fields to the amortization schedule record in Netsuite. However my user event script does not run. I used netsuite's debugger and when I view the record it doesn't even seem to recognize that there is a user event script. The script below works perfectly on other record types like a customer record but I can not get it to work on the amortization schedule record.
function addFieldsBeforeLoad(type, form, request){
form.addField('custpage_test', 'text', 'test');
}

This is clearly mentioned in NetSuite help that -
This record is scriptable in server SuiteScript only.
The user events are not supported.
Hope this will help.

Related

How to get a sales order ID and set it in a Custom Record in netsuite?

I am very new to netsuite. I want to redirect a user from sales order to a custom record I created on button click, I want to get sales order ID and set it in the custom form where the user is being redirected by clicking a button the way fulfillment works in netsuite. I am using client script to redirect user when the button is clicked. Is there a way to pass the sale order id to the next form/Record?
Like this
https://i.stack.imgur.com/QghDv.png
I tried to use the saved search feature but I couldn't fully understand it. If indeed it can be done through saved search, it would be a great help if someone could guide me.
In your Client Script you can use the N/currentRecord module to retrieve the ID of the record in context. It will allow you to retrieve a reference to the CurrentRecord object, which will have an id property.
See the Help page for N/currentRecord for details.

Getting data from netsuite using suite script

Can someone explain me how to fetch the record from netsuite (eg. if we click on the save button of inventory form, it should capture the record and display) using suite script.
thanks in advance.
You have to write a USER EVENT Script and deploy that script in the record (ex: customer record)
In the afterSubmit function of the script you can use scriptContext to get and display the value.
function afterSubmit(scriptContext) {
log.debug('scriptContext',scriptContext.newRecord); //You can see the record info on debug logs
}
If you want to get the data for some validation purposes you can use beforeSubmit function.

Netsuite timetrack Duration field into a Workflow

I would like to trigger an email when a new Time entry is created in Netsuite. Usually this can be easily accomplished through a Saved Search/Email but for Time searches, sending on Create is not available and already the topic of an enhancement request.
I've created a Workflow which will trigger upon Time entry create. In order to use the time entry fields I first created Workflow Fields and then in State 1 populate those workflow fields with the values. Suiteanswers: Use SQL expressions in Send Email action via the Workflow Manager (ID: 21669)
I can map many of the fields like Customer:Project, Service Item from the Time entry into my Workflow. I am stuck on mapping the Netsuite Duration field which according to the Records Browser is of a type "timetrack" ie 1:05.
I have tried it from the available field types, Date, Date/Time, Integer. I'm now trying to populate is into a Text field but am stuck as to how to convert it from the timetrack record type into Text.
Have tried
TO_CHAR({hours})
CAST({hours} AS text)
I just want a field with the Duration that I can use in an email. :)
How could I achieve this affect? Any thoughts appreciated.
Turns out that somewhere along the track I over-complicated what was needed. In the end I just inserted {hours} into my email text box and it worked. I can't explain why it didn't work initially.

How can I trigger a NetSuite workflow on a Form Event (Client side event)

I want to trigger a NetSuite workflow when the user sets the value of a field, but I don't want to have them submit first. The Workflow state builder looks like it has useful options but I can't get it to work.
There's some useful looking blog posts around but a lot of them seem out of date.
Update - more info
My primary issue is this one: Restrict what customers an employee can see (NetSuite)
The hack I'm currently looking at is populating a custom Transaction Column Field that I've added to a custom Time Recording form. The idea is to load this field on the UI with only valid projects (not customers as well), and this I have been able to do.
The problem is I still (as far as I can tell) still need to populate the "Customer" field, which is mandatory; I'm also assuming that if I don't do that then any time that is recorded won't go against the project. I had thought that if the user selects the project they want then I can populate the customer field with that value. I hate this as an approach but I can't see how else to do it. I do have coding experience (including JavaScript) but haven't made the leap into SuiteScript yet.
You won't be able to do this in a Workflow, as they are currently limited to only work with body level fields and cannot modify Transaction Column Fields (aka sublists).
You should be able to achieve this with a Client Side Script though.
Source (Netsuite login required).
Sublist changes will be available for transactions in the 2018.1 release sometime in Feb/Mar.

How to modify a Customer Refund in an After Submit User Event

After a new Customer Refund record is saved (After Submit user event) I need to communicate with an external web service and then update 2 fields in the record. When this code is executed to load the Customer Refund
var o = nlapiLoadRecord("customerrefund", 1906);
This error message is returned:
INVALID_TRANS_TYP
Transaction type specified is incorrect.
I found a list of supported records in the "Chapter 60 SuiteScript Supported Records" of SuiteScript Developer & Reference Guide which says the Customer Refund is only available in a server side script.
How should I go about updating the Customer Refund record?
Without seeing more code, it looks ok. I would double check that the internalId of 1906 is correct.
Also, if you're just submitting two fields, I would use nlapiSubmitField(), this will take less governance points and be quicker for NetSuite rather than nlapiLoadRecord / nlapiSubmitRecord.
Your code looks correct, if you are updating the current record I would recommend using below code to avoid incorrect internalid:
var o = nlapiLoadRecord("customerrefund", nlapiGetRecordId());
Also, I would recommend that if you need to update the fields, consider using before submit user event script on customer refund and you can update the fields using nlapiSetFieldValue(FIELD_ID, FIELD_VALUE). No need to submit the record in case of before submit.
If your script is deployed in the customer refund record, you can also do nlapiGetRecordType().

Resources