Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

If you're trying to use a Feeder Logic to emit items to a dataloaderData Load, you'll notice that the "Incremental" tickbox checkbox has no effect by default.

Setting this tickbox checkbox does, however, set some properties, which can then be used for emitting items which are more recently updated than the incremental date.

For an example on how to use incremental with a datafeederData Feed, see below code snippet, which will emit all PricelistItemsprice list items, sorted by most recent update date, from pricelist the price list ID 999:

Paste code macro
languagegroovy

feedObjects("PLI", Filter.equal("pricelistId", 999), "-lastUpdateDate")

void feedObjects(String typeCode, Filter filter = null, String sortBy = null, Boolean supportIncremental = true) {
  List<Number> ids = getObjectIds(typeCode, filter, sortBy, supportIncremental)
  for (id in ids) {
    api.emitPersistedObject(typeCode, id)
  }
}

List<Number> getObjectIds(String typeCode, Filter filter = null, String sortBy = null, Boolean supportIncremental = true){
  if(supportIncremental)
    filter = getIncrementalFilter(filter)

  def stream = api.stream(typeCode, sortBy ?: "-lastUpdateDate", ["id"], filter)
  List<Number> ids = stream?.collect { it.id }
  stream?.close()
  return ids
}

Filter getIncrementalFilter(Filter filter = null){
  if (api.currentItem("incremental") as Boolean) {
    Filter timeFilter = Filter.greaterOrEqual("lastUpdateDate", api.currentItem("incCalculationDate") ?: api.currentItem("incLoadDate"))

    if (filter)
      filter = Filter.and(filter, timeFilter)
    else
      filter = timeFilter
  }
  return filter
}

...