Getting All Fields From NetSuite Entities

As I have mentioned in my earlier post, NetSuite Debugger is a great tool to find the undocumented details about the entities . Another way to find the list of fields related to an entity is through these functions.

getAllFields()

Returns a normal keyed array of all the fields on a record. Note that the number of fields returned will differ when you call getAllFields() on the edit of a record vs. on the xedit of a record.

getAllLineItemFields(group)

Returns an array of all the field names of a sublist on this record.

Google App Engine (Python) for PHP Developers

Recently I developed a python web app deployed on Google App Engine. Its an app to facilitate the Peer Review Process for organizations. You can view the app at http://peer-review-process.appspot.com/ .

Below are my comments about the GAE platform as a PHP developer.

  • Basically its much easier to adopt for PHP developers. All the code level and application level flexibility I enjoy in PHP is also available in Python.
  • User Management becomes secure without any extra effort.
  • GAE provides a very good templating engine which is very familiar for PHP developers.
  • Lesser hassle for database related work. No DAO layer is required as data is always retrieved as native objects. Although the GQL Query is less flexible but the methods available are very intuitive to learn.
  • Unlike PHP, Python has Cross-Request variables preventing certain limitations in app development process (Be careful when adding static variables to classes. These variables are shared across multiple requests)

Folio3 Announces Android Mobile SuiteApp For NetSuite’s SuiteCloud Computing Platform

NetSuite Transaction Status Codes

When working with NetSuite, transaction Statuses are one of the most tricky parts.

Lets take an example. Below is the search filter to apply when trying to find Pending Fulfillment Sales Orders.

