• prasanth sfdc
  • NEWBIE
  • 40 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 14
    Replies
Hi,
  I am displaying map in lightning component using lightning:map tag. on click of the address at the left side i am not able to get the address information in javscript controller.  Please help me to sort this. 
 
<lightning:map mapMarkers="{!v.mapMarkers}" zoomLevel="{!v.zoomLevel}"  onclick="{!c.onclickofMap}" />
 
onclickofMap:function(component,event,helper)
    {
      //  alert('The event is:'+JSON.stringify(event));
       // var locationNameVal =  event.getParam("v.value");
      //  var temp =  component.find("mapvals").get("v.value");      
        //  var id = event.currentTarget.dataset.id; //it will return thisDiv
  //  var getTargetedButton = component.find(id); //it will return the source button

        var res = null ;
        var oTarget = event.target ;
        if (oTarget.attributes[title] != null)
        {  
            alert('The oTarget is:' +oTarget);
            res = oTarget.attributes[title].value;
         
        }
        else
        {
            for (var i = 0; i < oTarget.attributes.length; i++)
            {
                if (oTarget.attributes[i].name === title)
                    res = oTarget.attributes[i].value;
                 alert('coming here: '+res+'.....');
            }
        }
       
    }

User-added imageUser-added image
I am trying to display 100 locations address from cutom object to Lightning:map tag, its showing only first 11 addresses plotting on the map.  Is there any limitation for this lightning:map tag ?

Please help to solve this. 

I have followed this link to create component. 
http://sfdcmonkey.com/2018/09/16/mark-locations-google-map-salesforce-lightning/User-added image
I have trigger the below simple trigger to add BCC address dynamically, but its not firing to email. It is showing in the debug log about the added email address . Please help to solve this. 
 
trigger EmailMessage_Trigger on EmailMessage (before insert) {
    
       // EmailMessage_Trigger_Helper.emailMessage(Trigger.New);
     
     for(EmailMessage emsg : Trigger.New){
         if (emsg.Incoming==false && emsg.Status == '3') 
         {
             emsg.BccAddress ='saiprasanth123@gmail.com';  
             emsg.CcAddress ='saiprasanth1234@gmail.com';
           system.debug('coming sai inside:'+emsg.CcAddress+'....'+emsg.FromAddress);

         }
           system.debug('coming sai outside:'+emsg);
     }
}


Thanks,
Sai.
I am trying to integrate with Indian postal department data.  I am getting the below error from VF page code.   Please help me to solve this. 

System.JSONException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at input location [1,2]
Error is in expression '{!submit}' in component <apex:commandButton> in page postacodeapi: Class.System.JSON.deserialize: line 15, column 1
Class.fromJSON.parse: line 23, column 1
Class.postacodeAPIClass.submit: line 30, column 1


 
//
//Generated by AdminBooster
//

public class fromJSON{
    public String Message;  //Number of Post office(s) found: 11
    public String Status;   //Success
    public cls_PostOffice[] PostOffice;
    class cls_PostOffice {
        public String Name; //Addanki Gate
        public String Description;  //
        public String BranchType;   //Sub Post Office
        public String DeliveryStatus;   //Non-Delivery
        public String Taluk;    //Ongole
        public String Circle;   //Ongole
        public String District; //Prakasam
        public String Division; //Prakasam
        public String Region;   //Vijayawada
        public String State;    //Andhra Pradesh
        public String Country;  //India
    }
    public static fromJSON parse(String json){
        return (fromJSON) System.JSON.deserialize(json, fromJSON.class);
    }

   
}
 
public class postacodeAPIClass {
public string pcode{set;get;}
public string result{set;get;}
public integer scode{set;get;}
public string status{set;get;}
public List<fromJSON> wrapList{set;get;}
public void submit()
{


wrapList = new list<fromJSON>();

http p=new http();
httprequest req=new httprequest();
 req.setendpoint('http://postalpincode.in/api/pincode/'+pcode);
//req.setendpoint('http://facebook.com');
req.setmethod('GET');
httpresponse res=new httpresponse();
res =p.send(req);

result=res.getbody();

 
// result = '[{"Name":"Addanki Gate","Description":"","BranchType":"Sub Post Office","DeliveryStatus":"Non-Delivery","Taluk":"Ongole","Circle":"Ongole","District":"Prakasam","Division":"Prakasam","Region":"Vijayawada","State":"Andhra Pradesh","Country":"India"},{"Name":"Dcp(O)","Description":"","BranchType":"Sub Post Office","DeliveryStatus":"Non-Delivery","Taluk":"Ongole","Circle":"Ongole","District":"Prakasam","Division":"Prakasam","Region":"Vijayawada","State":"Andhra Pradesh","Country":"India"}]';
scode=res.getstatuscode();
status=res.getstatus();

   //  wrapList  = (List<fromJSON>)System.JSON.deserialize(result, list<fromJSON>.class);
  //fromJSON fromJSON2  = (fromJSON)System.JSON.deserialize(result,fromJSON.class);
 fromJSON wrapList = fromJSON.parse(res.getbody());

}

  
      
      
      

}

 
I am calling the below class from the lighting component OR form devloper console and i am getting the same error in the debug log. Kindly help me to sort this. Response body is coming and when I am deserilizing the error is coming.  please help to sort this.

