Paul Gregson
Paul Gregson

Reputation: 166

Netsuite: Server-side code not firing for csv uploads?

I created a script and deployed it to automatically populate web store fields when new inventory items are created in our system.

The code works when a new item is created through the interface, but does not when a new item is uploaded via csv.

This is the code:

function userEventAfterSubmit(type) {
if (type == 'create') {
    var newItem = nlapiLoadRecord('inventoryitem', nlapiGetNewRecord().getId());
    var storeDisplayImage = nlapiGetFieldValue('storedisplayimage');
    if (storeDisplayImage == '' || storeDisplayImage == null)
        newItem.setFieldValue('storedisplayimage', 620128);
    var storeDisplayThumbnail = nlapiGetFieldValue('storedisplaythumbnail');
    if (storeDisplayThumbnail == '' || storeDisplayThumbnail == null)
        newItem.setFieldValue('storedisplaythumbnail', 620127);
    var urlComponent = nlapiGetFieldValue('urlcomponent');
    if (urlComponent == '' || urlComponent == null)
        newItem.setFieldValue('urlcomponent', nlapiGetFieldValue('storedisplayname'));
    var pageTitle = nlapiGetFieldValue('pagetitle');
    if (pageTitle == '' || pageTitle == null)
        newItem.setFieldValue('pagetitle', nlapiGetFieldValue('storedisplayname'));
    var storeDescription = nlapiGetFieldValue('storedescription');
    if (storeDescription == '' || storeDescription == null)
        newItem.setFieldValue('storedescription', nlapiGetFieldValue('salesdescription'));
    var storeDetailedDescription = nlapiGetFieldValue('storedetaileddescription');
    if (storeDetailedDescription == '' || storeDetailedDescription == null)
        newItem.setFieldValue('storedetaileddescription', nlapiGetFieldValue('salesdescription'));
    var metaTagHtml = nlapiGetFieldValue('metataghtml');
    if (metaTagHtml == '' || metaTagHtml == null)
        newItem.setFieldValue('metataghtml', '<meta name="description" content="' + nlapiGetFieldValue('salesdescription') + '">');
    nlapiSubmitRecord(newItem);
}

}

And then this function is called as the "After Submit Function". Am I not calling in this in the right place for it to run for csv uploads?

This is my script deployment: enter image description here

Upvotes: 1

Views: 796

Answers (1)

prasun
prasun

Reputation: 7343

  1. Goto "Setup > Import/Export > CSV Import preferences"
  2. Make sure " RUN SERVER SUITESCRIPT AND TRIGGER WORKFLOWS" is checked.

Upvotes: 5

Related Questions