Load and Modify External File in NetSuite

When building a suitelet in NetSuite you can either inject HTML, CSS and Javascript in a field, or generate a full HTML page and render it into the suitelet. No matter which method you use, you normally have to write line after line of SuiteScript code where you build the HTML using string concatenation. This is not only difficult and tedious to write, making sure you match all the single and double quotes and semi colons, it also makes the code much harder to maintain. What if you could just create a regular HTML file, put it in the File Cabinet and then render it into a suitelet? And what if you could use one line of code to inject values from NetSuite in the correct place in the HTML? This could be search results from the use of my search function. That is what the function looks like: /** * Load file from NetSuite File Cabinet and replace placeholders with actual values * * Version Date Author Remarks * 1.00 07 Nov 2016 kmartinsson Created class/function * 1.01 08 Nov 2016 kmartinsson Consolidated setValue and setHTML into * one method and added noEscape parameter */ // ***** Read and process external file, replacing placeholders with proper values ***** function ExternalFile(filename) { //Get the file by path/name, can also be internal id var fileId = filename; // Load file content and store data var file = nlapiLoadFile(fileId); var data = file.getValue(); this.content = data; this.setValue = function(placeholder, value, noEscape) { // Check if noEscape is passed, if it is and if true then don't escape value. // This is needed when value contains HTML code. if (typeof noEscape == "undefined") { this.content = this.content.replace(new RegExp(placeholder, 'g'), nlapiEscapeXML(value)); } else { if (noEscape == true) { this.content = this.content.replace(new RegExp(placeholder, 'g'), value); } else { this.content = this.content.replace(new RegExp(placeholder, 'g'), nlapiEscapeXML(value)); } } } this.getContent = function() { return this.content; } } Reference this function in your Suitescript 1.0 code like this: // Load extrenal HTML file var html = new ExternalFile("SuiteScripts/BinTransfer.html"); // Insert NetSuite URL for CSS files var cssFileName = nlapiLoadFile("SuiteScripts/css/drop-shadow.css").getURL(); html.setValue("%cssDropShadow%", cssFileName, true); cssFileName = nlapiLoadFile("SuiteScripts/css/animate.css").getURL(); html.setValue("%cssAnimate%", cssFileName, true); // Insert array returned from a search html.setValue("%binarray%", JSON.stringify(binArray), true); // Replace placeholders with values html.setValue("%showAll%", "false"); html.setValue("%company%", companyName); The last (optional) argument "noEscape" decides if the value should be URL encoded (false/omitted) or not (true) using the function nlapiEscapeXML(). In most cases you don't need to specify this argument, but if you need to pass HTML or other code into the function you need to set it to true to avoid the code being modified. As you can see in my example above, I get the NetSuite URL for my CSS files as well. Instead of hard coding the NetSuite URL into the HTML page, I calculate it and insert it when the page is loaded. Not only does it make the page easier to read the code, it also makes it much easier to maintain. This is…

0 Comments

MWLUG 2017 – Be There!

This year's MWLUG conference will take place in Alexandria, VA. During the three day conference more than 50 sessions and two free workshops will be offered. All this for just $75. This year the conference starts a day earlier than usual, on a Tuesday. But everything you are used to from the previous years will be there. Keynotes, sessions, workshops, breakfast and lunch, receptions, networking events, access to experts, and much more. A new even for this year is Linuxfest, known from Lotusphere/IBM Connect. It is again hosted by Bill Malchisky together with a (as of now) secret guest speaker. You can register for MWLUG 2017 here.

0 Comments

Easy NetSuite Search

