How to give a contact access to netsuite login using suitlets

function GrantAccess(companyID,contactID,Email,Password){
  var obj = nlapiLoadRecord('customer',companyID);      
      obj.setFieldValue('contact',contactID);
      obj.setFieldValue('contactrole',-20);
      nlapiSubmitRecord(obj);   

    var obj_contact= nlapiLoadRecord('contact',contactID);
    var contact_email  = obj_contact.getFieldValue('email');
    
    var obj = nlapiLoadRecord('customer',companyID);    
    var linen = obj.findLineItemValue('contactroles', 'email', contact_email );
    nlapiLogExecution('DEBUG','LINE',linen);
    obj.selectLineItem('contactroles',linen );
    obj.setCurrentLineItemValue('contactroles', 'giveaccess', 'T'); 
    obj.setCurrentLineItemValue('contactroles', 'contact', contactID); 
    obj.setCurrentLineItemValue('contactroles', 'email', Email); 
    obj.setCurrentLineItemValue('contactroles', 'role', '14'); 
    obj.setCurrentLineItemValue('contactroles', 'password', Password); 
    obj.setCurrentLineItemValue('contactroles', 'passwordconfirm', Password); 
    obj.commitLineItem('contactroles');

    nlapiSubmitRecord(obj);
}

Popular posts from this blog

What are sales territory in Netsuite?

How to get and set a sublist in netsuite suitlet suitescript 2.0