• Rahul Sethi 11
  • NEWBIE
  • 20 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 1
    Replies
Please have a look at the code below: 

trigger addcontactlastname2accountname on Contact(before insert){

    Set<ID> contactid_lst = new Set<ID>();
    List<Account> account_lst = new List<Account>();
    Map<ID, Account> accountmap = new Map<ID, Account>();

    for(Contact c: Trigger.New){
        
        contactid_lst.add(c.AccountID);
    }

    account_lst = [Select ID, Name from Account where ID IN: contactid_lst];


    for(Contact c: Trigger.New){


        Account objacct = new Account();

        objacct = accountmap(account_lst).get(c.AccountID);
        
        objacct.Name = objacct.Name + '' + c.lastname;
        

    }

}
So, in my web-to-lead form code, I have an org id which is unique to my organization. But, can we add leads to multiple org using a single web-to-lead form? Does this mean that for every org, web-to-lead forms are unique? 
Now, if we delete a record type say A of Opportunity object (and we know that deleting a record type does not result in deletion of its related records), and at the time of deletion of record type A, we are replacing it with record type B. In other words, record type B, which has a completely different sales process than record type A, will store its data. I have tried it and record type B is storing the records of A. But how is that possible if both the stages are completely different?
We know that, in production environment, we cannot make changes to a class (which contains the endpoint URL). If we are trying to deploy through CHANGE SETS, the same endpoint URL will be copied to production. Now, I want to understand that, when we use www.abc.com in sandbox but while deploying it to production, the URL should change to www.xyz.com because xyz is the main url for the webservice and we are using abc URL for testing purposes.

Can we do it using custom label?
I am getting unauthorized error when trying to fetch token from a custom object. It shows correctly in Raw logs after running, but while adding it to setheader method of the Httprequest, it is throwing 401 error. If I hard code in a string, then it is working fine. But, I need to query it and then put it in the header.

public class SupplierGatewayEnrichment {
    
    public void createDataEnrichment(){
            
            List<SG_Token__c> bearer_token = [Select Token__c from SG_Token__c where createddate = TODAY limit 1];
             String token = String.valueOf(bearer_token);
              
            System.debug(token);
            
               
      //  String token2 = 'Q8e90uS-BQjb9ExORzBchScwBjgahCmbze_5mZufysMALG7k65K-nlfjJuuoBaRtiPfJYQaLzMykGtCx47BIZNWDpuqkkA6qn_uuwe23J3pXHShhL7A2AP7A_4vO1NB_D8eg9rhcZE2hdvgUZDPjUVcqWMySLXhBQ6anv6XF5P1_1aWCZmGObVKop5nYJGxB0Ril3gTvYWGonRFlVAMImPVVByFJvGAh-Cmm_atvvU1qN8PJr8hIU_goaR5i8tdMPxV-ukFrHiWaOqgJ790VWQBbsV2cvjVJTsqqy6CRlNc2dEDk5ZuvgAtoIdR0zQBIovhfu2y53CbyuLnS0PBBiV81zHEK0s-QKRTCsh1iE8Wx1ujkjYddqYeICqpNFLMOdKMsLbVIw7v0hmO0_MKA3O-wiSoRvYptLHsR36dB2QIvsgF0ayt55Er0dAj9hRLtqJ_tmmsAYj7ujDo9GjQfGvuf480ORPIe8_Np6Hp9i-_86vNFF6CpQ';
       //        System.debug(token2);
            Http http = new Http();
              HttpRequest request = new HttpRequest();
              request.setEndpoint('https://qa.suppliergateway.com:8446/v1/api/dataenrichment/jobs');
               request.setMethod('POST');
               request.setHeader('Authorization', 'Bearer '+ token);
            request.setHeader('Content-Type', 'application/json;charset=UTF-8');
            request.setBody('{ "jobdesc": ""}');
            
            HttpResponse response = new HttpResponse();
            response = http.send(request);
        
              if(response.getStatusCode() == 200){
                System.debug('Successful Data Enrichment Job ID::' + response);
                
                // Deserializes the JSON string
                SGEnrichment_Wrapper parsedJSON = SGEnrichment_Wrapper.parse(response.getBody());
                String final_jobid = parsedJSON.Job.jobid;
               
                
                    SGEnrichment__c enrichment = new SGEnrichment__c();
                    enrichment.JobID__c    = final_jobid;
                    insert enrichment;
                    }
                            else{
                    
                System.debug('Not Ok! Data Enrichment Job ID::' + response);    
            
            }
        }

    }