In an attempt to expand my knowledge to other platforms than Notes and Domino, I have now been working with NetSuite for a number of months. I have mainly been working with the ERP part of the cloud based system. The language used is called SuiteScript, and it is Javascript with a NetSuite-specific API to work directly with the databases. Knowing Javascript makes it easy to get started, just like knowing Visual Basic makes it easy to learn Lotusscript. And just like with Lotusscript, you have to learn the NetSuite specific functions. Since I like my code clean and easy to read (which will make future maintenance easier), I have created a number of functions to encapsulate NetSuite functionality. The first one I created was to search the database. The search in NetSuite is done by defining the columns (i.e. fields) to return as an array of search column objects. Then an array of search filters is created, and finally the search function is called, specifying what record type to search and passing the two arrays to it as well. This is a lot of code, and with several searching in a script it can be very repetetive, not to mention hard to read. Here is an example of a traditional NetSuite search: var filters = []; filters.push(new nlobjSearchFilter('item', null, 'anyof', item)); filters.push(new nlobjSearchFilter('location', null, 'noneof', '@NONE@')); var columns = []; columns.push(new nlobjSearchColumn('internalid')); columns.push(new nlobjSearchColumn('trandate').setSort()); columns.push(new nlobjSearchColumn('location')); var search = nlapiSearchRecord('workorder', '', filters, columns); Using my function, the code wold be simplified to this: var search = new Search('workorder'); search.addFilter('item', null, 'anyof', item); search.addFilter('location', null, 'noneof', '@NONE@'); search.addColumn('internalid')); search.addColumn('trandate',true); // Sort on this column search.addColumn('location'); var search = search.getResults(); The function also support saved searches. Simply add the following line: search.useSavedSearch('custsearch123'); There is a limitation in SuiteScript so that a maximum of 1000 records can be returned by a normal search. There is a trick to bypass this, but it requires some extra coding. So I thought why not add this into the function as default? So I did. Below is the code for the search function. I usually put it in a separate file and reference it as a library in the scripts where I want to use it. This first version does not support more advanced functionality like formulas in the filters. But for most searches this function will be usable. /** * Module Description * * Version Date Author Remarks * 1.00 11 Nov 2016 kmartinsson * 1.05 27 May 2017 kmartinsson Added support for record type in constructor * */ //***** Encapsulate search functionality ***** function Search(recordtype) { this.columns = []; this.filters = []; // If record type/ID is passed, no need to set it later if (recordtype == null || recordtype == "") { this.recordType = null; } else { this.recordType = recordtype; } // Set internal id of saved search to null this.internalId = null; // *** Set array of column names to return this.setColumns = function(columnArray) { for (var i = 0; i…

1 Comment

More time for your MWLUG abstract submission

Richard Moy, organizer of MWLUG, has extended the deadline for submission of abstract submission another week, until Friday, June 2. So if you haven't gotten around to submit an abstract yet, you have a few more days to come up with a good subject to present at this years MWLUG conference, taking place on August 8-10 in Washington, DC. Registration is also open. Don't miss out on a great conference!  

0 Comments

MWLUG Submssion Deadline

You have just over 3 days left to submit a session abstract for MWLUG 2017. The deadline is on Friday, May 26 at 5pm Central time. If you don't want to speak, registration is also open to this excellent conference. This year it takes place August 8-10 at Hilton Mark Center in Alexandria, VA. Expect a packed schedule with great sessions and speakers. This is one of the must-attend conferences in the US for anyone working with the ICS (IBM Collaborative Software) family of products.

0 Comments

IBM Connect – My thoughts and the future

There has been radio silence on this blog since right before IBM Connect in the end of February. I intended to write a recap of IBM Connect after I got back from the conference, but I have just been very busy. I haven't even had time to post the code from my presentation, but it will be up here shortly. There has already been several good overviews of IBM Connect, but I want to share how I experienced it, and how the first conference away from Orlando was. It was both good and bad. The bad part was just some minor things. Like everyone else I found San Francisco expensive, with a lot of homeless people. The venue also lacked some of the natural meeting spots we had in Orlando, when many of us were staying at the same hotel where the conference took place. The restrooms at the Moscone Center could also use a makeover. But none of these were things IBM really could do much about. What they could have done better would have been to server a warm breakfast and lunch, at least a couple of days. The food in Orlando was great, and at last years conference it was even outstanding, in my opinion. So the breakfasts of cereal and pastries and sandwiches for lunch was a bit of a disappointment. The conference itself was good. I enjoyed most of the sessions I attended, I learned about future enhancements to the Notes and Domino platform and ecosystem and I got to talk to a lot of people. I also met many of my friends in the community, but there however many faces missing. For the last few years more and more of the long-time Lotusphere/Connect attendees have moved away from the ICS platform into other technologies. It is just a natural progression. We all learn new things, try new technologies and broaden our horizons. I have done that myself, for the last several years I have moved more and more into pure web development, using tools like jQuery and Bootstrap to build front-ends to data often (but not always) located on a Domino server. But I have also been looking into other technologies. Lately I have been working with NetSuite, an ERP system recently acquired by Oracle. NetSuite is using Javascript both on the server and for the browser, so the skills I have aquired during my time as a Domino deverloper enabled me to quickly start working with this platform. Another area where I have been spending a lot of time is more traditional web design using Javascript, as well as frameworks and libraries like jQuery and Bootstrap. These tools can be integrated into Domino applications, and after you learn them it is not hard to branch out and use them with a different backend. One of the more exciting things that I brought back from Connect was the fact that Docker is a technology to watch. I attended a workshop that unfortunately had some technical problems,…

