Search code examples
demandware

OrderMgr getOrder() method always return null


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;

}

Solution

  • 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.