Index

Executing Scripts After Listings are Added, Revised or Relisted

By using the functions listingAdded(), listingRevised() or listingRelisted() you can run your own javascript when your listing was successfully started, revised and relisted, respectively.

Select your script in the “Validate Listing with Script” menu in Launch Control.

Validate Listings RevisedRelistedAdded

Here’s a sample script that will add a count in the User Properties section for each successful revise, relist and addItem:

function validateListing(listing) {
    // not used but should be implemented in the validate script
    return [];
}

function incrementKeyInUserProperties(listing, key) {
    var userProps = listing.userProperties;
    let count = parseInt(userProps[key]);
    if (count == null || isNaN(count)) {
        userProps[key] = "1";
    } else {
        userProps[key] = (count + 1).toString();
    }
    listing.userProperties = userProps;
}

function listingAdded(listing) {
    incrementKeyInUserProperties(listing, "ADDED_COUNT");
}

function listingRelisted(listing) {
    incrementKeyInUserProperties(listing, "RELISTED_COUNT");
}

function listingRevised(listing) {
    incrementKeyInUserProperties(listing, "REVISED_COUNT");
}


<< Validating scripts when launching listings eBay Listing JavaScript properties >>