0 Comments

IBM Connect coming up – Save $$$ on the conference fee!

IBM Connect 2017 starts in exactly one month, and the early bird special ends tomorrow. But I can still save you some money. Reach out to me or any other IBM Champion, and we can give you a special promotion code to use during the registration to save you $100 off the conference fee. If you use the code before the early bird rate expires tomorrow evening (Jan 20) you get $300 off! So contact me  (or any other Champion) and we can will give you the code. You can get hold of me on Twitter as @texasswede and of course through email texasswede@gmail.com. If you haven't registered yet, it is time to do that. The block of rooms at the special conference rate will only be available a few more days. Nearby hotels are also filling up it seems, but you can still score some good deals. If you go to Connect, don't miss me co-presenting  The Great Code Givaway 11: It's Back! with my fellow IBM Champion and friend Rob Novak. Our session is currently scheduled for Wednesday February 22 at 2pm in Moscone West, Level 2, Room 2006. I hope to see you in San Francisco in a month!  

0 Comments

IBM Connect 2017 – I will be speaking in San Francisco

I will be speaking at IBM Connect in San Francisco now in February. Rob Novak has resurrected "The Great Code Giveaway" and asked me to present it together with him. Who would turn down that opportunity? So some time between February 21 and 23 you can see Rob and me on stage at Moscone West. The exact time and location has not been announced yet. I hope to see you in San Francisco and that you will find our presentation and code useful!

1 Comment

IBM Champions for 2017 announced

A few hours ago IBM announced the 2017 IBM Champions for ICS during the Dominopoint conference in Italy. This year 123 were picked, including 44 new Champions. An IBM Champion is a non-IBMer who evangelize IBM solutions and share their knowledge at conferences, on blogs, in forums, and in other ways. Congratulations to everyone picked, and a special welcome to the new Champions! I was fortunate enough to be picked for a fourth year. It is a huge honor. Thank you Amanda, Libby and of course IBM. On a related note, Amanda Bauman last week described how she and the IBM team used IBM Connections as a tool to reduce the time needed by the selection committee from 6 weeks to just 3. This is interesting reading, as it shows how Connections can be used for collaboration all over the world and save a lot of time. This time, I pulled all of the unique nominees into an Ideation Blog in a dedicated IBM Champion selection community on Connections Cloud. Each nominee had their own entry in the Ideation blog, complete with all of the nomination data received for that nominee. Including twitter handles, blog links, YouTube, and a listing from various people about their contributions. Over 70 IBMers were invited to review, validate contributions, and post their comments to the Ideation Blog. Where an IBMer was listed as a reference, that IBMer was invited to vote, comment, and support your nomination. Connections is a really powerful tool, and I wish I could have convinced my old workplace to start using it. I pushed for it for years, but it was never adopted, for different reasons.t is a

2 Comments

IBM Connect 2017 – It’s that time of the year!

Registration for IBM Connect 2017 is open. The conference, in the past known and beloved as Lotusphere, has changed some. It takes place a month later than normaland has moved from Orlando where it did take place for the last 20+ years. The new location is the Moscone Center in San Francisco and the dates are February 20-23, 2017. Another change to the format is that the conference start Monday evening instead of Sunday. Otherwise the agenda looks very similar to what we got used to in the past. The list of session has not been published yet, the final selection of speakers will be made later this month. But I don't doubt there will be plenty of great sessions woth attending. I hope to be able to go, this is a great conference not only for learning but also for networking and socializing with other professionals who work with the IBM Collaborative and Watson products. I hope to see you in San Francisco in February!  

0 Comments

How to get the upcoming Font Awesome Pro 5.0 for $20

I love using the free icon set Font Awesome in my web applications, and I know I am not alone. A new major version is in the works, and the creators are using Kickstarter to help fund it. Font Awesome version 5 will still be free, but as an early backer you get the Pro versions, with over a thousand extra icons, and much more. And the price? Only $20 until the end of the Kickstarter tomorrow Monday at Noon Eastern time. After this the Pro version will be $40 and each of the currently 18 icon packs (each with 30 icons) will be $10. So this is a substantial savings. The new version should be available in May 2017 but as we all know, plans can always change. You can read more about the Kickstarter campaign or take a look at what you get in Font Awesome 4.7.   If you are doing any kind of web development and not already using it, you should take a closer look at Font Awesome.  

