• AnantGarg
  • NEWBIE
  • 35 Points
  • Member since 2018


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 7
    Replies
What's the specific reason for not having an UPDATE query option in SOQL? 
We know there are many limitations of SQL over data limit, though a direct UPDATE operation on a table is allowed there. Like -  UPDATE TABLE TABLE_NAME, though in case of SOQL we need to first prepare the sObject then update its index.
I have an Org with 'Person account' enable onto it and I am working with Salesforce API to create/update person account record. I am sending some data in 'PersonAssistantName' and getting an error in response stating "No such column 'PersonAssistantName' on sObject of type Account". Though this field does exist in my Org. Please assist
I am trying to create a reduction order for an already created order. Though reduction order is being created successfully, it is returning this error:

Refund Order Error: field integrity exception: OriginalOrderId (reduction orders may not reference other reduction orders for reduction)

I have correctly passed the required parameters as:

   
Order reductionOrder = new Order(
    IsReductionOrder = true,
    OriginalOrderId = originalOrder.Id,
    Pricebook2Id = originalOrder.Pricebook2Id,
    EffectiveDate = originalOrder.EffectiveDate,
    Status = 'Draft',
    AccountId = originalOrder.AccountId);

    insert reductionOrder;

Why do I get this error? How can I fix it?

The original order is not a reduction order though
User-added image
I am here working on 'Product2' sObject where I have created a custom field mynamespace__post_id__c. Now with a piece of code, I am trying to update this post id. For a short brief of it please see the code.
productId = '01t0v000003SFQYAA4';
list<Product2> pro = [Select Id, Name, IsActive ,mynamespace__post_parent__r.mynamespace__post_id__c,(Select Id,Pricebook2Id,UnitPrice from PricebookEntries),mynamespace__post_id__c from product2 where Id =:productId];
        string postId = 20; 
        pro[0].mynamespace__post_id__c = Integer.valueOf(wooId.trim());
        try {
              List<Database.SaveResult> updateResults = Database.update(pro, true);
              System.debug(updateResults); // This is giving result as (Database.SaveResult[getErrors=();getId=01t0v000003SFQYAA4;isSuccess=true;])
        } catch (Exception e) {
              System.debug('exception in product update: '+e.getMessage());
        }
