NetSuite / Wrike Integration

Published on January 30, 2022.

Last year, one of my NetSuite clients introduced me to Wrike - an online (SaaS) system for managing projects, tasks, deadlines, workflows, and more. It's very easy to use, with an intuitive, flexible interface. If you aren't familiar with it, I encourage you to check it out.

Wrike provides an impressive, easy-to-use Web API. It's a full-featured API, and with it you can access everything from users, groups, workflows, custom fields, folders and projects, tasks, comments, and more.

I've been using the Wrike API on a couple of NetSuite / Wrike integration projects, where I'm both pushing and pulling data to and from NetSuite and Wrike. One of the first projects that I worked on is a simple portlet that uses the Wrike API to retrieve my active tasks, and display them on my NetSuite dashboard.

Here's a short animation that shows the portlet. You can see that I'm adding a personal task in Wrike, and after refreshing the portlet in NetSuite, the task appears.

Click the image to view a larger version.

I thought I'd share the SuiteScript that I developed, and it is included at the end of this post. Again, it's very simple, but it does provide a nice foundation that you can build on, and code snippets that you could use for more advanced NetSuite / Wrike integrations.

Configuring the Portlet

In order to use the portlet, there are two settings that you need to set. One is the token, and the other is your contact ID.

To obtain a token, see the "Permanent access token" topic on this page: https://developers.wrike.com/oauth-20-authorization/

To obtain your contact ID (or the ID of another Wrike user that you're configuring the portlet for), I suggest making a call to the API's "Query Contacts" function, as described here: https://developers.wrike.com/api/v4/contacts/#query-contacts

As an alternative to specifying the settings in the script itself, you could use Script Parameters.

Adjusting the Wrike API Call

By default, the portlet is configured to retrieve all active tasks that have been assigned to the specified contact. Here's a code snippet that shows the call to the API.

var httpResponse = https.get(
	{
		url: 'https://www.wrike.com/api/v4/tasks/?responsibles=%5B%22' + contactID + '%22%5D&status=Active&sortField=Importance',
		headers: httpRequestHeaders
	}
);

The URL indicates that we want to retrieve active tasks, to which the contact is assigned ("responsible"), and that the tasks are to be sorted based on importance. If you're familiar with the Wrike API, you could adjust the URL to retrieve tasks that meet different criteria. For example, you might want to retrieve tasks that are assigned to multiple users.

Wrapping Up

I hope you find the portlet to be helpful. It's very basic, but I think it's a good example of how you can use the Wrike API to integrate Wrike with NetSuite. I've found it to be convenient, helping me to keep up with my open tasks, whether they're personal tasks or tasks associated with client projects.

As I mentioned above, you could use snippets of the code to build more advanced NetSuite / Wrike integrations. For example, I'm also working on an integration that automatically creates and assigns Wrike tasks based on NetSuite events and data.

The Portlet

/**
* @NApiVersion 2.1
* @NScriptType Portlet
* @NModuleScope SameAccount
*/


/* 

------------------------------------------------------------------------------------------
Script Information
------------------------------------------------------------------------------------------

Name:
Wrike Tasks

ID:
_wrike_tasks

Description:
A portlet that displays active Wrike tasks.

Portlet Type:
Inline HTML


------------------------------------------------------------------------------------------
MIT License
------------------------------------------------------------------------------------------

Copyright (c) 2022 Timothy Dietrich.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


------------------------------------------------------------------------------------------
Developer(s)
------------------------------------------------------------------------------------------

TD:
• Tim Dietrich
• timdietrich@me.com


------------------------------------------------------------------------------------------
History
------------------------------------------------------------------------------------------

20220130 - TD
Initial version.	


------------------------------------------------------------------------------------------
Thank You!
------------------------------------------------------------------------------------------

Styled Table CSS 
• Author: Dom (dcode)
• URL: https://dev.to/dcodeyt/creating-beautiful-html-tables-with-css-428l


*/


var https;

	
let token = 'your-token';

	
let contactID = 'your-contact-id';


define( [ 'N/https' ], main );


function main( httpsModule ) {

	https = httpsModule;
	
    return {
        render: renderContent
    }

}


function renderContent( params ) {
		
	params.portlet.title = 'Your Wrike Tasks';
	
	var httpRequestHeaders = {
		'Authorization': 'Bearer ' + token,
		'Content-Type': 'application/json'
	}	
	
	var httpResponse = https.get(
		{
			url: 'https://www.wrike.com/api/v4/tasks/?responsibles=%5B%22' + contactID + '%22%5D&status=Active&sortField=Importance',
			headers: httpRequestHeaders
		}
	);	
						
	if ( httpResponse.code == 200 ) {
		
		var responseBody = JSON.parse( httpResponse.body );
		
		var tasks = responseBody.data;
		
		var tableRows = '';
		
		for ( i = 0; i < tasks.length; i++ ) {
		
			var task = tasks[i];

			tableRows += `
				<tr>
					<td><a href="" target="_wrike"></a></td>
					<td></td>
				<tr>
			`;
								
		}			

		var content = `
		
			<style type = "text/css"> 

				.styled-table {
					border-collapse: collapse;
					margin: 0 0;
					font-size: 0.9em;
					font-family: sans-serif;
					min-width: 400px;
					box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);
					width: 100%;
				}			
			
				.styled-table th,
				.styled-table td {
					padding: 6px 6px;
				}
			
				.styled-table thead tr {
					background-color: #607799;
					color: #ffffff;
					text-align: left;
				}			
			
				.styled-table tbody tr {
					border-bottom: thin solid #dddddd;
				}

				.styled-table tbody tr:nth-of-type(even) {
					background-color: #f3f3f3;
				}
			
				.styled-table tbody tr.active-row {
					font-weight: bold;
					color: #009879;
				}	
			
				.styled-table tbody tr:hover {
					background-color: #ffff99;
				}
			
			</style>
			
			<table class="styled-table">
				<thead>
					<tr>
						<th>Title</th>
						<th>Importance</th>
					</tr>
				</thead>
				<tbody>
					
				</tbody>
			</table>
			
		`;
					
		params.portlet.html = content;

	} else {
		params.portlet.html = `<p style="color: red;">Not available.</p>`
	}

}
About Me

Hello, I'm Tim Dietrich. I develop custom software for businesses that are running on NetSuite, including mobile apps, Web portals, Web APIs, and more.

I'm the developer of several popular NetSuite open source solutions, including the SuiteQL Query Tool, SuiteAPI, and more.

I founded SuiteStep, a NetSuite development studio, to provide custom software and AI solutions - and continue pushing the boundaries of what's possible on the NetSuite platform.

Copyright © 2025 Tim Dietrich.