0 Comments

Looking for a HP calculator? Look no further!

It is probably well-known that I am a little bit of an enthusiast when it comes to HP calculators. I have written about this in the past here on my blog. The other day I received a packet from Switzerland. Inside I found two calculators from SwissMicros. This is a company who created and sell clones of the famous HP Voyager series (HP-11C, HP-12C, HP-15C and HP-16C) as well as a version to emulate HP-41. I received one full-size DM-15L (which was introduced just last year) as well as the original credit card sized DM-15. I picked this model as I still have my original HP-15C that I got in 1983 so I could compare them side-by-side. SwissMicros have made an amazing job. I have just started playing with them, but they work just like the original. The attention to detail is pretty amazing. On the back of the larger DM-15L there is even the same set of formulas, functions and error messages as on the original. There are of course some differences. The case is not plastic but titanium, and held together by four screws. The keys are flatter that on the classic HP keyboard, but the feel of the keyboard is almost identical, something that really impressed me. On the credit card sized DM-15 the keys are almost totally flat, but still easy to use despite the small size. There is also a USB port to allow users to connect to the computer to update the firmware or even access the content, something that did not exist back when the orignal calculators were introduced in the early 1980's. SwissMicros also claim to have fixed some of the bugs found in the original calculators. There is also more memory available by using a special firmware. The fact that you can upgrade the firmware is very nice. These days we are used to that, but back in the 80's that was unheard of. Another neat feature is that there are 3 different fonts to choose from. The original of course only had one font. The letters on the display are a little bit larger than the original, making them easy to read. The calculators also run at a much higher speed than the original at 48 MHz, but the speed can be slowed down to 12 MHz with a special key kombination. The batteries used are CR2032 instead of three button cells of the original. The 2011 HP-15C Limited Edition used two CR2032 batteries. You have to open the case (remove the four screws) of the SwissMicros calculators to replace the battery, instead of just popping of a small plastic door. I think it's a good improvement as that little door was prone to get lost. Thanks to the metal case the DM-15L is slightly heavier than my old HP-15C, but not by much. It weights 130 gram (4.5 oz) vs 118 gram (4.1 oz), with the credit card sized DM-15 coming in at 57 g (2 oz). The price is a bargain if you compare with eBay, where the originals often ar sold for $300-400 or even more. The full-size L-models are all 119…

1 Comment

IBM Champion nominations are now open

IBM has opened the nominations for IBM Champions for 2017. This is how they describe the program: The IBM Champion program recognizes innovative thought leaders in the technical community and rewards these contributors by amplifying their voice and increasing their sphere of influence. An IBM Champion is an IT professional, business leader, developer, or educator who influences and mentors others to help them make best use of IBM software, solutions, and services. https://www.ibm.com/developerworks/champion/index.html So if you know someone who have helped you or who deserve to be honored for their committment, go and nominate her or him! I have a list of people I plan to nominate myself.

0 Comments

New life for “old” technology

A few weeks ago I visited the town of Antigua in Guatemala for 5 days. My wife used to live in Guatemala, working for a non-profit organization back in the late 1990's, and she wanted to show me how beautiful the country is. Of course my wife was absolutely right. The town was colorful and relaxing, people were very nice and the food was delicious. When I in the past heard "Guatemala" I thought of rain forests and hot and humid conditions. But in Antigua the temperature was perfect, about 70° F (21° C) during the day and 55° F (13° C) at night. We slept with open windows every night, with a view of one of the nearby volcanoes. No need for air conditioning, we could just enjoy the clean fresh air. But what is really amazing is how resourceful people in Guatemala are. They reuse things in a very clever way, with the most striking being the "chicken bus", the local transportation system between cities. When American school buses get old they are sold at auctions for a couple of thousand dollars. Many of them are purchased by Guatemalans who drive them down through Mexico to Guatemala. There they are fitted with upgraded powerful diesel engines (often the same ones used to power semi-trucks), repainted and outfitted with additional lights (sometimes neon lights), roof racks for cargo and plenty of chrome. Often they get a new hood from a semi-truck as well. The US truck manufacturer International used to have a truck manufacturing plant in Guatemala, but it was closed down some years ago. This left the country with an abundance of very competent mechanics, especially diesel engine mechanics. They are now passing their knowledge on to the next generation. On an interesting note, IC Bus, one of the major manufacturer of the yellow American school buses, is a division within International and the school buses share much of the design with the International trucks. And this is what the end result looks like:   https://youtu.be/TuLDmSo24NY So what does this have to do with IBM Notes and Domino, you may ask? Well, the same way as you can take a boring and generic workhorse like a yellow school bus and give it a second life by converting it into a colorful and useful source of transportation, you can modernize and update your old and perhaps a bit dated Notes application to something new exciting and attractive that your users would like to use. Take your Notes application from this: To this modern web application: Just like the mechanics in Guatemala replaces the old worn-out engine with a new powerful truck engine, your Domino data engine can be replaced with a new engine, for example from LDC Via, if you want to get away from Domino as a server platform. But Domino is a very competent and powerful NoSQL database/server and will work well for most users. So like old worn out yellow school buses, your Notes applications can be given a…

