2

I am writing a simple job that fetches the order status from external service. Then I want to use this data to update the order.

Whenever I call a static method getOrder(id : String) on the OrderMgr I receive null.

The order with given ID exists and is visible in BM.

Can someone advise me what am I doing incorrectly?

importPackage(dw.order);

function execute( pdict : PipelineDictionary  ) : Number
{   
    var mgr : OrderMgr = OrderMgr;
    var logH : Logger = Logger.getLogger("test1", "test1");
    var order : Order = mgr.getOrder("00000101");
    if (order == null){
        // always null, even if the order exists
        logH.info("The order is null");
    }
    return PIPELET_NEXT;

}

2 Answers2

3

Check in scope of what site you are running the job. If it’s in Organization scope, you have to change to the site scope. Second when you will do update, don’t forget to use Transactions.

Oleg Sapishchuk
  • 667
  • 6
  • 18
  • 1
    I’d also add that you seem to be writing a pipelet script which is the older way to build a job. You should probably build a custom Job Component instead. (For any new jobs at least) – sholsinger Feb 28 '19 at 14:03
0

I think you need to use getOrder() method from a batch job in dw business manager, there are some scripts that does not allow you to call them from storefront

Alex MAN
  • 111
  • 1
  • 6