This topic contains 0 replies, has 0 voices, and was last updated by Jordan Manningham 7 years, 10 months ago.
-
AuthorPosts
-
January 16, 2017 at 1:15 pm #5626
Jordan ManninghamI have a before submit user event script that transfers address subrecords on a customer record to a contact record. The script executes perfectly on my end when logged in as any role. The script throws an error on line 58 when anyone not logged in as an admin tries to execute. The error is “Sublist addressbook field addressbookaddress is not a subrecord field Stack Trace: transfer(transferAddresses.js$259389:58)”. I’m really not sure why this error is being thrown. I’ve looked at role differences and checked permissions but am drawing a blank. I know addressbookaddress is not a documented sublist field but it should work for all users if it works for me and other admins.
Any thoughts?
Code:
function transfer(type, name){
if (nlapiGetFieldValue(‘custentity90’) == ‘T’){
try{
var com = nlapiLoadRecord(‘customer’, nlapiGetFieldValue(‘company’));
}
catch(e){}
try{
if (com == null){
com = nlapiLoadRecord(‘othername’, nlapiGetFieldValue(‘company’));
}
}
catch(e){}
try{
if (com == null){
com = nlapiLoadRecord(‘prospect’, nlapiGetFieldValue(‘company’));
}
}
catch(e){}
try{
if (com == null){
com = nlapiLoadRecord(‘lead’, nlapiGetFieldValue(‘company’));
}
}
catch(e){}
var address_fields = [‘defaultbilling’, ‘defaultshipping’, ‘country’, ‘custrecord_addresstype’, ‘attention’, ‘addressee’, ‘addrphone’, ‘addr1’, ‘addr2’, ‘city’, ‘dropdownstate’, ‘zip’];
var check_fields = [‘addr1’, ‘addr2’, ‘city’, ‘dropdownstate’, ‘zip’, ‘country’];
var addresses = com.getLineItemCount(‘addressbook’);
var a_count = nlapiGetLineItemCount(‘addressbook’);
var match = 0;
var matching = 0;
for (var xx = 1; xx 5){
match = 1;
}
}
}
if (match == 0){
com.selectLineItem(‘addressbook’, xx);
var cust_subrec = com.viewCurrentLineItemSubrecord(‘addressbook’, ‘addressbookaddress’);
var thisrec = nlapiGetNewRecord();
thisrec.selectNewLineItem(‘addressbook’);
thisrec.setCurrentLineItemValue(‘addressbook’, ‘defaultshipping’, com.getLineItemValue(‘addressbook’, address_fields[0], xx));
thisrec.setCurrentLineItemValue(‘addressbook’, ‘defaultbilling’, com.getLineItemValue(‘addressbook’, address_fields[1], xx));
thisrec.setCurrentLineItemValue(‘addressbook’, ‘isresidential’, com.getLineItemValue(‘addressbook’, ‘isresidential’, xx));
var subrec = nlapiCreateCurrentLineItemSubrecord(‘addressbook’, ‘addressbookaddress’);
subrec.setFieldValue(address_fields[2], cust_subrec.getFieldValue(address_fields[2]));
subrec.setFieldValue(address_fields[3], cust_subrec.getFieldValue(address_fields[3]));
subrec.setFieldValue(address_fields[4], cust_subrec.getFieldValue(address_fields[4]));
subrec.setFieldValue(address_fields[5], cust_subrec.getFieldValue(address_fields[5]));
subrec.setFieldValue(address_fields[6], cust_subrec.getFieldValue(address_fields[6]));
subrec.setFieldValue(address_fields[7], cust_subrec.getFieldValue(address_fields[7]));
subrec.setFieldValue(address_fields[8], cust_subrec.getFieldValue(address_fields[8]));
subrec.setFieldValue(address_fields[9], cust_subrec.getFieldValue(address_fields[9]));
subrec.setFieldValue(address_fields[10], cust_subrec.getFieldValue(address_fields[10]));
subrec.commit();
thisrec.commitLineItem(‘addressbook’);
}
}
nlapiSetFieldValue(‘custentity90’, ‘F’);
nlapiSetFieldValue(‘custentity67’, ‘F’);
nlapiSetFieldValue(‘custentity46’, ‘F’);
}
}
This is a cached copy. Click here to see the original post. -
AuthorPosts
You must be logged in to reply to this topic.