Now as the try block is showing isSuccess as true, the object is not getting updated. Also, the log is showing up a FATAL_ERROR. Can anyone help out where am I going wrong  
A similar question (https://success.salesforce.com/answers?id=9063A000000lJbWQAU#!/feedtype=SINGLE_QUESTION_SEARCH_RESULT&id=90630000000hU7uAAE" target="_blank) has been asked earlier, though I am still confused with some use case:

1. Salesforce allows order creation without adding any product into it. I am unable to get a real life example where we create an order without adding any product/service/contract into it. Maybe I am thinking in particular e-commerce scenario only that's why I am unable to think any use case for it.

One of the answer by @Cheryl Feldman (https://success.salesforce.com/profile?u=00530000003TRBy" target="_blank) there states an example of transactional order for a change in billing or billing contact. Should that be counted in order?

2. While creating a reduction order I faced this confusion. Let me elaborate. I created order and added product P1 with quantity '3' into it. Now while creating reduction I am only allowed to reduce this order up to '3' quantity, which is ok. Though after making a reduction order with '3' quantity, I am able to again create a new reduction order with up to '3' quantity. In general e-commerce scenario if a complete order is reduced/refunded then it can not be refunded again and again. Is there a use case for this in Salesforce on how it reduces an order even after complete reduction?
Using REST API, I am trying to insert/update a contact into my business org, though in response I am getting this error message 'Cannot deserialize instance of MailingAddress from VALUE_STRING', the same response also resulting for 'OtherAddress'.

To my understanding, I think this is due to the reason that 'MailingAddress' and 'OtherAddress' are not actual fields that contains some String data, rather they take a dynamic address which resulting in filling up all other related fields like - 'MailingCity, MailingStreet, etc'.
So I have 2 questions:
1. How can I set 'MailingAddress'  and 'OtherAddress' fields if I want to using API parameter only?
2. Is there any manual/documentation for this reference? As I am also having trouble with 'OtherLatitude' and 'OtherLogitude' fields.
I have an Org with 'Person account' enable onto it and I am working with Salesforce API to create/update person account record. I am sending some data in 'PersonAssistantName' and getting an error in response stating "No such column 'PersonAssistantName' on sObject of type Account". Though this field does exist in my Org. Please assist
I am trying to create a reduction order for an already created order. Though reduction order is being created successfully, it is returning this error:

Refund Order Error: field integrity exception: OriginalOrderId (reduction orders may not reference other reduction orders for reduction)

I have correctly passed the required parameters as:

   
Order reductionOrder = new Order(
    IsReductionOrder = true,
    OriginalOrderId = originalOrder.Id,
    Pricebook2Id = originalOrder.Pricebook2Id,
    EffectiveDate = originalOrder.EffectiveDate,
    Status = 'Draft',
    AccountId = originalOrder.AccountId);

    insert reductionOrder;

Why do I get this error? How can I fix it?

The original order is not a reduction order though
User-added image
Using REST API, I am trying to insert/update a contact into my business org, though in response I am getting this error message 'Cannot deserialize instance of MailingAddress from VALUE_STRING', the same response also resulting for 'OtherAddress'.

To my understanding, I think this is due to the reason that 'MailingAddress' and 'OtherAddress' are not actual fields that contains some String data, rather they take a dynamic address which resulting in filling up all other related fields like - 'MailingCity, MailingStreet, etc'.
So I have 2 questions:
1. How can I set 'MailingAddress'  and 'OtherAddress' fields if I want to using API parameter only?
2. Is there any manual/documentation for this reference? As I am also having trouble with 'OtherLatitude' and 'OtherLogitude' fields.
Challenge Not yet complete... here's what's wrong: 
The runWarehouseEquipmentSync method does not appear to have run successfully. Could not find a successfully completed @future job for this method. Make sure that you run this method at least one before attempting this challenge. Since this method is annotated with the @future method, you may want to wait for a few seconds to ensure that it has processed successfully.

here is my code

public with sharing class WarehouseCalloutService {
    
    private static final String WAREHOUSE_URL = 'https://th-superbadge-apex.herokuapp.com/equipment';
    @future(callout=true)
    // complete this method to make the callout (using @future) to the
    // REST endpoint and update equipment on hand.
    public static void runWarehouseEquipmentSync(){
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint(WAREHOUSE_URL);
        request.setMethod('GET');
        HttpResponse response = http.send(request);
        // If the request is successful, parse the JSON response.
        String ret = '';
        if (response.getStatusCode() == 200) {
            // Deserialize the JSON string into collections of primitive data types.
            List<Object> results = (List<Object>) JSON.deserializeUntyped(response.getBody());
            
            List<Product2> LstProduct = new List<Product2>();
            for(Object obj : results)
            { 
                Map<String, Object> mapobj = (Map<String, Object>)obj;
                Product2 product = new Product2();
                           
                Integer maintenanceperiod = (Integer)mapobj.get('maintenanceperiod');               
                Integer Lifespan = (Integer)mapobj.get('lifespan');
                Integer Cost = (Integer)mapobj.get('cost');
                Boolean replacement = (Boolean)mapobj.get('replacement');
                Integer quantity = ((Integer)mapobj.get('qIntegerntity'));
                product.Name  = (String)mapobj.get('name'); 
                product.Maintenance_Cycle__c = Integer.valueof(maintenanceperiod);
                product.Cost__c = Cost;
                product.Current_Inventory__c = quantity;
                product.Lifespan_Months__c = Lifespan; 
                product.Replacement_Part__c = replacement;
                product.Warehouse_SKU__c = (String) mapobj.get('sku');
                product.ProductCode = (String)mapobj.get('_id');       
                LstProduct.add(product);
            }
            
            System.debug(LstProduct);
             upsert LstProduct Warehouse_SKU__c;
        
        }
        
       
    }
}
Automate record creation
Install the unmanaged package for the schema and stubs for Apex classes and triggers. Rename cases and products to match the HowWeRoll schema, and assign all profiles to the custom HowWeRoll page layouts for those objects. Use the included package content to automatically create a Routine Maintenance request every time a maintenance request of type Repair or Routine Maintenance is updated to Closed. Follow the specifications and naming conventions outlined in the business requirements.
how to achieved ?
public class ContactAndLeadSearch {
public static List<List<SObject>> searchContactsAndLeads(string FN)
{
    List<List<sObject>> searchList = [FIND 'FN' IN all fields 
RETURNING Contact(FirstName,LastName) ,Lead(FirstName,Lastname)];
//Contact[] searchContacts = (Contact[])searchList[0];
//Lead[] searchLeads = (Lead[])searchList[1];
return searchList;
   

}
}

Please someone correct this code ,, this one was nt fulfilling the challenge req.