简体   繁体   中英

How to get data of modules in NetSuite using SuiteScript?

I am using NetSuite and there are some records/forms like employees, items etc. that I would like to access. I have read about using SuiteScript to get the data from NetSuite and for creating new modules in the NetSuite. I want to know how can I access existing data from records in NetSuite? For example I would like to get the list of all employees, items or other record types. I am not able to understand how to go about accessing this information. I've been provided some of the NetSuite API Records, Fields & Forms. Please help me as I'm a beginner in NetSuite.

Here is an example of using NetSuite web services in .NET where I load an Opportunity record. The process of loading Employees or other records would be the same. Once you get the basics working read the NetSuite Records Browser document in the NetSuite help.

// create objects for netsuite login
NetSuiteService netsuite = new NetSuiteService();
CookieContainer cookie = new CookieContainer();
Passport passport = new Passport();
RecordRef role = new RecordRef();

// hard code for administrator role 3
role.externalId = "3";

// latest NetSuite web services url
netsuite.Url = "https://webservices.sandbox.netsuite.com/services/NetSuitePort_2015_1";
netsuite.CookieContainer = new CookieContainer();
passport.account = "6669990";
passport.email = "john.doe@stackoverflow.com";
passport.password = "P@SSW0RD!";
passport.role = role;

System.Console.WriteLine("\nLogging into NetSuite ... ");
System.Console.WriteLine("\nUsername: " + passport.email);
System.Console.WriteLine("\nAccount: " + passport.account);

// try loggin into web services
Status status = netsuite.login(passport).status;

if (status.isSuccess)
{
    // read opportunity record id 2236873
    Opportunity oppty = NSFunc.getOpportunity(netsuite,"2236873");
    System.Console.WriteLine("\nNetSuite Login: " + status.isSuccess.ToString());
    netsuite.logout();
}
else
{
    System.Console.WriteLine("\nNetSuite Login: " + status.isSuccess.ToString());
}

Access data using NetSuite SuiteScript instead of web services than you can write SuiteScript (JavaScript) files, save them with (.js) file extension and upload them to the NetSuite File Cabinet.

Your JavaScript (aka SuiteScript) file will contain regular JavaScript and will use the API Functions that you talk about. There are example SuiteScripts in the NetSuite Online Help, here is one for customizing the page load of a record .

Once you upload to file cabinet you can create a NetSuite Script record and define how the script will be used, for example the file name, which function should be used, which event on a form should cause your JavaScript function to fire (eg Before Save, After Save). Last you deploy your script to "Testing" and you can test/debug it. There is a lot more to it but this should get you on the right track. The website NetSuiteGo has information about NetSuite SuiteScript it helped me get started.

Good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM