Synchronize Salesforce Data With An External System | Apex Specialist Superbadge

Поделиться
HTML-код
  • Опубликовано: 12 дек 2024

Комментарии • 24

  • @milantiwari
    @milantiwari 6 месяцев назад +3

    Challenge Not yet complete... here's what's wrong:
    The WarehouseCalloutService class does not appear to have run successfully as the equipment records are not found in the database. The REST endpoint returns 22 records so your org should have at least 22 records in the Product2 table. Make sure that you successfully run this class at least once before attempting this challenge. Since this class is implementing the queueable interface, you may want to wait to ensure that it has processed successfully.

  • @Gopesh0000
    @Gopesh0000 2 месяца назад +1

  • @sivaparvathiinti474
    @sivaparvathiinti474 Год назад +1

    Bro I am getting like this -- "Class WarehouseCalloutService must implement the Queueable interface."

    • @Anu1901
      @Anu1901 Год назад

      I AM ALSO GETTING THE SAME ERROR WHAT TO DO
      PLEASE REPLY

    • @killarmass6092
      @killarmass6092 10 месяцев назад

      first save all and try again@@Anu1901

    • @tajkunwar7828
      @tajkunwar7828 3 месяца назад +1

      Since you’re using a Queueable job, the @future annotation is not needed. The Queueable job itself handles asynchronous processing. - Remove @future

  • @YourCoddingBuddy
    @YourCoddingBuddy  Год назад +6

    Remote Site Name - WarehouseURL
    Remote Site URL - th-superbadge-apex.herokuapp.com
    ********************* WarehouseCalloutService class ***********************
    public with sharing class WarehouseCalloutService implements Queueable {
    private static final String WAREHOUSE_URL = 'th-superbadge-apex.herokuapp.com/equipment';

    //class that makes a REST callout to an external warehouse system to get a list of equipment that needs to be updated.
    //The callout’s JSON response returns the equipment records that you upsert in Salesforce.

    @future(callout=true)
    public static void runWarehouseEquipmentSync(){
    Http http = new Http();
    HttpRequest request = new HttpRequest();

    request.setEndpoint(WAREHOUSE_URL);
    request.setMethod('GET');
    HttpResponse response = http.send(request);

    List warehouseEq = new List();

    if (response.getStatusCode() == 200){
    List jsonResponse = (List)JSON.deserializeUntyped(response.getBody());
    System.debug(response.getBody());

    //class maps the following fields: replacement part (always true), cost, current inventory, lifespan, maintenance cycle, and warehouse SKU
    //warehouse SKU will be external ID for identifying which equipment records to update within Salesforce
    for (Object eq : jsonResponse){
    Map mapJson = (Map)eq;
    Product2 myEq = new Product2();
    myEq.Replacement_Part__c = (Boolean) mapJson.get('replacement');
    myEq.Name = (String) mapJson.get('name');
    myEq.Maintenance_Cycle__c = (Integer) mapJson.get('maintenanceperiod');
    myEq.Lifespan_Months__c = (Integer) mapJson.get('lifespan');
    myEq.Cost__c = (Integer) mapJson.get('cost');
    myEq.Warehouse_SKU__c = (String) mapJson.get('sku');
    myEq.Current_Inventory__c = (Double) mapJson.get('quantity');
    myEq.ProductCode = (String) mapJson.get('_id');
    warehouseEq.add(myEq);
    }

    if (warehouseEq.size() > 0){
    upsert warehouseEq;
    System.debug('Your equipment was synced with the warehouse one');
    }
    }
    }

    public static void execute (QueueableContext context){
    runWarehouseEquipmentSync();
    }

    }
    ******************************** Code Runned Under Anonymous Window ****************************
    System.enqueue Job (new warehousecallout Service());

    • @zo2687
      @zo2687 Год назад +1

      you should pin this on the top

    • @RTechVlog
      @RTechVlog Год назад

      Corrected Code Runned Under Anonymous Window : System.enqueueJob(new warehousecalloutService());

    • @thenomadfoodie219
      @thenomadfoodie219 Год назад

      bro spacing ka error aa rha h, video me execution code of comment me alag h

    • @yashwankhade2239
      @yashwankhade2239 Год назад

      ****************************** Code Runned Under Anonymous Window **************************
      System.enqueueJob(new warehousecalloutService());

    • @bhargavishamala7637
      @bhargavishamala7637 Год назад

      😊

  • @srikanthtalks4877
    @srikanthtalks4877 Год назад +1

    bro please provide code