Debug log error message.
public class ApiCallLightningComponent {
 /*
 * @Name : - fetchUserSessionId
 * @Description: - Call the VF page and get the Log In Use Session Id
 * @Params : - none
 * @ReturnType : - String
 */
 public static String fetchUserSessionId(){
 String sessionId = '';
 // Refer to the Page
 PageReference reportPage = Page.GetSessionIdVF;
 // Get the content of the VF page
 String vfContent = reportPage.getContent().toString();
 System.debug('vfContent '+vfContent);
 // Find the position of Start_Of_Session_Id and End_Of_Session_Id
 Integer startP = vfContent.indexOf('Start_Of_Session_Id') + 'Start_Of_Session_Id'.length(),
 endP = vfContent.indexOf('End_Of_Session_Id');
 // Get the Session Id
 sessionId = vfContent.substring(startP, endP);
 System.debug('sessionId '+sessionId);
 // Return Session Id
 return sessionId;
 }
 /*
 * @Name - makeAPICall
 * @Description - Responsible for making API Call out
 * @params - None
 * @ReturnType - String
 */
 @AuraEnabled
 public static list<accountwrapper> makeAPICall(){
 String sessionId = fetchUserSessionId();
 HTTP h = new HTTP();
 HTTPRequest req = new HTTPRequest();
 HttpResponse resp = new HttpResponse();
 req.setMethod('GET');
 req.setHeader('Authorization', 'Bearer ' + sessionId);
     system.debug('coming here 1');
 req.setEndpoint(URL.getSalesforceBaseUrl().toExternalForm() + '/services/data/v41.0/query?q=Select+Id,+Name+From+Account');
 resp = h.send(req);
 System.debug('#### Response Status '+resp.getStatus());
 System.debug('#### Response Status Code '+resp.getStatusCOde());
 System.debug(resp.getBody());
    list<accountwrapper> accountwrapperList = new list<accountwrapper>();
    //  string temp = string.valueof(resp.getBody()).substringAfter('"records":');
      system.debug('the response:'+resp.getBody());
    // system.debug('the temp is:'+temp);
     accountwrapperList = (list<accountwrapper>)system.json.deserialize(resp.getBody(), list<accountwrapper>.class);
     // return JSON.serialize(resp.getBody());
     system.debug('The accountwrapperList is :'+accountwrapperList);
      return accountwrapperList;
 } 
    
    public class accountwrapper{
       @AuraEnabled public string Id;
       @AuraEnabled public string Name;
    }
}

 
Hi,
    I have written rest api code (http Get) method for capturing lead information from external system. I have rested the api, it is working good. But duing the test class i am getting NULL values for parameters. Kindly help me on this. 

Apex class:-  

In the below class, "allvalue" varible is showing as null null .......  in debug log.  Please help me on this. 
 
@RestResource(urlMapping='/timeemailer/*')
global class timeemailerRestApi{

    @HttpGet
    global static String createNewLead()
    {
    string erroMsg = '';
    string allvalue ='';
    try{
     RESTRequest req = RESTContext.Request;
     RESTResponse res = RESTContext.Response;
  //  String body =  req.requestBody.Tostring();
    
    String name = req.params.get('name');
    string emailid = req.params.get('emailid');
    string  Phonenumber = req.params.get('Phonenumber');
    string Projectname = req.params.get('Projectname');
    string key = req.params.get('key');
    
    allvalue = name +'..'+emailid+'...'+phonenumber+'....'+projectname+'..'+key;
    
    system.debug('The coming values are  : '  + allvalue);
   
   if(key!= null && key.Equals(label.Times_E_mailer_key)) 
   { 
    lead l1 = new lead();
    l1.lastname = name;
    if(emailid != null && emailid !='NA')
    l1.Email = emailid;
    l1.mobilephone = phonenumber;
    l1.projects__c = Projectname;
    l1.company ='NA';
    l1.Source_Channel__c = 'Times-E-mailer';
    l1.run_lead_assignment__c =true;
    
    insert l1; 
    
    erroMsg = 'Record sucessfully inserted in salesforce. ';
   } 
   else{
     erroMsg = 'You have entered a wrong API key';
      Error_Log__c el = new Error_Log__c();
           el.Class_Trigger_Name__c ='timeemailerRestApi ';
           el.Error_Description__c = 'Sent wrong key ......................................... The original sent data is :'  + allvalue;
           el.Method_Name__c = 'lead insert method';
           insert el;           
   }
    }
      catch(exception ert)
      {
         Error_Log__c el = new Error_Log__c();
           el.Class_Trigger_Name__c ='timeemailerRestApi ';
           el.Error_Description__c = string.valueof(ert)+'......................................... The original sent data is :'  + allvalue;
           el.Method_Name__c = string.valueof(ert.getLineNumber());
           insert el;           
         erroMsg = 'Records are not inserted ' + string.valueof(ert);
      }
      
    
    return erroMsg;
  
 
    
    }
    
    }

TEST CLASS:-
 
