This topic cover the topic for showing the customer’s or contact’s name and who created the wishlist in My account UI on the website
- Create a contact under the main customer and access it to login into the website
As per the contact
1. Login to NetSuite account (The login credentials are already shared previously)
2. Go to the lead or customer record where you want to create a contact for customer.
3. Create a contact under the user or company.
4. give access to that contact for it can be logged into the website as user or customer
5. Create a wishlist in my account. and the name will be shown below the notes in the wishlist.
Note: We can give access by using the access tab of the customer record, under which there is a contact tab, in which we can give access to each individual contact.
Create an extension for the Wishlist
Check where the name is storing in the custom record, if not create a suite script for storing the name
Create a function for showing the name of creator on the My wishlist (SuiteScript)
_.extend(ProductListModel, {
getCreatorName : function(email){
try {
var url = “https://tstdrv2778156.extforms.netsuite.com/app/site/hosting/scriptlet.nl?script=1313&deploy=1&compid=TSTDRV2778156&h=de07171b53ed25cb46d2”;
var response = nlapiRequestURL(test, {email : email , id: nlapiGetUser()} , null , ‘POST’);
if (response.code === 200 && response.body !== ”) {
var bodyObject = JSON.parse(response.body);
return bodyObject.name;
}else{
return ”;
}
} catch (e) {
console.error(“err@GetCreatorName”, e);
}
},
getColumns: function() {
return {
internalid: new nlobjSearchColumn(‘internalid’),
templateid: new nlobjSearchColumn(‘custrecord_ns_pl_pl_templateid’),
name: new nlobjSearchColumn(‘name’),
description: new nlobjSearchColumn(‘custrecord_ns_pl_pl_description’),
owner: new nlobjSearchColumn(‘custrecord_ns_pl_pl_owner’),
scope: new nlobjSearchColumn(‘custrecord_ns_pl_pl_scope’),
type: new nlobjSearchColumn(‘custrecord_ns_pl_pl_type’),
created: new nlobjSearchColumn(‘created’),
lastmodified: new nlobjSearchColumn(‘lastmodified’),
creator : new nlobjSearchColumn(‘custrecord_jj_whish_list_creator’)
};
},
// Returns a product list based on a given userId and id
get: function(user, id) {
this.verifySession();
console.error('Wishlist GET user id', id);
var filters = [
new nlobjSearchFilter('internalid', null, 'is', id),
new nlobjSearchFilter('isinactive', null, 'is', 'F'),
new nlobjSearchFilter('custrecord_ns_pl_pl_owner', null, 'is', user)
];
var product_lists = this.searchHelper(filters, this.getColumns(), true);
if (product_lists.length >= 1) {
return product_lists[0];
}
throw notFoundError;
},
searchHelper: function(filters, columns, include_store_items, order, template_ids) {
// Sets the sort order
var order_tokens = (order && order.split(':')) || [];
var sort_column = order_tokens[0] || 'name';
var sort_direction = order_tokens[1] || 'ASC';
var productLists = [];
columns[sort_column] && columns[sort_column].setSort(sort_direction === 'DESC');
// Makes the request and format the response
var records = Application.getAllSearchResults(
'customrecord_ns_pl_productlist',
filters,
_.values(columns)
);
_.each(records, function(productListSearchRecord) {
var product_list_type_text = productListSearchRecord.getText(
'custrecord_ns_pl_pl_type'
);
var last_modified_date = nlapiStringToDate(
productListSearchRecord.getValue('lastmodified'),
window.dateformat
);
var last_modified_date_str = nlapiDateToString(
last_modified_date,
window.dateformat
);
var productList = {
internalid: productListSearchRecord.getId(),
templateId: productListSearchRecord.getValue('custrecord_ns_pl_pl_templateid'),
name: productListSearchRecord.getValue('name'),
description: productListSearchRecord.getValue('custrecord_ns_pl_pl_description')
? productListSearchRecord
.getValue('custrecord_ns_pl_pl_description')
.replace(/\n/g, '<br>')
: '',
owner: {
id: productListSearchRecord.getValue('custrecord_ns_pl_pl_owner'),
name: productListSearchRecord.getText('custrecord_ns_pl_pl_owner')
},
creator: productListSearchRecord.getValue('custrecord_jj_whish_list_creator'),
scopeId: productListSearchRecord.getValue('custrecord_ns_pl_pl_scope'),
scopeName: productListSearchRecord.getText('custrecord_ns_pl_pl_scope'),
typeId: productListSearchRecord.getValue('custrecord_ns_pl_pl_type'),
typeName: product_list_type_text,
created: productListSearchRecord.getValue('created'),
lastmodified: productListSearchRecord.getValue('lastmodified'),
lastmodifieddate: last_modified_date_str,
items: ProductListItemSearch.search(
productListSearchRecord.getValue('custrecord_ns_pl_pl_owner'),
productListSearchRecord.getId(),
include_store_items,
{
sort: 'sku',
order: '1',
page: -1
}
)
};
if (template_ids && productList.templateId) {
template_ids.push(productList.templateId);
}
productLists.push(productList);
});
return productLists;
},
// Retrieves all Product Lists for a given user
search: function(user, order) {
var filters = [
new nlobjSearchFilter('isinactive', null, 'is', 'F'),
new nlobjSearchFilter('custrecord_ns_pl_pl_owner', null, 'is', user)
];
console.error('Wishlist Filter', filters);
var template_ids = [];
var product_lists = this.searchHelper(
filters,
this.getColumns(),
false,
order,
template_ids
);
var self = this;
// Add possible missing predefined list templates
_(this.configuration.listTemplates).each(function(template) {
if (!_(template_ids).contains(template.templateId)) {
if (!template.templateId || !template.name) {
console.log(
'Error: Wrong predefined Product List. Please check backend configuration.'
);
} else {
if (!template.scopeId) {
template.scopeId = '2';
template.scopeName = 'private';
}
if (!template.description) {
template.description = '';
}
if (!template.typeId) {
template.typeId = '3';
template.typeName = 'predefined';
}
// This conversion to "string" is necessary since there exist an inconsistency between backend response and default values in ProductList.json
template.scopeId += '';
product_lists.push(template);
}
}
});
if (this.isSingleList()) {
return _.filter(product_lists, function(pl) {
// Only return predefined lists.
return pl.typeName === 'predefined';
});
}
return product_lists.filter(function(pl) {
return pl.typeId !== self.later_type_id && pl.typeId !== self.quote_type_id;
});
},
// Creates a new Product List record
create: function(user, data) {
console.error('Wishlist create data', data);
this.verifySession();
var productList = nlapiCreateRecord('customrecord_ns_pl_productlist');
productList.setFieldValue('custrecord_jj_whish_list_creator', this.getCreatorName(data.creatorEmail));
data.templateId &&
productList.setFieldValue('custrecord_ns_pl_pl_templateid', data.templateId);
data.scopeId && productList.setFieldValue('custrecord_ns_pl_pl_scope', data.scopeId);
data.typeId && productList.setFieldValue('custrecord_ns_pl_pl_type', data.typeId);
data.name && productList.setFieldValue('name', this.sanitize(data.name));
data.description &&
productList.setFieldValue(
'custrecord_ns_pl_pl_description',
this.sanitize(data.description)
);
productList.setFieldValue('custrecord_ns_pl_pl_owner', user);
return nlapiSubmitRecord(productList);
},
// Updates a given Product List given its id
update: function(user, id, data) {
console.error('Wishlist update data', data);
this.verifySession();
var product_list = nlapiLoadRecord('customrecord_ns_pl_productlist', id);
product_list.setFieldValue('custrecord_jj_whish_list_creator', this.getCreatorName(data.creatorEmail));
if (parseInt(product_list.getFieldValue('custrecord_ns_pl_pl_owner'), 10) !== user) {
throw unauthorizedError;
}
data.templateId &&
product_list.setFieldValue('custrecord_ns_pl_pl_templateid', data.templateId);
data.scopeId && product_list.setFieldValue('custrecord_ns_pl_pl_scope', data.scopeId);
data.typeId && product_list.setFieldValue('custrecord_ns_pl_pl_type', data.typeId);
data.name && product_list.setFieldValue('name', this.sanitize(data.name));
product_list.setFieldValue(
'custrecord_ns_pl_pl_description',
data.description ? this.sanitize(data.description) : ''
);
nlapiSubmitRecord(product_list);
},
// Deletes a Product List given its id
delete: function(user, id) {
this.verifySession();
var product_list = nlapiLoadRecord('customrecord_ns_pl_productlist', id);
if (parseInt(product_list.getFieldValue('custrecord_ns_pl_pl_owner'), 10) !== user) {
throw unauthorizedError;
}
product_list.setFieldValue('isinactive', 'T');
var internalid = nlapiSubmitRecord(product_list);
return internalid;
}
});
and fetch data from profile model and pass the value to template file.