Anyone know of a non-manual way to set image alt t...
# suitecommerce
l
Anyone know of a non-manual way to set image alt tags for SuiteCommerce product images?
p
webservices expose the alt field.
l
Thank you Pablo, will look into that. Can't find a way in SuiteScript.
j
@LMG I’ve done it with SuiteScript. Here’s an abbreviated version of what I’ve done:
Copy code
var itemParentItem = nRecord.load({
	type: nRecord.Type.INVENTORY_ITEM,
	id: internalid,
	isDynamic: true
});

var invImagesCount = itemParentItem.getLineCount({
	sublistId: 'itemimages'
});

try {

	if (invImagesCount > 0) {

		for (var j = 0; j < invImagesCount; j++) {

			var imageName = itemParentItem.getSublistValue({
				sublistId: 'itemimages',
				fieldId: 'name',
				line: j,
			}) || '';

			var imageAltCaption = itemParentItem.getSublistValue({
				sublistId: 'itemimages',
				fieldId: 'altTagCaption',
				line: j
			}) || '';

			try {

				if (!!!imageAltCaption && imageAltCaption !== ' ') {

					//getCaption is just a custom function that I wrote to get data that
					//I put into the file name of the image because I find it easier to set
					//the alt tags in my filesystem than in NetSuite
					
					imageAltCaption = getCaption(imageName);

					itemParentItem.selectLine({
						sublistId: 'itemimages',
						line: j
					});

					itemParentItem.setCurrentSublistValue({
						sublistId: 'itemimages',
						fieldId: 'altTagCaption',
						value: imageAltCaption
					});

					itemParentItem.commitLine({sublistId: 'itemimages'});
				}

			} catch (e) {
				nLog.error({title: 'item caption error', details: JSON.stringify(e)});
				nLog.error({title: 'item caption error name', details: imageName});
			}

		}
	}

} catch (e) {
	nLog.error({title: 'parent image error', details: JSON.stringify(e)});
}
I’m triggering it in a larger map/reduce script that does a few other item data things, but I imagine you could put it into a user event.
🙂 1
p
Copy code
altTagCaption
😮 today i learned!
l
Great, thank you! Didn't realize that sublist was editable via SS, had only been trying to update it on the image file itself.
a
SuiteCommerceDev portal says to refer to image_default.txt
j
So, for those of you keeping score at home, that’s @PabloZ: 2,498, Me: 1
p
😂
I’ve learn a few more things from you than just this!
fakenews 1