Javascript Example Script: Show listings with too long attribute values

Attribute values in the item specifics area for usual are limited to 65 characters but sometimes you have entered more. Below you find a script that displays listings with too long attribute values.

Feel free to modify and improve it to fit your needs.

Disclaimer:

  • You might want to test this script with one single listing first.
  • There’s no undo function.

More about GarageSale’s javascript feature

// This script finds attribute values longer than the allowed 65 character limit 
function run() {
	var arr = [];
	for (const listing of selectedListings) {
		for (const key in listing.attributes) {
			const value = listing.attributes[key];
			if (String(value).length > 65) {
				consoleLog("Attribute '" + key + "' has more than 65 characters! (Listing: " + listing.title + "; item ID: " + listing.itemID + ")" );
   				arr.push(listing);
   			}
   		}
	}
	showListings(arr, "These listings have attribute values longer than 65 characters:");
}

To use this script open GarageSale’s script editor, click the + button and paste the script. Select one or more listings in GarageSale’s main window, then click the “Run” button in script editor.

1 Like

This can be very useful, as I have found that auto-populated attributes often go over the 65-character limit [title of a movie or book or a review for example].

Two questions: Can this script be modified to remove everything past 65 characters?

When auto-populating the fields via the Product search feature, can they simply honor the 65 character limit? Eg: make the fields themselves not allow input past 65 characters. The title of an eBay listing, for example, has an 80 character limit and the app won’t allow you to accidentally type more than 80 characters. Similar to leaving others feedback - you have that set to not accept longer than 500 characters. Can the 65 character fields be made to not accept input past 65 characters?

Thanks.

Here you go:

// This script cuts off attribute values longer than the allowed 65 character limit 
function run() {
	var arr = [];
	for (const listing of selectedListings) {
		for (const key in listing.attributes) {
			const attrbts = listing.attributes;
			if (String(attrbts[key]).length > 65) {
				attrbts[key] = String(attrbts[key]).substr(0,65);
				listing.attributes = attrbts;
				consoleLog("Attribute '" + key + "' had more than 65 characters! (Listing: " + listing.title + "; item ID: " + listing.itemID + ")" );
   			}
   		}
	}
}

Thank you! This is a good workaround for the auto-populated fields that GS fills in that go above 65 characters. Though it won’t stop GS from filling in more than 65 characters nor does it stop the user from doing that manually. GS does do this for the listing title and feedback text. Is there any chance of this feature coming in a future version? Thanks again!

Yes I agree, this would be very useful. Sometimes automatically cutting the text that exceed the limit is unsafe. In my listings, generally the “condition” field exceeds the limit and if I cut its text, I risk to omit important information of item’s condition. The solution of automatically limiting text characters (like in title field) is much safer.

1 Like