@istest
private class timeemailerRestApi_test{

@istest private static void testmethod1()
{

  


   // req.requestURI = '/services/apexrest/timeemailer';  //Request URL
  //  req.addParameter('name','hellotesting');
  //  req.addParameter('emailid','testing123123get@gmail.com');
  //  req.addParameter('Phonenumber','9842011142');
  //  req.addParameter('Projectname','Acropolis');
  //  req.addparameter('Key','Times-E-mailer');
  
  
   
   
    RestRequest req1 = new RestRequest(); 
    RestResponse res1 = new RestResponse();

    // pass the req and resp objects to the method     
    req1.requestURI = '/services/apexrest/timeemailer?key=Times-E-mailer&name=TestingGetmethod&emailid=testing123123get@gmail.com&Phonenumber=9842011142&Projectname=myprojectName';  //Request URL
    req1.httpMethod = 'GET';
    
    RestContext.request = req1;
    RestContext.response = res1;

 


   string responseMsg = timeemailerRestApi.createNewLead(); //Call the Method of the Class with Proper 


}
}

 

I am trying to populate the one input text field(after entering the date) into another inputtext field in table at visualforce page. I am using change function but, it is not working. Please help me to solve this. Even alert is also not working in my change function code.

Visualforce and apex code below. 
 
<apex:page controller="jquerytableaddrows">
  
  <head>
<title>jQuery Add Elements to DOM</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript">
var dropdwn='';

dropdwn = '{!optionsstr}';

  $j = jQuery.noConflict();
  
    $j(document).ready(function(){
        $j("#btn").click(function(){
 $j("#tabletab").append('<tr valign="top"><th scope="row"><label for="customFieldName">Custom Field</label></th><td><input type="text" class=".cfonee" id="cfone" name="customFieldName[]" value="" placeholder="Input Name" /> &nbsp;'+dropdwn +' <input type="text" class="code" id="customFieldValue" name="customFieldValue[]" value="" placeholder="Input Value" /> &nbsp; <a href="javascript:void(0);" class="remCF">Remove</a></td></tr>');
    });
        
        
        
       $j("#tabletab").on('click','.remCF',function(){
        $j(this).parent().parent().remove();
    });
   
       $j('input[id$=cfone]').change(function(){
         alert('123123');
        });
  
        });
   
    
   
    
</script>
</head>
<body>
    <p>This is a paragraph.</p>
 
    <button id="btn">Add new list item</button><br/>
    <table class="ipfields" id="tabletab">
    </table>
    <ol>
        <li>list item</li>
        <li>list item</li>
        <li>list item</li>
    </ol>
</body> 
  </apex:page>
 
public class jquerytableaddrows {

public list<string> names{set;get;}
public string optionsstr{set;get;}

public jquerytableaddrows()
{
names = new list<string>();
optionsstr = '<select>';
 for(contact con:[select name from contact  order by createddate asc limit 10])
 {
     optionsstr = optionsstr + '<option value=\"' + con.name +'\">'+con.name+'</option>';
 
// optionsstr=+ '<option value='+"volvo">Volvo</option>
 }
 optionsstr = optionsstr +'</select>';

 
}
}

User-added image
      Please help me to solve this for me.  I have installed SFDC open cti adapter but, I am not able to find where to pass the API links data and how to pass which has been given from my client. (one is freepbx  another one is Mcube). Salesforce documentation is saying that, we need to uncomment the TWILO code after installing the Twillio package in SFDC org.  But Twilio is paid one and client doesn't want to pay for TWILIO. Could you guide me any documentation or code for doing CTI with SFDC OPEN CTI ADAPTER. 


In the below class "SoftphoneProviderHelper" sfdc documents saying that remove the comments after installing the TWILIO package.

Or do we need to modify the TWILIO package for CTI with our credentails ? 

​Please help me to solve this.  
Hi,

   I want to display all contacts.
Conditions:-  We need to display only if the contact parent account has more then 3 contacts. 

So i write this soql. but its not wokring.,  Please help.  If this is done then i need to do the same for custom objects in my project. 

If we write "select count(account.id) from contact group by account.name"  then it is displaying result as excepted. But below query is not working.  
select id,name from contact where (select count(account.id) from contact group by account.name) > 2

 
Hi,   If i click on "edit" text in the below image, then i need to hide all the <apexoutputext> tag in that row and display all <apex:inputtext> tags in that same row where i click the "edit" text. So I need to get the siblings ids <apexoutputext> tag.  Please help to solve this. 

User-added image

 
<apex:pageBlockTable value="{!categories}" var="c">
          <apex:column width="25px">
            <apex:inputCheckbox value="{!c.checked}"/>
          </apex:column>
          
           
        <apex:column headerValue="LastName" >  <apex:outputtext value="{!c.cat.LastName}"  id="lOutname" styleclass="outval"/>
                                                <apex:inputtext value="{!c.cat.LastName}" id="linname" styleclass="inpval"/> 
        </apex:column>
                       
        <apex:column headerValue="FirstName">   <apex:outputtext value="{!c.cat.FirstName}"  id="fOutname" styleclass="outval"/>
                                                <apex:inputtext value="{!c.cat.FirstName}" id="finname" styleclass="inpval"/>
        </apex:column>
        
        <apex:column headerValue="Department" >   <apex:outputtext value="{!c.cat.department}" id="Outdept" styleclass="outval"/>
                                                   <apex:inputtext value="{!c.cat.department}"   id="indept" styleclass="inpval"/>
        </apex:column>
        
        <apex:column headerValue="Edit/Save" > 
                                               <div id="editrow" onclick="editrow()"> Edit </div>  
                                               <div id="saverow"> Save </div> 
        </apex:column>
      

        </apex:pageBlockTable>

 
