Fetch comments in product

swat.fetchListItemComments

Fetches the Comments of a given List Item

Definition

swat.fetchListItemComments(options, onSuccess, onError)

Example

Here's an example of how you can use this API to fetch Comments of a specific List Item :

// Define the opts
let options = {
	// List Id
  lid: "list-id",
  empi: 123,
  epi: 111
  // limit: 8 // Optional Limit on number of comments to return
  // sincets: timeinmilliseconds // Optional The timestamp from when returned comments should begin
  // continuation: continuationtoken // Optional Continuation token passed back in the response  
};

// Define success callback
let onSuccess = function(response) { 
  // Executed when list item comments are successfully fetched
  console.log("Successfully fetch List Item Comments", response);
}

// Define error callback
let onError = function(error) {
  // Error is an xhrObject
  console.log("Error while fetching List Item Comments", error);
}

swat.fetchListItemComments(options, onSuccess, onError);

API Parameters

ArgumentTypeDescription
optionsobjectoptions is a simple object containing config required for fetching List Item Comments
onSuccessfunctionCalled when the List Item Comments are successfully fetched.
onErrorfunctionCalled when there is an error while fetching the List Item Comments.

Success Response

The success response is a Map containing continuation token and List Item Comments

{
  "continuation": null,
  "results": [
    {
      "cid": "comment-id",
      "userinfo": {
        "em": "email-id",
        "fname": "first name",
        "lname": "last name"
      },
      "txt": "My third comment is here",
      "lid": "list-id",
      "empi": 123,
      "epi": 111,
      "cts": 145555555511
    }
  ]
}

Other References

options

ArgumentTypeRequiredDescription
opts.lidstringYesUnique id of the List to fetch Comments for
opts.empistringYesProduct master id of the List Item to fetch Comments for
opts.epistringYesProduct variant id of the List Item to fetch Comments for
opts.limitnumberoptionalNumber of Comments to fetch. Defaults to 100
opts.continuationstringoptionalContinuation token to paginate with the initial limit, returned in the response. Null when limit is not hit
opts.sincetsnumberoptionalTimestamp in milliseconds to fetch comments since

List Item Comments

Fields in List Item Comment Response

{
  "cid": "System generated comment id",
  "lid": "List id for the comment",
  "empi": "Product ID",
  "epi": "Product Variant ID",
  "txt": "Comment text",
  "via": "set as 'email' if comment received via email",
  "cby": "Created by email address",
  "uby": "Updated by email address",
  "cts": "Created at in milliseconds",
  "userinfo": {} // userinfo for the comment adder
}
ArgumentTypeRequiredDescription
cidstringYesComment id - system generated guid for the comment
lidstringYesList id - system generated guid for the list
epinumber/stringYesVariant id of the product
empinumber/stringYesProduct id of the product
viastringoptionalSet as email if comment was received via email, else undefined
txtstringYesComment content
cpropsobjectoptionalMap of custom fields
ctsnumberYesCreated time at in milliseconds
cbystringYesEmail address of the user who added the commentDefaults to 1. Quantity included for the action
userinfoobjectYesUser info of the comment adder
userinfo.emstringYesEmail address of the adder
userinfo.fnamestringYesFirst name of the adder
userinfo.lnamestringYesLast name of the adder