• Atul Pandey 4
  • 0 Points
  • Member since 2016

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 1
  • 2
I am New in SFDC development, i have written an apex batch class for webservice callout. please suggest me how can i write the test class for below class.
global class CoDoc implements Database.Batchable, Database.AllowsCallouts {
global final String QODoc; global final String CMOOId; global final boolean V; global final boolean R; global CoDoc( String QODoc , String CMOOId , Boolean V , Boolean R ) { this.QODoc = QODoc; this.CMOOId = CMOOId; this.V = V; this.R = R; } global Database.QueryLocator start(Database.BatchableContext BC){ return Database.getQueryLocator(QODoc); } global void execute(Database.BatchableContext BC, List<sObject> scope){ List <Cust> CMO = [SELECT Id ,OpNumber__c ,R_No__c ,V_No__c FROM Cust WHERE id = :CMOOId ]; String EndPoingtUrl = Label.EndPointURL; String APIKey = Label.API_Key; if( V== true && R == false ) { for(Sobject sObj : scope) { Document__c Doc = (Document__c)sObj; Integer countL = Doc.Name.Length()- Doc.Name.replace('_','').Length(); String newName = CMO[0].OpNumber__c +'_V'+ CMO[0].V_No__c +'_R'+ CMO[0].R_No__c +'_'+ Doc.Name.split('_',countL).get(countL-1); Http h = new Http(); HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); req.setEndpoint(EndPoingtUrl+Doc.TId__c+'?api_key='+APIKey); req.setMethod('GET'); req.setHeader('Accept', 'application/json'); res = h.send(req); //Server has send the Response if( res.getStatusCode() == 200 && !String.isEmpty( res.getBody()) ){ String resBody = res.getBody(); Map< String , Ids__c > IdsMap = Ids__c.getall(); for( String templateIsStr : IdsMap.keySet() ) { if( resBody.contains(templateIsStr) ){ //Instantiate a new HTTP object Http http = new Http(); //Instantiate a new http request, specify the method (POST) as well as the endpoint HttpRequest req1 = new HttpRequest(); HttpResponse res1 = new HttpResponse(); req1.setBody('{"p":{"n": "'+newName+'","int_id":"'+CMO[0].Id+'"}}'); req1.setEndpoint(EndPoingtUrl+Doc.TId__c+'/duplicate?api_key='+APIKey); req1.setMethod('POST'); req1.setHeader('Content-Type', 'application/json ;charset=UTF-8'); req1.setHeader('Accept', 'application/json'); req1.setTimeOut(60000); res1 = http.send(req1); } } } } } } global void finish(Database.BatchableContext BC){ }

Would someone be able to help me write a trigger so that when an account address and phone number change, the address and phone number on all contacts change?  In my perfect world, the phone number would only change on the contact IF before the update they were the same number.  Since I am not a code writer other than when I have to be, I am not sure that is even possible.




  • August 23, 2012
  • Like
  • 0

what is the difference between "Trigger.New" and "Trigger.old"?

  • December 22, 2010
  • Like
  • 0
Hi All,

I am first time using javascript and i am new to salesforce too.So please help me to know where i am going wrong.

My Requirement is Onclick of checkbox a textfield should appear that too using only javascript not the controller class.I will be sharing my code here.Please helpme out with solutions.If you have some examples of javascript vfpage please do share it.It would be very beneficial to learn the things.Thanks in advance.
<apex:page standardController="contact" >
  <apex:form >
    <apex:pageBlock title="Javascript Example">
     <apex:pageBlockSection title="Checkbox Example"> 
      <apex:inputCheckbox id="cc" value="{!contact.Check_Me__c}" label="Do not call" onclick="tt(this,'{!$Component.ii}'})"/>
      <apex:inputField id="ii" value="{!contact.Languages__c}" />
     function tt(input,txt)