Hi, 
   I want to display buttons like the below image. i worte the code basic code here . intially some buttons should be display in page and remaining buttons should be display in toogle. the button lable names and buttons are always dynamic. Please help me. 

 
public class AutoToogleButtons {

public list<Account> accs{set;get;}
  public AutoToogleButtons()
  {  
      accs =[select id,name from account limit 30];
  
  }

}








<apex:page controller="AutoToogleButtons">
  <apex:form >
  <apex:pageblock >
  <table ><tr>
     <apex:repeat value="{!accs}" var="acc">
     <td><apex:commandbutton value="{!acc.Name}" /> </td>
     
     </apex:repeat>
     </tr></table>
  </apex:pageblock>
  </apex:form>
  
  
</apex:page>

User-added image
hi, i am trying to pass the one string value from child component to parent component. but it is not firing. please help me to solve this issue. Thank you.


Child component code: -
 
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" controller="AccountContactEventClass">
    
  <!--  <aura:registerEvent name="rollUpEventRaja1" type="c.rollUpEventRaja" /> -->
    
    	    <aura:registerEvent name="jaffraja123" type="c:eventraja"/>

    
    <aura:handler name="init" value="{!this}"  action="{!c.onloadingmethod}" />
    <aura:attribute name="contact" type="contact" default="{'sobjectType': 'contact',
                         'LastName': '',
                         'Phone': '',
                         'Title': '',
                         'AccountId': ''                                  
                           }"/>
    <aura:attribute name="result" type="string" />
    
    <ui:inputSelect label="Select Account:" class="optionClass" aura:id="InputSelectDynamic" change="{!c.accountSelected}" />
    
    <br/><br/>
    
    Insert new contact.
                                               
     
  LastName:   <ui:inputtext value="{!v.contact.LastName}" />
    Phone :     <Ui:inputtext value="{!v.contact.Phone}" />
    Title :    <ui:inputtext value="{!v.contact.Title}" />  
    Department:  <ui:inputtext value="{!v.contact.Department}" />
    <br/><br/>
    <ui:button label="Insert contact" press="{!c.insertcontact}" />
    
    ...The reslt is: -  {!v.result}.....
    
</aura:component>
















({
  // Method for displaying the all account names in a picklist value . Loading intially.
         

    onloadingmethod :function(component, event, helper) {
 
        var apexmeth = component.get("c.callaccounts");
         
        // setting call back.
        apexmeth.setCallback(this, function(data) {
           var state = data.getState();
            console.log('the state init',state); 
            if(state == "SUCCESS")
            {
                var arryRecs =[];
                
                var apexRecs = data.getReturnValue();
                
                for(var i=0;i<apexRecs.length;i++)
                {
                    var cuurentApexRec = apexRecs[i];
                    console.log('the rec names are: ',cuurentApexRec.Name);
                    
                      arryRecs.push({"class": "optionClass", label: cuurentApexRec.Name, value: cuurentApexRec.Id});
                }
                 var inputsel = component.find("InputSelectDynamic");
                 inputsel.set("v.options", arryRecs);        
            }
            else
            {
                alert('The state us error while calling the init method');
            }
            
        });
         $A.enqueueAction(apexmeth);
    },
    
    
    
    
    
    // Method for inseting new contact with the selected account id from the picklist value.
    
	insertcontact : function(component, event, helper) {
		// calling the value from the component user inputs.
        var con = component.get("v.contact");
        console.log('1st log: '+ con);
        // calling the apex class method.
        var apexclass = component.get('c.getcreateContact');
        
        // setting call bank and passing the contact as paramter to the apex class.
        //  con.AccountId = '0012800000zemil';
        //  Getting the account id selected from the front end user picklist. 
        var selectedAcc = component.find("InputSelectDynamic").get("v.value");  
        con.AccountId = selectedAcc;
        apexclass.setParams({
            "con" : con
        });
        
        var ContactInsertedAccount ;
        apexclass.setCallback(this,function(data){
            var state = data.getState();
            
            console.log('the state is : '+state);
            if(state =="SUCCESS")
            {
                console.log('The return val is: ', data.getReturnValue());
                component.set("v.result",data.getReturnValue());
                ContactInsertedAccount = data.getReturnValue();
            }
            else{
                alert('error during calling the callback function');
            }
            
        });
        
        
     //adds the server-side action to the queue        
        $A.enqueueAction(apexclass);
          ContactInsertedAccount ="tesing jaff passing";
        var searchCompleteEvent = component.getEvent("rollUpEventRaja1");
      /*  console.log("event called :"+JSON.stringify(searchCompleteEvent));
  
      
        
       var status1 = searchCompleteEvent.setParams({ "accName": ContactInsertedAccount }).fire();
        console.log('The stats if fire is : ',status1);  */
        
         var searchCompleteEvent = component.getEvent("jaffraja123");
        console.log("event called :"+JSON.stringify(searchCompleteEvent));

    searchCompleteEvent.setParams({ "variable123": ContactInsertedAccount }).fire();

	},
    


    accountSelected : function(component)
    {
       var selectedAcc = component.find("InputSelectDynamic").get("v.value");  
        
        console.log('the slectesd val is acc : '+selectedAcc);
        
    },
    
    
})