new nlobjSearchFilter(‘status’,null,’is’,'SalesOrd:B’)

and to set the status of a sales order as pending approval

nlapiSubmitField(‘salesorder’,soID,’orderstatus’,'A’,false);

I was unable to find these codes in the documentation so extracted it from NetSuite HTML ( Each line shows Intended Status along with its code separated by comma)

‘Bill:Open’, ‘VendBill:A’
‘Bill:Paid In Full’, ‘VendBill:B’
‘Bill Payment:Voided’, ‘VendPymt:V’
‘Bill Payment:Online Bill Pay Pending Accounting Approval’, ‘VendPymt:Z’
‘Cash Sale:Unapproved Payment’, ‘CashSale:A’
‘Cash Sale:Not Deposited’, ‘CashSale:B’
‘Cash Sale:Deposited’, ‘CashSale:C’
‘Check:Voided’, ‘Check:V’
‘Check:Online Bill Pay Pending Accounting Approval’, ‘Check:Z’
‘Commission:Pending Payment’, ‘Commissn:A’
‘Commission:Overpaid’, ‘Commissn:O’
‘Commission:Pending Accounting Approval’, ‘Commissn:P’
‘Commission:Rejected by Accounting’, ‘Commissn:R’
‘Commission:Paid in Full’, ‘Commissn:X’
‘Credit Memo:Open’, ‘CustCred:A’
‘Credit Memo:Fully Applied’, ‘CustCred:B’
‘Customer Deposit:Not Deposited’, ‘CustDep:A’
‘Customer Deposit:Deposited’, ‘CustDep:B’
‘Customer Deposit:Fully Applied’, ‘CustDep:C’
‘Customer Refund:Voided’, ‘CustRfnd:V’
‘Expense Report:In Progress’, ‘ExpRept:A’
‘Expense Report:Pending Supervisor Approval’, ‘ExpRept:B’
‘Expense Report:Pending Accounting Approval’, ‘ExpRept:C’
‘Expense Report:Rejected by Supervisor’, ‘ExpRept:D’
‘Expense Report:Rejected by Accounting’, ‘ExpRept:E’
‘Expense Report:Approved by Accounting’, ‘ExpRept:F’
‘Expense Report:Approved (Overridden) by Accounting’, ‘ExpRept:G’
‘Expense Report:Rejected (Overridden) by Accounting’, ‘ExpRept:H’
‘Expense Report:Paid In Full’, ‘ExpRept:I’
‘Invoice:Open’, ‘CustInvc:A’
‘Invoice:Paid In Full’, ‘CustInvc:B’
‘Item Fulfillment:Picked’, ‘ItemShip:A’
‘Item Fulfillment:Packed’, ‘ItemShip:B’
‘Item Fulfillment:Shipped’, ‘ItemShip:C’
‘Journal:Pending Approval’, ‘Journal:A’
‘Journal:Approved for Posting’, ‘Journal:B’
‘Opportunity:In Progress’, ‘Opprtnty:A’
‘Opportunity:Issued Estimate’, ‘Opprtnty:B’
‘Opportunity:Closed – Won’, ‘Opprtnty:C’
‘Opportunity:Closed – Lost’, ‘Opprtnty:D’
‘Paycheck:Undefined’, ‘Paycheck:A’
‘Paycheck:Pending Tax Calculation’, ‘Paycheck:C’
‘Paycheck:Pending Commitment’, ‘Paycheck:D’
‘Paycheck:Committed’, ‘Paycheck:F’
‘Paycheck:Preview’, ‘Paycheck:P’
‘Paycheck:Reversed’, ‘Paycheck:R’
‘Payment:Unapproved Payment’, ‘CustPymt:A’
‘Payment:Not Deposited’, ‘CustPymt:B’
‘Payment:Deposited’, ‘CustPymt:C’
‘Payroll Liability Check:Voided’, ‘LiabPymt:V’
‘Purchase Order:Pending Supervisor Approval’, ‘PurchOrd:A’
‘Purchase Order:Pending Receipt’, ‘PurchOrd:B’
‘Purchase Order:Rejected by Supervisor’, ‘PurchOrd:C’
‘Purchase Order:Partially Received’, ‘PurchOrd:D’
‘Purchase Order:Pending Billing/Partially Received’, ‘PurchOrd:E’
‘Purchase Order:Pending Bill’, ‘PurchOrd:F’
‘Purchase Order:Fully Billed’, ‘PurchOrd:G’
‘Purchase Order:Closed’, ‘PurchOrd:H’
‘Quote:Open’, ‘Estimate:A’
‘Quote:Processed’, ‘Estimate:B’
‘Quote:Closed’, ‘Estimate:C’
‘Quote:Voided’, ‘Estimate:V’
‘Quote:Expired’, ‘Estimate:X’
‘Return Authorization:Pending Approval’, ‘RtnAuth:A’
‘Return Authorization:Pending Receipt’, ‘RtnAuth:B’
‘Return Authorization:Cancelled’, ‘RtnAuth:C’
‘Return Authorization:Partially Received’, ‘RtnAuth:D’
‘Return Authorization:Pending Refund/Partially Received’, ‘RtnAuth:E’
‘Return Authorization:Pending Refund’, ‘RtnAuth:F’
‘Return Authorization:Refunded’, ‘RtnAuth:G’
‘Return Authorization:Closed’, ‘RtnAuth:H’
‘Sales Order:Pending Approval’, ‘SalesOrd:A’
‘Sales Order:Pending Fulfillment’, ‘SalesOrd:B’
‘Sales Order:Cancelled’, ‘SalesOrd:C’
‘Sales Order:Partially Fulfilled’, ‘SalesOrd:D’
‘Sales Order:Pending Billing/Partially Fulfilled’, ‘SalesOrd:E’
‘Sales Order:Pending Billing’, ‘SalesOrd:F’
‘Sales Order:Billed’, ‘SalesOrd:G’
‘Sales Order:Closed’, ‘SalesOrd:H’
‘Sales Tax Payment:Voided’, ‘TaxPymt:V’
‘Sales Tax Payment:Online Bill Pay Pending Accounting Approval’, ‘TaxPymt:Z’
‘Statement Charge:Open’, ‘CustChrg:A’
‘Statement Charge:Paid In Full’, ‘CustChrg:B’
‘Tax Liability Cheque:Voided’, ‘TaxLiab:V’
‘Tegata Payable:Endorsed’, ‘TegPybl:E’
‘Tegata Payable:Issued’, ‘TegPybl:I’
‘Tegata Payable:Paid’, ‘TegPybl:P’
‘Tegata Receivables:Collected’, ‘TegRcvbl:C’
‘Tegata Receivables:Discounted’, ‘TegRcvbl:D’
‘Tegata Receivables:Endorsed’, ‘TegRcvbl:E’
‘Tegata Receivables:Holding’, ‘TegRcvbl:H’
‘Transfer Order:Pending Approval’, ‘TrnfrOrd:A’
‘Transfer Order:Pending Fulfillment’, ‘TrnfrOrd:B’
‘Transfer Order:Rejected’, ‘TrnfrOrd:C’
‘Transfer Order:Partially Fulfilled’, ‘TrnfrOrd:D’
‘Transfer Order:Pending Receipt/Partially Fulfilled’, ‘TrnfrOrd:E’
‘Transfer Order:Pending Receipt’, ‘TrnfrOrd:F’
‘Transfer Order:Received’, ‘TrnfrOrd:G’
‘Transfer Order:Closed’, ‘TrnfrOrd:H’
‘Vendor Return Authorization:Pending Approval’, ‘VendAuth:A’
‘Vendor Return Authorization:Pending Return’, ‘VendAuth:B’
‘Vendor Return Authorization:Cancelled’, ‘VendAuth:C’
‘Vendor Return Authorization:Partially Returned’, ‘VendAuth:D’
‘Vendor Return Authorization:Pending Credit/Partially Returned’, ‘VendAuth:E’
‘Vendor Return Authorization:Pending Credit’, ‘VendAuth:F’
‘Vendor Return Authorization:Credited’, ‘VendAuth:G’
‘Vendor Return Authorization:Closed’, ‘VendAuth:H’
‘Work Order:Pending Build’, ‘WorkOrd:B’
‘Work Order:Cancelled’, ‘WorkOrd:C’
‘Work Order:Partially Built’, ‘WorkOrd:D’
‘Work Order:Built’, ‘WorkOrd:G’
‘Work Order:Closed’, ‘WorkOrd:H’

Netsuite PHP ToolKit Tips and Code Samples

I have been working on Netsuite PHP Toolkit for some time. Below are some code samples and tips I found useful. Any suggestion/comments are welcome.

Tips

Netsuite Webservices have concurrent session issue. This can be handled by adding a simple loop in make call function.

In PHPToolkit functions are not enclosed in try catch blocks. It is a good practice to add them to be safe from unexpected results.

GetAll Operation can be used to fetch many type of lists in netsuite

$result = $myNSClient->getAll(‘supportCaseIssue’);

Get Operation

$RecordRef = new nsRecordRef(array('internalId' => 23, 'type' => 'customer'));
$getResponse = $myNSClient->get($RecordRef);

Search by Internal Id

$search = new nsComplexObject("ContactSearchBasic");
$search->setFields(array("internalId" => array("operator" => 'anyOf', "searchValue" => new nsRecordRef(array('internalId' => ‘24’, 'type' => 'contact')))));
$searchResponse = $myNSClient->search($search);

Clearing Fields
In update operation if you want to clear an already set field you have to use nullfield list.
Below is the code to clear the email and phone fields in any case object.

$nullFieldArray = array();
$nullFieldArray['name'] = array();
$nullFieldArray['name'][] = ‘email’;
$nullFieldArray['name'][] = ‘phone’;
$caseFields['nullFieldList'] = $nullFieldArray;

Join Search

Get companies attached with a contact

$searchAdvance = new nsComplexObject('CustomerSearchAdvanced');
$search = new nsComplexObject('CustomerSearch');

$searchBasic = new nsComplexObject('ContactSearchBasic');
$searchMultiSelectField = new nsComplexObject('SearchMultiSelectField');
$searchValue = new nsRecordRef(array('type' => 'contact', 'internalId' => $contactInternalId));
$searchMultiSelectField->setFields( array( 'operator'=>'anyOf','searchValue'=>$searchValue));
$searchBasic->setFields(array('internalId'=>$searchMultiSelectField));
$joinFields = array('contactJoin'=>$searchBasic);
$search->setFields($joinFields);
$searchAdvance->setFields(array('criteria'=>$search));
$searchResponse = $myNSClient->search($searchAdvance);

The Geek Peek (An insight into Blogosphere)

We are living in the age of information. The web is overwhelmed by user generated content. Any body can share his/her view on any topic and it goes public the very next moment. The blogosphere has become a place where every body is speaking and no body is listening. While generally it is the case but some topics and blogs really stand out. Below is a listing of such blogs.

Duct Tape Programmer

I hope you have heard about the book “coders at work”. It’s a collection of the author’s interviews with 15 of the best brains in Computer Science and Programming, the world has seen. Some parts of the interview (quoted here, http://gigamonkeys.wordpress.com/2009/09/28/a-tale-of-two-rewrites/ ) with Jamie Zawinski gave a stir to the blogging world.

The idea was first discussed at http://joelonsoftware.com/items/2009/09/23.html

Most of the bloggers supported the basic idea

http://jeffreypalermo.com/blog/debunking-the-duct-tape-programmer/

While the astronaut architect would sit in analysis paralysis, the duct tape programmer would have some working product already out the door.

http://www.cubeia.com/index.php/blog/archives/140

Gave few very good Practical examples for “The Duct Tape Architect”

http://www.kevinwilliampang.com/2009/10/26/theres-no-such-thing-as-a-duct-tape-programmer/

All carpenters have duct tape in their toolbox

The difference between a good developer and a bad developer isn’t whether they use duct tape, it’s how well they can recognize whether a situation calls for it.

http://blog.objectmentor.com/articles/2009/09/24/the-duct-tape-programmer

Not that you shouldn’t learn new ideas, and new languages, and new APIs; you should! But you don’t have to use them in systems as soon as they are out of the box. Let them cure a bit.

So. Be smart. Be clean. Be simple. Ship! And keep a small roll of duct tape at the ready, and don’t be afraid to use it.

Some of them denied it with their arguments.

http://techdistrict.kirkk.com/2009/09/25/duct-tape-programming/

Programmers are smart.

http://www.tbray.org/ongoing/When/200x/2009/09/25/On-Duct-Tape

Joel is right that complexity is your enemy

Unit testing is right Joel and zwk are wrong.

SQL vs NoSQL

A problem with growing data is that we need more robust and scalable DBMS. Certain techniques are being implemented to cope with massive data. One of them is NoSQL.

NoSQL Databases – An Overview

http://www.nosqldatabases.com/main/2010/7/9/nosql-databases-an-overview.html

SQL + NoSQL = SomeSQL

http://paranoid-engineering.blogspot.com/2010/07/sql-nosql-somesql.html

NOSQL OR NOJOIN?

http://www.daniel-lemire.com/blog/archives/2010/06/28/nosql-or-nojoin/

How the NoSQL is going to affect SQL. How they both interact with each other.

10 things you should know about NoSQL databases

http://blogs.techrepublic.com.com/10things/?p=1772

What The Heck Are You Actually Using NoSQL For?

http://highscalability.com/blog/2010/12/6/what-the-heck-are-you-actually-using-nosql-for.html

What problems are resolved with NoSQL? What NoSQL can do and what can’t be done by NoSQL.

The beginning of the end of NoSQL

http://blogs.the451group.com/information_management/2010/11/12/the-beginning-of-the-end-of-nosql/

It discusses the term NoSQL and what it employs.

NoSQL: Don’t Take the Drug Unless You Have the Symptoms

http://www.soderstrom.se/?p=366

It addresses the real world practical problems with NoSQL

An Introduction To Cassandra: The Data Model

http://java.dzone.com/articles/introduction-cassandra-data

Cassandra is being used by big players in the web to scale their sites. This article explains its architecture briefly.

First look at Google BigQuery

http://xebee.xebia.in/2010/11/18/first-look-at-google-bigquery/

Last Byte

After having some food for thought, now have dessert for thought. It’s a link for some programming quotes. Although you may have read some of them but many of them are new and HILARIOUS.

http://www.junauza.com/2010/12/top-50-programming-quotes-of-all-time.html

Microsoft Open Door Event

On 4th and 5th Nov 2010 Sheraton Hotel, Karachi was overwhelmed by geeks and gadgets. The event was Microsoft Open Door. Being part of the presentations and discussions I was able to collect some views about Microsoft. Below is a little account about it, You can add your bits through comments.

Corporate Perspective

Innovation is not the first priority corporate companies. They need mature products. Microsoft is the biggest player in giving them mature yet innovative solutions which are very nicely integrated with each other. So by paying some extra money they are saved from lots of integration/deployment risks.

http://sharepoint.microsoft.com/en-us/Pages/default.aspx

http://www.microsoft.com/en-us/dynamics/default.aspx

http://sharepoint.microsoft.com/businessproductivity/solutions/pages/unified-communications.aspx#fbid=Wdz43M6fKZG

Developer Perspective

Microsoft is having its full share on latest trends and technologies

http://www.microsoft.com/windowsazure/windowsazure/

With IE 9 MS is now very in into HTML 5

http://ie.microsoft.com/testdrive/

Microsoft is much more anticipated to give its products free for development purposes. Need Proof? These links speak thousand words

http://msdn.microsoft.com/en-us/evalcenter/default.aspx

http://technet.microsoft.com/en-us/evalcenter/default.aspx

Local Perspective

There are many partners at different levels in Pakistan. Microsoft (Especially people at Microsoft East Asia & Africa) are very enthusiastic about Pakistan. Pakistan is one of the strongest Developer Community in the region. All these people and power can make Pakistan a good software solutions Market.

Pro Microsoft Perspective

Microsoft is every kind of IT related business and they are doing things better than any other company could do. There are not many organizations that can come up with a successful product like Windows 7 after a massive failed product like Vista so we can expect from Microsoft to come up with a boom at any moment.

Microsoft cares (and it has to) about the non-profit sectors

https://www.dreamspark.com/default.aspx

A usability tip

In past decades World-Wide-Web has evolved from simple navigational websites to more process based portals. As websites getting richer day by day we should use standards to maintain ease of access.

A tip in this regard may be that text links are good for navigational purposes but whenever an action is going to be performed based on user click a Button should be placed ( not necessarily a HTML button but it can be a link that look likes a button).

For example on a job portal a user finds a text link saying “Apply for this job”. Upon clicking this link a user expects to be navigated to a page where he or she can complete the process of applying for the job. The user will be surprised if he finds that clicking the link has caused him to actually apply for the job. This use experience can be changed a lot by just changing the text link into a button.

Most of us are using these type of techniques but we can still find people ignoring these things and making WWW not a better place to live. what’s your say.

Netsuite Programming Tips

  • Record Browser and Help center do not have complete documentation about some entities.  Loading Such objects in debugger shows all the fields and sublist for the entity.
  • Searching for any entity programmatically brings the records which are marked as ‘inactive’. Inactive entities can not be referenced by other entities.
  • Always initialize ‘nlobjSearchFilter’ and ‘nlobjSearchColumn’ with the ‘new’ keyword. Otherwise it creates unexpected errors.
  • Be careful when doing number calculations as Suitscript (actually Javascript Engines) some times concatenates the number instead of adding them.  ParseInt and ParseFloat functions can help in this scenario.
  • Floating Point numbers also cause Precision problems ( http://stackoverflow.com/questions/588004/is-javascripts-math-broken )
  • Api.js is also a great help ( https://system.netsuite.com/app/common/scripting/nlapihandler.nl?downloadapi=T )
  • As SuiteScript is based on JavaScript, so read Javascript books to master in suiteScript.

Trust yourself but never trust your code

An intelligent fool can make simple thing complex

Most good developers have believe in their selves. This helps them committing and fulfilling harder goals. This self belief also gets extended to the code they write. This feeling make them believe that simpler parts of our code can never be wrong neither syntactically nor logically. In reality it frequently happens that few lines of code written to perform a very mundane task become the source of Bug.

Let’s take an example. You write a small script to fetch some data from the DB and show it in HTML table. Some how the data doesn’t show up correctly. You scratch your head as you are unable to find any bug in your db schema or in your PHP code. After a painful debugging session you find out that real problem was in your HTML tags. It took so long to find the bug because developer thought that the html part is simple and it can’t be wrong so the bug must be in some other part of the code.

Trusting your code blindly results in time-wasting. In fact the more you write and test code the more you understand that “less is more”. http://elegantcode.com/2010/06/06/the-best-code-you-will-ever-write/

Follow

Get every new post delivered to your Inbox.