Admin Upskill Center

Bulk Update Vendor Contact Roles in NetSuite

Browser-console method for bulk assigning primary vendor contact roles when standard NetSuite tooling is limited.

If you need to set the vendor contact role to Primary in bulk, you may have found that this is not possible to do programmatically.

Using a bit of ingenuity and chatGPT to do the boring work, I’m happy to share a code snippet you can use in your browser console to do this in bulk.

Just update the pairs section with your vendor and contact ids and put it in your browser console to run.

This method is similar to how you can create the “Other Relationship” link between vendors, customers, partners, and the good ‘ol “Other Name” entities.

// === CONFIG ===
const contactRole = -10; // Primary Contact Role internal ID
const pairs = [
    { vendorId: 674, contactId: 1360 },
];

// === DEFINE FUNCTION ===
async function addContactsSequential() {
    for (const { vendorId, contactId } of pairs) {

    const url = `/app/common/entity/companycontact.nl`;
    const body = new URLSearchParams({
        id: vendorId,
        contact: contactId,
        contactrole: contactRole,
        action: 'addcontact'
    });

    try {
        const res = await fetch(url, {
            method: 'POST',
            headers: {'Content-Type': 'application/x-www-form-urlencoded'},
            body: body.toString(),
        });
        
        console.log(`Vendor ${vendorId}, Contact ${contactId}:`, res.status);
        await new Promise(r => setTimeout(r, 500)); // throttle
        } catch (e) {
          console.error(`Vendor ${vendorId}, Contact ${contactId}:`, e);
        }
    }
}

// === RUN FUNCTION ===

addContactsSequential();