Parent component :-
 
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" controller="AccountContactEventClass">
    
    <aura:handler name="init" value="{!this}" action="{!c.loadRollUpsummary}" />
    <aura:attribute name="accoutRollUps" type="AccountContactEventClass.ReportExample" />
     
 <!-- <aura:handler name="rollUpEventRaja1"  event="c:rollUpEventRaja" action="{!c.showAccName}"/>   -->
    <aura:handler name="jaffraja123"  event="c:eventraja" action="{!c.myAction}"/> 
    
   <!-- <ui:outputtext aura:id="accname" />
    <ui:outputtext aura:id="rollupcount" /> -->
    
    List of Accounts with Rollup contacts count. 
	
    <table>
        <tr><td>Name</td><td>Total Contacts</td></tr>
    <aura:iteration items="{!v.accoutRollUps}" var="acc" >
    <tr><td>{!acc.accName}</td><td>{!acc.totalContacts}</td></tr>
        
    
    </aura:iteration>
    </table>
</aura:component>










({
	loadRollUpsummary :function(component,event)
    {
        var apexmeth = component.get("c.rollUpContacts");
        
        apexmeth.setCallback(this,function(data){
            
            var accsData = data.getReturnValue();
            console.log('The data is : ',accsData.accName );
            component.set("v.accoutRollUps",accsData);
            
        });
        $A.enqueueAction(apexmeth);       
        
    },
    
    showAccName : function(component,event)
    {
         
       // component.find("v.accname").set(event.getParam("accName")); 
        console.log('The value of event is: ', event.getParam("variable123"));
    
    } 
  
})


Event:-
 
<aura:event type="component"  >
    <aura:attribute name="variable123" type="string" />
</aura:event>


 
rest api with salesforce to salesforce thowing error. 

Class.System.JSON.deserialize: line 15, column 1 Class.SendAccountFromSource.createAccount: line 53, column 1 02:22:18.32 (551178169)|FATAL_ERROR|System.JSONException: Malformed JSON: Expected '{' at the beginning of object


This is my apex code. here line no.53 error is showing. please help
public class SendAccountFromSource {
 private final String clientId = '3MVG9ZL0ppGP5UrCXwgNBMST50Qgzy25yEBImbav2qxNHYZumcKbMK09kOK5qvYnGpde4jJt.MtQ1rjlyytaP';
 private final String clientSecret = '7453209643147176840';
 private final String username = 'prasanthkumar@gmail.com';
 private final String password = 'dolly1234';
 
 
 public class deserializeResponse
 {
  public String id;
  public String access_token;
 }
 
 
 public String ReturnAccessToken (SendAccountFromSource acount)
 {
  String reqbody = 'grant_type=password&client_id='+clientId+'&client_secret='+clientSecret+'&username='+username+'&password='+password;
  Http h = new Http();
  HttpRequest req = new HttpRequest();
  req.setBody(reqbody);
  req.setMethod('POST');
  req.setEndpoint('https://login.salesforce.com/services/oauth2/token');
  HttpResponse res = h.send(req);
  deserializeResponse resp1 = (deserializeResponse)JSON.deserialize(res.getbody(),deserializeResponse.class);
  
  system.debug('The resp1.access_token is : ' +resp1.access_token+' The status code is: '+res.getstatuscode() +'....' +res.getstatus());
  
  
  return resp1.access_token;
  
  
 }
 @future(callout=true)
 public static void createAccount(String accName, String accId) 
 {
  SendAccountFromSource acount = new SendAccountFromSource();
  String accessToken = acount.ReturnAccessToken (acount);
 
  if(accessToken != null)
  {
  system.debug('inside the if statement :' );
   String endPoint = 'https://ap2.salesforce.com/services/apexrest/v1/createAccount/';
   String jsonstr = '{"Name" : "' + accName + '"}';
   Http h2 = new Http();
   HttpRequest req1 = new HttpRequest();
   req1.setHeader('Authorization','Bearer ' + accessToken);
   req1.setHeader('Content-Type','application/json');
   req1.setHeader('accept','application/json');
   req1.setBody(jsonstr);
   req1.setMethod('POST');
   req1.setEndpoint(endPoint);
   HttpResponse res1 = h2.send(req1);
   deserializeResponse resp2 = (deserializeResponse)JSON.deserialize(res1.getbody(),deserializeResponse.class);
   Account a = [SELECT Id FROM Account WHERE Id = :accId];
   a.externalId__c = resp2.id;
   update a;
  }
 }
}

 
In this code. call back function state is coming as false.  Please help.
 
newcontacts : function(component, event, helper){
    var contval = component.get("v.newcontact");
        console.log('The con vlaue is ',contval);
        
        var action = component.get("c.getlightcons");
        action.setParams({
            con : contval
        });
             
        
        action.setCallback(this,function(a){
            //get the response state
            var state = a.getState();
            if(state == true)
            {    
            
            
                    console.log("The state is true");
                     component.get("v.errormeg",a.getReturnValue());
            }
            else
            {
                console.log("The state is false");
            }
           
        });
    $A.enqueueAction(action);
  }
})










