...
"AW Computing (AWC) handles orders in Salesforce and stores its product inventory in a field, Inventory__c, on a custom object, Product__c. When an order for a Product__c is placed, the Inventory__c field is reduced by the quantity of the order using an Apex trigger. public void reduceInventory (Id prodId, Integer qty){ Integer newInventoryAmt = getNewInventoryAmt (prodId, qty); Product__c = new Product__c(Id = prodId, Inventory__c = newInventoryAmt); Update p; // code goes here } AWC wants the real-time inventory reduction for a product to be sent to many of its external systems, including some future systems the company is currently planning. What should a developer add to the code at the placeholder to meet these requirements?
InventoryReductionEvent__e ev = new InventoryReductionEvent__e(ProductId__c = prodId, Reduction__c = qty); EventBus.publish(ev);
InventoryReductionEvent__c ev = new InventoryReductionEvent__c(ProductId__c = prodId, Reduction__c = qty); EventBus.publish(ev);
InventoryReductionEvent__e ev = new InventoryReductionEvent__e(ProductId__c = prodId, Reduction__c = qty); insert ev;
InventoryReductionEvent__c ev = new InventoryReductionEvent__c(ProductId__c = prodId, Reduction__c = qty); insert ev;
Готово! Нажмите кнопку «Результат».
Результат