2 Comments

IBM Notes, Domino and the future

As some may already know I was recently laid off after 14 years as a Notes and Domino developer at my workplace. I suspected for a while that some staff reduction would be coming soon, but I was a bit surprised that I was included since I am the only Notes developer in the company. I had for a while considered to do consulting and freelance development. My wife as well as several friends have been encouraging me for years. So this was just the push I needed. I am starting my own company, Demand Better Solutions, where I will focus on Notes and Domino Development, application modernization and migration as well as building brand new web applications and websites. I realize that me being laid off is just a business decision. It is not personal. Several of the business critical applications at my former employer are developed using IBM Notes, but the executives have for years been talking about moving away from the platform. Of course they don't realize the huge amount of work needed to do this, but never the less this was/is their ultimate goal. The reason is that they feel (based on what they hear from other executives) that Notes is old technology. The fact that IBM has been slow in modernizing the interface, and that many of the templates still look like back in 1999 when version 5.0 was released does not help this perception. Last fall all our email at my old job was moved to Outlook, and ever since I have heard users complaining about missing Notes and certain functionality they were used to. A lot of integration between Notes applications and Notes mail were also lost, and I had to re-create it in different ways. You often hear stories about people complaining about the Notes client, but most of our users wanted nothing but to get it back... My old employer also uses Visual FoxPro, a product where the last version was released in 2004. It has officially been discontinued by Microsoft, but we use it for several important applications. So I don't think that even a product being discontinued is driving a huge number of migrations. It is the perception of how modern the product is that matters. And that perception is almost 100% the way the product looks. To a user the interface is the product. Create a modern looking application and nobody will question (or care) what tool was used to build it. The last 3-4 years I have been learning new web technologies, like jQuery, Bootstrap, Ajax, JSON. I have been able to use much of that at work, as well as in several side projects. I also started learning C# and .net. After the layoff I sat down and started looking at (among others) php and mySQL as well as researched frameworks like AngularJS. As a developer I have to keep up with new technologies, or I will be left behind. But it is hard when you work full-time, have side work and then have…

2 Comments

IBM extending support of Notes & Domino

IBM today announced that support for IBM Notes and Domino 9.0.1 have been extended until September 30, 2021, five years from now. Like many others I would have liked to see IBM use the wording "at least until 2021", but I am sure IBM's lawyers have something to do with this. It is important to notice that this is not an end-of-life announcement, At the same time IBM also announced that they now will start shipping new features for the products in the Notes and Domino product line without changing the version number like before. In the past only bug fixes were shipped between version in so called "fix packs". Any new features had to wait until a new version was released. But recently some new features have been added as well, causing some confusion. In the future IBM will shift to more frequent updates , using the name Feature Packs. Many cloud offerings don't even do version numbers anymore (what version of Gmail are you using?), and Microsoft is doing the same thing with Windows 10, pushing out new features within the same version number. Also today IBM announced Fix Pack 7 (FP7), probably the last fix pack version before the name change to Feature Pack. It can be download as of today. You can read more about what is new here. In an upcoming feature release IBM is expected to update the JVM to Java 8, as well as add new functions needed for Verse on-promises which is planned for release at the end of the year.    

0 Comments

My MWLUG presentation

I have been very busy ever since the MWLUG conference in Austin, but now you can finally view my presentation and download the sample code. Enjoy!   I will post the code for my Phonegap Demo next week. Reminder: you need to sign the database (or at least all the agents) with an ID who has the rights to run agents, or the Ajax calls will not return anything. If you are interested in having your Notes applications modernized and moved to the web, feel free to contact me at karl-henry@demandbettersolutions.com.

0 Comments

End of content

No more pages to load