Reputation: 11
We have customer records in NetSuite CRM module with additional custom records linked to the customer record. We have a custom field on customer record "customer status".
Based on customer status we want to disable new custom record (in this case new service record) button. I am able to use beforeLoad script to disable button on main customer record but similar approach fails when I try to disable button associated with linked record.
/**
* @NApiVersion 2.0
* @NScriptType UserEventScript
*/
define(["N/log", "N/ui/serverWidget"], function(log,ui) {
function disableNewCaseButton(context){
if (context.type == context.UserEventType.VIEW){
var customerStatus = context.newRecord.getValue({"fieldId" : "custentitycustomer_status"});
if (customerStatus !== 1){
var newButton = context.form.getButton({
id: 'newrecrecmachcustrecordso_customer_name'
})
try{
newButton.isDisabled = true;
}
catch(e){
log.debug({
title : "error",
details: e
});
}
}
return;
}
}
return {
beforeLoad: disableNewCaseButton
}
});
Upvotes: 0
Views: 3135
Reputation: 2840
Set the custom record Access Type=Use Permission List. Then on the Role configuration, assign the custom record permission to the Role with Access=View.
View access is lower than Create so the user with this role will be able to select but the “New” option will not be available in the dropdown selection.
Upvotes: 0
Reputation: 3783
I don't believe there is any API supported way to do this.
If you want to resort to DOM hackery, you could use a client script to hide it:
document.getElementById("newrecrecmachcustrecordso_customer_name").style.display = "none";
Keep in mind that there is no guarantee this won't break in a future NetSuite updates.
Another approach could be to leave the button, but use a Workflow or Script on the linked record to prevent it from saving if the customer status is not valid.
Upvotes: 0