• Rakesh Bachhav
  • NEWBIE
  • 10 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies
Create a process builder on Contact object that will call the flow to pull all opportunities related to account and clone those opportunities on contact also delete existing opportunities on that contact if any exists.?
Create a process builder on Contact object that will call the flow to pull all opportunities related to account and clone those opportunities on contact also delete existing opportunities on that contact if any exists.?
Hello community!  I have a REST Post callout that is fired from a trigger.  I am passing three parameters from that trigger into the callout method.  I am having trouble writing a text class for this callout.  Any help or suggestions are welcomed.  Thanks in advance for your time and knowledge!

HERE IS THE CLASS:

public class RESTCallout {
    @future (callout=true)
    public static void makePostCallout(string taskType, string orderNumber, string siteId) {
       
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        String authorizationHeader = 'BASIC' + 'somecredential';
        String endpoint = 'http://api.website.com/api2/rest/v1/order/'+orderNumber+'/communication/'+siteId;
        System.debug(endpoint);
        
        request.setEndpoint(endpoint);
        request.setMethod('POST');
        request.setHeader('Content-Type', 'application/json;charset=UTF-8');
        request.setHeader('Authorization', authorizationHeader);
        
        JSONGenerator gen = JSON.createGenerator(true);    
        gen.writeStartObject();      
        gen.writeStringField('communicationType', taskType);
        gen.writeEndObject();    
        String jsonS = gen.getAsString();
        System.debug('jsonMaterials'+jsonS);
        
        request.setBody(jsonS);
        HttpResponse response = http.send(request);
       
        if (response.getStatusCode() != 200) {
            System.debug('The status code returned was not expected: ' +
            response.getStatusCode() + ' ' + response.getStatus());
        } else {
            System.debug(response.getBody());
        }
    }
}

HERE IS THE TRIGGER:

trigger PostToFulfillment on Task (after update, after insert) {
    
        Set<Id> caseIdSet = new Set<Id>();

    for(Task t: Trigger.new) {
        If(t.whatId != null && t.whatId.getsObjectType() == Case.sObjectType ){
            caseIdSet.add(t.whatId);
        }       
    }

    if(!caseIdSet.isEmpty()) {
        Map<Id, Case> caseMap = new Map<Id, Case>([Select Id, RecordType.DeveloperName, RecordTypeId, Order_Number__c, Type, Site_ID__c, Status from Case where Id =: caseIdSet]);
        for(Task t: Trigger.new) {
            If(t.whatId.getsObjectType() == Case.sObjectType){
                Case c = caseMap.get(t.whatId);
                if(c != null && t.Status == 'Completed' && c.RecordType.DeveloperName == 'eConnect') {
                    eConnTaskRESTCallout.makePostCallout(t.Type, c.Order_Number__c, c.Site_ID__c);
                }
            }
        }
    }    
}
Hi,

I need some info regarding integration error logs in salesforce
Scenario, we are integrating the account records from external system to salesforce by using Rest or Soap API. 
In SFDC side we are not doing any integration, this is something like inbound integration from external system to SFDC

My Question is: How we will get the error logs in SFDC side while inserting the data from external system.

Please suggest your solution or guidance on this.
Thanks in advance…
 
Hello,

This is the trailhead questions which I am trying to solve :

Create an Apex class that returns an array (or list) of formatted strings ('Test 0', 'Test 1', ...). The length of the array is determined by an integer parameter.The Apex class must be called 'StringArrayTest' and be in the public scope.
The Apex class must have a public static method called 'generateStringArray'.
The 'generateStringArray' method must return an array (or list) of strings. Each string must have a value in the format 'Test n' where n is the index of the current string in the array. The number of returned strings is specified by the integer parameter to the 'generateStringArray' method.


Here is my code :

public class StringArrayTest {
    public static List <String> generateStringArray (Integer n) {
       List<String> List1 = new List<String> ();
        for(Integer i=0;i<n;i++) {
          List1.add('\'Test'+ i+'\'' );
  }
        System.debug(List1);
        return List1;
    } 

}


I am getting following error :

Challenge not yet complete... here's what's wrong: 
Executing the 'generateStringArray' method failed. Either the method does not exist, is not static, or does not return the proper number of strings.


I tried it many times but I am not able to solve this problem. Please help.