public class eventsexampleapexclass {
     @AuraEnabled
     public static string getlightcons(contact con)
     {           system.debug('inside the The error message value is : ');

         string errormsg ='';
         try{
         		if(con!= null)
         		{
             		insert con;
         		}
            }
         catch(exception er1)
         {
             errormsg=string.valueOf(er1);
             system.debug('inside the catch method');
         }
         system.debug('The error message value is : '+errormsg);
         return errormsg;
     }
    
}

 
Hi,  i am trying to display wrapper class data in lighning page. But noting is coming. But in cosole.log data is coming. Please help me to findout this thing.   

 
public class accwrapperclass {

    public class accwrapper
    {
      @AuraEnabled  public account acc{set;get;}
      @AuraEnabled  public boolean check{set;get;}
    }
}



public class selectedaccountslight {
 
    
    @auraEnabled
    public static list<accwrapperclass.accwrapper> getalldatas()
    {
        list<accwrapperclass.accwrapper> accWrapperList = new list<accwrapperclass.accwrapper>();
        
        for(account a1:[select id,name,phone,industry from account ])
        {
            accwrapperclass.accwrapper aw1 = new accwrapperclass.accwrapper();
            aw1.check= false;
            aw1.acc = a1;
            accWrapperList.add(aw1);
            
        }
        return accWrapperList;
    }

}








<aura:component controller="selectedaccountslight">
           <aura:handler name="init" value="{!this}" action="{!c.myAction}"/>
   <aura:attribute name="accwrappervalues" type="accwrapperclass.accwrapper[]" /> 

    <aura:iteration items="{!v.accwrappervalues}" var="data">
    {!data.check}....  
    
    
    </aura:iteration>
	
</aura:component>











({
	myAction : function(component, event, helper) {
        
        var action = component.get("c.getalldatas");
 console.log("hello raja");
        
        //Setting the Callback
            action.setCallback(this,function(a){
                //get the response state
                var state = a.getState();
                		  console.log("hello raja2");

                //check if result is successfull
                if(state == "SUCCESS"){
                    
                    var wrapdata = a.getReturnValue();
                    console.log("The wrapdata is: " ,wrapdata);
                  component.get("v.accwrappervalues",wrapdata);
                    
                } 
            });
            
            //adds the server-side action to the queue        
            $A.enqueueAction(action);
		  console.log("hello raja3");
	}
})

 
Hi, 

I want to display list of accounts with contacts in lightning page. Here the code i have written. Here accounts are displaying but contacts are not display. Please help me to display the accounts with contacts.

Thank you.


 
<aura:component controller="accountsWithContactsClass" implements="flexipage:availableForAllPageTypes" access="global">
	 
    <aura:attribute name="accounts" type="Account[]" />
    <ui:button label="click this" press="{!c.myAction}" />
    <table>
            <tr><td><b>Name</b></td><td><b>Industry</b></td></tr>

    <aura:iteration items="{!v.accounts}" var="accs1" >
        <tr>   
        <td> {!accs1.Name}  </td>
         
      <td>   {!accs1.Industry}  </td> 
      <!--   <td>   {!accs1.Contacts.lastName}  </td> -->
        </tr>     
     <tr>   <aura:iteration items="{!v.accs1.contacts}" var="con1" >
            
             <td>{!con1.lastName} </td>
            
        </aura:iteration></tr>
     </aura:iteration>                                            
        </table>
    
</aura:component>








({
	myAction : function(component, event, helper) {
		var action =component.get("c.getAllAccounts");
        console.log('The action value is: '+action);
         action.setCallback(this, function(a){ 
             
            component.set("v.accounts", a.getReturnValue());
           //  console.log('The accs are :'+JSON.stringify(a.getReturnValue()));
            console.log('The accs are :'+JSON.stringify(a.getReturnValue()));
          
        });
        $A.enqueueAction(action);
	}
})











public class accountsWithContactsClass {

@auraEnabled
public static list<account> getAllAccounts()
    {
       list<account> accs =[select id,name,phone,industry,(select lastName from contacts) from account limit 10];
      //  list<account> accs =[select id,name,phone,industry from account limit 10];
     //   return [select Id,Name from account limit 10];
     return accs;
    }
}

 
Hi, 
      Here i have two objects have the same data type fields with api names. if i click on button then from one object record has to copy to another object.  so i am wrote this code in developer console for tesitng. i am getting this error. 

Line: 22, Column: 5
Invalid field t1 for SObject sai_prasanth__c   

Actually i want to get the field api name into temp string "t1"  but there my code thinking this "t1"  is custom field.  How to make string as api name here ?   
 
list<string> fields = new list<string>();
fields.add('name');
fields.add('comments__c');
fields.add('Cost__c');
fields.add('hotel_name__c');

string queryfields ='comments__c,Cost__c,hotel_name__c';
string tempname='lunch';
string query ='select id,'+queryfields+' from prashanth_kuamar__c where name=:tempname';

prashanth_kuamar__c pk =database.query(query);

system.debug(pk);

list<sai_prasanth__c> spToInsert = new list<sai_prasanth__c>();

for(integer i=0;i<fields.size();i++)
{
    system.debug('inside for loop: '+i);
    sai_prasanth__c sp= new sai_prasanth__c();
    string t1 = fields.get(i);
    sp.t1 = pk.t1;
    spToInsert.add(sp);
}
insert spToInsert;

 
Hi,  i am trying to display wrapper class data in lighning page. But noting is coming. But in cosole.log data is coming. Please help me to findout this thing.   

 
public class accwrapperclass {

