• Jennifer BERNARD
  • NEWBIE
  • 30 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 3
    Replies

Hello everyone,

When I use the getCartItems method (https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_getCartItems_6) (with ProducFields in param) from the CommerceCart, some of the cart items have the products' fields' data set, but other don't, how come ?

Thank you in advance !

Hello everyone.

I'm trying to get all jobs records using this URL:
https://my.org.my.salesforce.com/services/data/v58.0/jobs/query

According to the documentation I should be able to get 1000 records per request by default:
https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/query_get_all_jobs.htm?q=get%20all%20jobs

But when I run the query (using Postman), I get 200 records. How can I change the number of records in the response ?
Hello, I would like to know if it's possible to retrieve Report metadata using the command sfdx force:source:retrieve ?

I tried using the following:
sfdx force:source:retrieve -m Report:FolderName/Name
sfdx force:source:retrieve -m Report:FolderName/DeveloperName

FolderName, Name and DeveloperName being the fields we can find in the Report's object. Unfortunately, my report was not found (it's a public one).

Am I missing something ?
 
Hello everyone. I can't validate Synchronize Salesforce data with an external system super badge challenge and I don't know why. I get this error after trying to validate it:  
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.
Here's my code:
public with sharing class WarehouseCalloutService implements Queueable, Database.AllowsCallouts {
    
    private static final String WAREHOUSE_URL = 'https://th-superbadge-apex.herokuapp.com/equipment';
    
    /**
	 * Queue process execution
	 */
    public static void execute(QueueableContext context){
        syncWarehouseAndSalesforceDB();
    }
    
    /**
	 * Synchronize Warehouse Data to Salesforce database. 
	 */
    public static void syncWarehouseAndSalesforceDB() {
        // Send GET request to Heroku
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint(WAREHOUSE_URL);
        request.setMethod('GET');
        
        HttpResponse response = http.send(request);
        if (response.getStatusCode() == 200) {
            // Get request result body
            List<Object> results = (List<Object>) JSON.deserializeUntyped(response.getBody());
            // Create equipments to insert
            List<Product2> equipmentsToInsertList = new List<Product2>();
            for (Object equipment :results) {
                // Parse object to String, Value map
                Map<String, Object> equipmentMap = (Map<String, Object>) equipment;
                
                Product2 equipmentToInsert = new Product2(
                    Cost__c = (Decimal) equipmentMap.get('cost'),
                    Lifespan_Months__c = (Integer) equipmentMap.get('getlifespan'),
                    Maintenance_Cycle__c = (Integer) equipmentMap.get('maintenanceperiod'),
                    Name = (String) equipmentMap.get('name'),
                    Current_Inventory__c = (Integer) equipmentMap.get('quantity'),
                    Replacement_Part__c = (Boolean) equipmentMap.get('replacement'),
                    Warehouse_SKU__c = (String) equipmentMap.get('sku')
                );
                
                equipmentsToInsertList.add(equipmentToInsert);
            }
            System.debug(equipmentsToInsertList);
            // upsert equipment
            upsert equipmentsToInsertList Warehouse_SKU__c;
        }
    }    
}
I ran this code in Execute Anonymous Window:
System.enqueueJob(new WarehouseCalloutService());
The jobs appears in the Apex Job list, it successfully ran.
I've also ran this query to make sure it worked:
// return 22 records found
SELECT COUNT() FROM Product2

The tests also run successfully. 
I've also checked that I am using the correct Playground environment for the validation.

Could someone explain to me what's wrong ?

Hello everyone !

I would like to remove all order items and their orders if ALL order items are 5 years old or older, and if their status is shipped. (both data can be found in Order Items object).

I wish to do that in one single SOQL request (entry request for a bulk job) to avoid any performance issue. Would it be possible to do so ?

For example
Order1
  |-> OrderItem1: shippingDate = 2015-01-01
  |-> OrderItem2: shippingDate = 2015-01-01
  |-> OrderItem3: shippingDate = 2019-01-01

Order2
  |-> OrderItem4: shippingDate = 2015-01-01
  |-> OrderItem5: shippingDate = 2015-01-01
  |-> OrderItem6: shippingDate = 2015-01-01

Order1 and related order items should not be deleted because at least one record is too recent.

Order2 and related orders should be deleted.

Hello everyone,

When I set mock up data in a test class, a trigger is fired and this request is sent in its process :
SOQL_EXECUTE_BEGIN [15]|Aggregations:0|SELECT id FROM Pricebook2 WHERE Name LIKE '%Standard%'
SOQL_EXECUTE_END [15]|Rows:0
But when I send this request in the Debug window I get this:
SOQL_EXECUTE_BEGIN [1]|Aggregations:0|SELECT id FROM Pricebook2 WHERE Name LIKE '%Standard%'
SOQL_EXECUTE_END [1]|Rows:1
Is it a profile issue ? Or a bug ? Or something else ? The trigger process failed because it cannot find any records from Pricebook2 table.
 

Hello everyone.

I need to create a custom RecordList table which is using a custom ListView.

In order to do that I have created a LWC using lightning-datable just like in the Apex to Work with Data unit from Trailhead (https://trailhead.salesforce.com/content/learn/modules/lightning-web-components-and-salesforce-data/use-apex-to-work-with-data).

I would like to reuse this LWC to display different Objects' records instead of creating different component for each Object. Is it possible to use ListView for so I can get the columns automatically as well ?

I am fairly new to SalesForce development, I hope I am making sense. Thanks in advance for your help. 

Hello everyone.

I'm trying to get all jobs records using this URL:
https://my.org.my.salesforce.com/services/data/v58.0/jobs/query

According to the documentation I should be able to get 1000 records per request by default:
https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/query_get_all_jobs.htm?q=get%20all%20jobs

But when I run the query (using Postman), I get 200 records. How can I change the number of records in the response ?
Hello, I would like to know if it's possible to retrieve Report metadata using the command sfdx force:source:retrieve ?

I tried using the following:
sfdx force:source:retrieve -m Report:FolderName/Name
sfdx force:source:retrieve -m Report:FolderName/DeveloperName

FolderName, Name and DeveloperName being the fields we can find in the Report's object. Unfortunately, my report was not found (it's a public one).

Am I missing something ?
 

Hello everyone !

I would like to remove all order items and their orders if ALL order items are 5 years old or older, and if their status is shipped. (both data can be found in Order Items object).

I wish to do that in one single SOQL request (entry request for a bulk job) to avoid any performance issue. Would it be possible to do so ?

For example
Order1
  |-> OrderItem1: shippingDate = 2015-01-01
  |-> OrderItem2: shippingDate = 2015-01-01
  |-> OrderItem3: shippingDate = 2019-01-01

Order2
  |-> OrderItem4: shippingDate = 2015-01-01
  |-> OrderItem5: shippingDate = 2015-01-01
  |-> OrderItem6: shippingDate = 2015-01-01

Order1 and related order items should not be deleted because at least one record is too recent.

Order2 and related orders should be deleted.