A quick code snippet for you today, if you want to cancel all UPS shipments that have not been picked up.
Here is the code to run in Developer Console:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String queryString = 'SELECT ' + 'Id,Name, zkups__UPSShipmatePreference__c, zkups__MasterTrackingId__c, zkups__ShipmentProcessingCompleted__c, ' + | |
'zkups__SsProcessReturnShipment__c, zkups__ServiceType__c, zkups__SenderState__c, zkups__SenderCountry__c, zkups__SenderName__c, ' + | |
'zkups__RecipientState__c, zkups__RecipientCountry__c, zkups__ShipmentDeleted__c, zkups__Delivered__c, zkups__StatusDescription__c, zkups__ModKey__c ' + | |
'FROM zkups__UPSShipment__c WHERE Name <= \'UPS-Shipment-0000001000\' and zkups__StatusDescription__c like \'%BILLING INFORMATION RECEIVED\' and zkups__Delivered__c = false and zkups__ShipmentDeleted__c = false' ; | |
Integer recordCount = 1; | |
zkups.ShipmentInterface.startMassShipmentCancelBatch(queryString, recordCount); |
Line 4 determines the shipments we want to set as cancelled. For this snippet we have decided to cancel all shipments older than UPS-Shipment-0000001000.
Line 7 then uses our startMassShipmentCancelBatch process that goes through all the shipments and cancels them.
Please contact us if you have any questions and we will be glad to help.