    public class accwrapper
    {
      @AuraEnabled  public account acc{set;get;}
      @AuraEnabled  public boolean check{set;get;}
    }
}



public class selectedaccountslight {
 
    
    @auraEnabled
    public static list<accwrapperclass.accwrapper> getalldatas()
    {
        list<accwrapperclass.accwrapper> accWrapperList = new list<accwrapperclass.accwrapper>();
        
        for(account a1:[select id,name,phone,industry from account ])
        {
            accwrapperclass.accwrapper aw1 = new accwrapperclass.accwrapper();
            aw1.check= false;
            aw1.acc = a1;
            accWrapperList.add(aw1);
            
        }
        return accWrapperList;
    }

}








<aura:component controller="selectedaccountslight">
           <aura:handler name="init" value="{!this}" action="{!c.myAction}"/>
   <aura:attribute name="accwrappervalues" type="accwrapperclass.accwrapper[]" /> 

    <aura:iteration items="{!v.accwrappervalues}" var="data">
    {!data.check}....  
    
    
    </aura:iteration>
	
</aura:component>











({
	myAction : function(component, event, helper) {
        
        var action = component.get("c.getalldatas");
 console.log("hello raja");
        
        //Setting the Callback
            action.setCallback(this,function(a){
                //get the response state
                var state = a.getState();
                		  console.log("hello raja2");

                //check if result is successfull
                if(state == "SUCCESS"){
                    
                    var wrapdata = a.getReturnValue();
                    console.log("The wrapdata is: " ,wrapdata);
                  component.get("v.accwrappervalues",wrapdata);
                    
                } 
            });
            
            //adds the server-side action to the queue        
            $A.enqueueAction(action);
		  console.log("hello raja3");
	}
})

 
I am trying to display 100 locations address from cutom object to Lightning:map tag, its showing only first 11 addresses plotting on the map.  Is there any limitation for this lightning:map tag ?

Please help to solve this. 

I have followed this link to create component. 
http://sfdcmonkey.com/2018/09/16/mark-locations-google-map-salesforce-lightning/User-added image
Hi,
    I have written rest api code (http Get) method for capturing lead information from external system. I have rested the api, it is working good. But duing the test class i am getting NULL values for parameters. Kindly help me on this. 

Apex class:-  

In the below class, "allvalue" varible is showing as null null .......  in debug log.  Please help me on this. 
 
@RestResource(urlMapping='/timeemailer/*')
global class timeemailerRestApi{

    @HttpGet
    global static String createNewLead()
    {
    string erroMsg = '';
    string allvalue ='';
    try{
     RESTRequest req = RESTContext.Request;
     RESTResponse res = RESTContext.Response;
  //  String body =  req.requestBody.Tostring();
    
    String name = req.params.get('name');
    string emailid = req.params.get('emailid');
    string  Phonenumber = req.params.get('Phonenumber');
    string Projectname = req.params.get('Projectname');
    string key = req.params.get('key');
    
    allvalue = name +'..'+emailid+'...'+phonenumber+'....'+projectname+'..'+key;
    
    system.debug('The coming values are  : '  + allvalue);
   
   if(key!= null && key.Equals(label.Times_E_mailer_key)) 
   { 
    lead l1 = new lead();
    l1.lastname = name;
    if(emailid != null && emailid !='NA')
    l1.Email = emailid;
    l1.mobilephone = phonenumber;
    l1.projects__c = Projectname;
    l1.company ='NA';
    l1.Source_Channel__c = 'Times-E-mailer';
    l1.run_lead_assignment__c =true;
    
    insert l1; 
    
    erroMsg = 'Record sucessfully inserted in salesforce. ';
   } 
   else{
     erroMsg = 'You have entered a wrong API key';
      Error_Log__c el = new Error_Log__c();
           el.Class_Trigger_Name__c ='timeemailerRestApi ';
           el.Error_Description__c = 'Sent wrong key ......................................... The original sent data is :'  + allvalue;
           el.Method_Name__c = 'lead insert method';
           insert el;           
   }
    }
      catch(exception ert)
      {
         Error_Log__c el = new Error_Log__c();
           el.Class_Trigger_Name__c ='timeemailerRestApi ';
           el.Error_Description__c = string.valueof(ert)+'......................................... The original sent data is :'  + allvalue;
           el.Method_Name__c = string.valueof(ert.getLineNumber());
           insert el;           
         erroMsg = 'Records are not inserted ' + string.valueof(ert);
      }
      
    
    return erroMsg;
  
 
    
    }
    
    }

TEST CLASS:-
 
@istest
private class timeemailerRestApi_test{

@istest private static void testmethod1()
{

  


   // req.requestURI = '/services/apexrest/timeemailer';  //Request URL
  //  req.addParameter('name','hellotesting');
  //  req.addParameter('emailid','testing123123get@gmail.com');
  //  req.addParameter('Phonenumber','9842011142');
  //  req.addParameter('Projectname','Acropolis');
  //  req.addparameter('Key','Times-E-mailer');
  
  
   
   
    RestRequest req1 = new RestRequest(); 
    RestResponse res1 = new RestResponse();

    // pass the req and resp objects to the method     
    req1.requestURI = '/services/apexrest/timeemailer?key=Times-E-mailer&name=TestingGetmethod&emailid=testing123123get@gmail.com&Phonenumber=9842011142&Projectname=myprojectName';  //Request URL
    req1.httpMethod = 'GET';
    
    RestContext.request = req1;
    RestContext.response = res1;

 


   string responseMsg = timeemailerRestApi.createNewLead(); //Call the Method of the Class with Proper 


}
}

 
Hi everyone. In our company we are currently implementing the opencti for our customers.
So one of the feature that we want is to create a call log while or after the call is finish. 
I saw that I can use the 
sforce.opencti.screenPop({
                            type: sforce.opencti.SCREENPOP_TYPE.NEW_RECORD_MODAL, 
                            params: { entityName: 'Task'}
}); 

