0

Im using a rest api for getting orders from a webshop, the result is max 100 orders at a time and there is a page param to use for next 100 orders.

I have solve this in a viewmodel using periodic action (disables = not self.oclIsIn(#InProgress)) like this:

vCount := self.Orders->size;
vPage := vPage + 1;

vResponse := selfVM.RestGet(
String.Format('{0}/wp-json/wc/v3/orders?per_page={1}&page={2}',self.Channel.Url, self.Channel.Source.MaxCount, vPage),
self.Channel.UserName,
self.Channel.Password,'');


vResponse := String.Format('{0}{1}{2}','{"orders":', vResponse,'}');

--self.JSonData := self.JSonData + vResponse;

vOutput := vOutput +  self.MergeTaJson( ImportBatch.Viewmodels.WooOrderJSon, vResponse );

if ((self.Orders->size - vCount) = 0) then
  if vOutput->IsNullOrWhiteSpace then
    self.Fail
  else
   --self.ParsingLog := vOutput;
    self.Success
  endif;
  true
else
  vCount := self.Orders->size;
  false
endif

It will go on and on until result from the api is 0 then state sets to Done and it stops.

Now I want to do the same server side, but how do I solve this without a periodic action like this? And I want to do the same in a AsyncTicket "action".

1 Answers1

1

Is it possible for you to see the whole serverside job as a periodic action?

Each execution of a SS job should fit in "one go" and saved in one transaction

Lars
  • 191
  • 4