We pull some data from a custom record type to create a new partner record. The following is the code used to create the partner record. The country is canada and is selected in the custom record from the native NS Country List by a getFieldValue. It returns 37 for Canada. However when the script executes we get Invalid Coundtry Reference Key 37 for the var emscountry2 when the new partner record is submitted. Based on the code below what change do I need to make this work.
var newpartrec = nlapiCreateRecord('partner');
//Put in the partner/entity ID, which is a required field
newpartrec.setFieldValue('entityid',emsorgname);
//Put in the partner code, which is a required field
newpartrec.setFieldValue('partnercode',emsorgname);
//Map in the other partner fields that will not be part of the contact record
newpartrec.setFieldValue('companyname',emsorgname);
newpartrec.setFieldValue('email',emsemail);
newpartrec.setFieldValue('phone',emsoffphone);
newpartrec.setFieldValue('fax',emsfax);
newpartrec.setLineItemValue('addressbook','addr1',1,emsaddress1);
newpartrec.setLineItemValue('addressbook','addr2',1,emsaddress2);
newpartrec.setLineItemValue('addressbook','city',1,emscity);
newpartrec.setLineItemValue('addressbook','state',1,emsstate2);
newpartrec.setLineItemValue('addressbook','zip',1,emszip);
newpartrec.setLineItemValue('addressbook','country',1,emscountry2);
//Add in default billing and default shipping
newpartrec.setLineItemValue('addressbook','defaultbilling',1,'T');
newpartrec.setLineItemValue('addressbook','defaultshipping',1,'T');
//Add in ems provider type to partner record. 1 is the ID for ems provider.
var addphystype = new Array();
addphystype[0] = 1;
newpartrec.setFieldValues('custentityvendortype',addphystype);
//Submit the partner record, including dependent fields
var subpartrec = nlapiSubmitRecord(newpartrec,true);