Tip 16 – Update Subscriptions in Contact Record

Hello Friend,

Recently I got a requirement like, we will have to update Subscriptions in Contact record and I was told that, Netsuite Support team says, its not possible to update it in Contact record through scripting.

I tried even after knowing its not possible as suggested by Netsuite Support.

Even in Record Browser, you won’t find any sublist/fields related to Subscriptions in Contact record.

I checked in Record Browser for Customer and tried checking how it works in Customer record.

Then I tried the same sublist and field IDs in Contact record to update Subscriptions.

You won’t believe, that worked.

Here is the sample piece of code that I am introducing to update Subscriptions in Contact Record:

var contactRecord = nlapiLoadRecord("contact",983);
var subCount = contactRecord.getLineItemCount("subscriptions");
		
//Billing Communication = 2, Marketing=1, Newsletters=4, Product Updates=5, Surveys=3
if(subCount > 0){
	for(var count = 1; count <= subCount; ++count){
		var sub = contactRecord.getLineItemValue("subscriptions", "subscription", count);
		var isChecked = contactRecord.getLineItemValue("subscriptions", "subscribed", count);
		nlapiLogExecution("DEBUG", "sub - isChecked", sub + " - " + isChecked);
				
		if(isChecked == "F"){
			contactRecord.setLineItemValue("subscriptions", "subscribed", count, "T");
		}
		else{
			contactRecord.setLineItemValue("subscriptions", "subscribed", count,"F");
		}
	}
}
var contactId= nlapiSubmitRecord(contactRecord);
nlapiLogExecution("DEBUG", "Contact record submitted", contactId);

Hope when you will get such requirement, you won’t need Netsuite Support’s help πŸ™‚

Cheers

Asha

Advertisements

One thought on “Tip 16 – Update Subscriptions in Contact Record

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s