because I read something that a call log is the same as task but unfortunately this is not shareable. 
Only the one user can see the this call log that is not our customer wants. Is there any other way around that can solve this?
I tried to create a public group and assign the task but it's not working only contacts and lead can be assign or relate to the task.
Is there any open cti function that I can use regarding this issue? because this is a sample scenario we want. 
For example, there are list of phone numbers that the agents need to call, if the other agents already called this number there's no need to call
that number. and so agents need to know about it by having a call log that is visible to all assigned users in a open cti call center.

I hope you can help me about this. Thank you.

Austin
In this code. call back function state is coming as false.  Please help.
 
newcontacts : function(component, event, helper){
    var contval = component.get("v.newcontact");
        console.log('The con vlaue is ',contval);
        
        var action = component.get("c.getlightcons");
        action.setParams({
            con : contval
        });
             
        
        action.setCallback(this,function(a){
            //get the response state
            var state = a.getState();
            if(state == true)
            {    
            
            
                    console.log("The state is true");
                     component.get("v.errormeg",a.getReturnValue());
            }
            else
            {
                console.log("The state is false");
            }
           
        });
    $A.enqueueAction(action);
  }
})










public class eventsexampleapexclass {
     @AuraEnabled
     public static string getlightcons(contact con)
     {           system.debug('inside the The error message value is : ');

         string errormsg ='';
         try{
         		if(con!= null)
         		{
             		insert con;
         		}
            }
         catch(exception er1)
         {
             errormsg=string.valueOf(er1);
             system.debug('inside the catch method');
         }
         system.debug('The error message value is : '+errormsg);
         return errormsg;
     }
    
}

 
Hi, 

I want to display list of accounts with contacts in lightning page. Here the code i have written. Here accounts are displaying but contacts are not display. Please help me to display the accounts with contacts.

Thank you.


 
<aura:component controller="accountsWithContactsClass" implements="flexipage:availableForAllPageTypes" access="global">
	 
    <aura:attribute name="accounts" type="Account[]" />
    <ui:button label="click this" press="{!c.myAction}" />
    <table>
            <tr><td><b>Name</b></td><td><b>Industry</b></td></tr>

    <aura:iteration items="{!v.accounts}" var="accs1" >
        <tr>   
        <td> {!accs1.Name}  </td>
         
      <td>   {!accs1.Industry}  </td> 
      <!--   <td>   {!accs1.Contacts.lastName}  </td> -->
        </tr>     
     <tr>   <aura:iteration items="{!v.accs1.contacts}" var="con1" >
            
             <td>{!con1.lastName} </td>
            
        </aura:iteration></tr>
     </aura:iteration>                                            
        </table>
    
</aura:component>








({
	myAction : function(component, event, helper) {
		var action =component.get("c.getAllAccounts");
        console.log('The action value is: '+action);
         action.setCallback(this, function(a){ 
             
            component.set("v.accounts", a.getReturnValue());
           //  console.log('The accs are :'+JSON.stringify(a.getReturnValue()));
            console.log('The accs are :'+JSON.stringify(a.getReturnValue()));
          
        });
        $A.enqueueAction(action);
	}
})











public class accountsWithContactsClass {

@auraEnabled
public static list<account> getAllAccounts()
    {
       list<account> accs =[select id,name,phone,industry,(select lastName from contacts) from account limit 10];
      //  list<account> accs =[select id,name,phone,industry from account limit 10];
     //   return [select Id,Name from account limit 10];
     return accs;
    }
}

 
Hi, 
      Here i have two objects have the same data type fields with api names. if i click on button then from one object record has to copy to another object.  so i am wrote this code in developer console for tesitng. i am getting this error. 

Line: 22, Column: 5
Invalid field t1 for SObject sai_prasanth__c   

Actually i want to get the field api name into temp string "t1"  but there my code thinking this "t1"  is custom field.  How to make string as api name here ?   
 
list<string> fields = new list<string>();
fields.add('name');
fields.add('comments__c');
fields.add('Cost__c');
fields.add('hotel_name__c');

string queryfields ='comments__c,Cost__c,hotel_name__c';
string tempname='lunch';
string query ='select id,'+queryfields+' from prashanth_kuamar__c where name=:tempname';

prashanth_kuamar__c pk =database.query(query);

system.debug(pk);

list<sai_prasanth__c> spToInsert = new list<sai_prasanth__c>();

for(integer i=0;i<fields.size();i++)
{
    system.debug('inside for loop: '+i);
    sai_prasanth__c sp= new sai_prasanth__c();
    string t1 = fields.get(i);
    sp.t1 = pk.t1;
    spToInsert.add(sp);
}
insert spToInsert;