• smita bhargava
  • NEWBIE
  • 90 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 28
    Questions
  • 24
    Replies
In the lightning component I have following piece of code
<aura:iteration items="{!'v.someValues.myVal}" var="rule" indexVar="indx">

<a href="javascript:void(0)" id="anchor" tabIndex="-1" onclick="doLogic">{!rule.RuleId}<a>

</aura:iteration>

The above iteration returns as follows which are hyperlinks.
NOC1
NOC2
NOC3
NOC4
NOC5


My requirement is twhen I click on the Hyperlink "NOC1", I want to disable it and all other hyperlinks below it.

please let me know how to do.

smita
I am having a lightning component datatable with 2 rows each row having a check box.
when I select a checkbox at headlevel then it shud select all rows and when I deselect header level checkbox it will deselect all below chekcboxex. I have atatched a screen for the same.

lightning datatable with select all checkbox


I saw couple of posts but I am not clear on how to proceed.
a working piece of code will be really helpful to understand.

 <c:GPS_COMP_DataTableUtility
                                 keyField = "id"
                                 tableData="{!v.tableData}"
                                 tableColumns="{!v.columns}"                                                                  hideCheckboxColumn="false"
                                 maxRowSelection="{!v.maxRowSelection}"
                                 selectedRows="{!v.selectedRows}"/>

Thanks
smita
Hello
My requirement is to restrict the past dates to the user, so it show start with the current date only.

I have as follows inside lightning component::

 <aura:attribute name="todayDate" type="Date" description="Today's Date"/>
<lightning:input type="datetime" aura:id ="dateTime" label="Follow Up Date and Time" name="date"  min="{!v.todayDate}"/>

doInit : function(component, event, helper) {
        component.set("v.todayDate",new Date());     
        alert(component.get("v.todayDate"));
    }

so when the component loads it will NOT show previous dates but only the current date to the user.Please let me know why this isn't working?

If any change in the markup I have to do pls let me know without too much coding in the controller.

Thanks
smita
If anybody can sh
I have a lightning comboBox as follows.

 <aura:attribute name="workBaskets" type="List" default="" description="Listing things in controller"/>

 <lightning:combobox name="workbasket" label="Work Basket"  value="{!v.workbasketName}" aura:id="workBasket" 
                                    class="priorityAlign" options="{!v.workBaskets}">

In the controller of the component I have as follows

 options.push({'label': 'WBI MDCR Rework Member', 'value': 'WBI_MDCR_Rework_Member'});
            options.push({'label': 'WB MDCR Rework Review Escalations', 'value': 'WB_MDCR_Rework_Review_Escalations'});
            options.push({'label': 'WBI MDCR StopPay', 'value': 'WBI_MDCR_StopPay'});
            options.push({'label': 'WBI MDCR Rework Provider', 'value': 'WBI_MDCR_Rework_Provider'});
            options.push({'label': 'WB MDCR DentalClaims', 'value': 'WB_MDCR_DentalClaims'});
            component.set("v.workBaskets",options);

.THIS .priorityAlign{
    margin-top: 25px;
  }


The ConboBox values are getting truncated when the conboxBox is loaded.

My requirement is to increase the width of the comboBox so the values do not appear truncated.

can we do this using slds class or using CSS?
Please let me know at the earliest with working code.
Like wise any CSS or slds class that will automatically increase the width of comboBox based on the value

Thanks
Smita
 
Hello
Has any one worked on salesforce Lightning Experience Reports & Dashboard Specialist .

I saw the URL 
https://techforceservices.com.au/salesforce/salesforce-lightning-experience-reports-dashboard-specialist-trailhead-superbadge/amp/

but didn't understand what report type(name) we have to create and what should be the record type. Its not very descriptive.

Please let me know.

Thanks
smita
I am doing the TrailHead challenge as below.

https://trailhead.salesforce.com/en/content/learn/modules/apex_integration_services/apex_integration_rest_callouts

I created an aexx class with method as follows as part of the challenge.

public class AnimalLocator{

public String getAnimalNameById(Integer id){
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals/:id');
request.setMethod('GET');
HttpResponse response = http.send(request);
// If the request is successful, parse the JSON response.
if (response.getStatusCode() == 200) {
    // Deserialize the JSON string into collections of primitive data types.
    Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
    // Cast the values in the 'animals' key as a list
    List<Object> animals = (List<Object>) results.get('animals');
    System.debug('Received the following animals:');
    //for (Object animal: animals) {
      //  System.debug(animal);
   // }   
}}

In the challenge ist given like this "the method returns the value of the 'name' property (i.e., the animal name)"
so  How to make the method return the animal name 

Please let me know.

Thanks
Smita
I have a code in my lightning component as follows.
Comp1.cmp

 <aura:attribute name="showProviderListcmp" type="Boolean" default="false"/>

  <lightning:card>
                <lightning:layout>
                    <lightning:layoutItem flexibility="auto" padding="around-small">
                  
                     <div onkeyup="{!c.handleKeyUp}">
                            <lightning:input
                                             aura:id="enter-search"
                                             name="searchProvider"
label=""
placeholder = "Search by Name, Speciality, Procedure, Condition or Provider ID  "
type="search"
                                             />
                        </div>
                      
                    </lightning:layoutItem>
                </lightning:layout>
            </lightning:card>      

<aura:if isTrue="{!v.showSpinner}">
       
        <lightning:spinner aura:id="spinner" variant="brand" size="medium" alternativeText="service Request"/> 
        <aura:set attribute="else">
            <aura:if isTrue="{!v.showProviderListcmp}">
             
                <div class="slds-p-bottom_xx-small" id="scrollDiv"></div>
                <lightning:card title="" aura:id="displayFindCareList">
                    <c:COMP2/>
                </lightning:card>
             
            </aura:if>
        </aura:set>
    </aura:if> 

Comp1Controller.js

 handleKeyUp : function (component,event,helper) {
      
   
        var isEnterKey = event.keyCode === 13;
        if (isEnterKey) {
            var queryTerm = component.find('enter-search').get('v.value');
            if (queryTerm.length > 2) {
          
                helper.navigateToList(component,event,helper,queryTerm);
        
            }}
   
    },

Comp1Helper.js

   navigateToList :  function(component,event,helper,queryTerm){
         var flow = component.find("autoServiceRequest");
        component.set("v.showSpinner",true);   
        var inputVariables =[
            {name: "varCaseRecordId",type:"String",value : component.get("v.caseId")},
            {name: "varAutoSrReason",type:"String",value : "Find Provider"},
            {name:"varAutoSrSubReason" ,type:"String",value:queryTerm}
        ];
        
       flow.startFlow("GPS_Create_Auto_Service_Request",inputVariables); 
 
        component.set("v.showProviderListcmp",true);
       
    },

what I want is when I type some test and click enter key in lightning:input, inside the method "handleKeyUp" I want to navigate to CompB i.e I want to scrollDown to CompB without the user manually having to do so.

I am struggling with his, please let me know with working code.

thanks
smita B
In the lightning component bundle I have the design  component.

Please let me know what is the difference between this and the markup.

In what specific situations do we need to create a <design:component>. 

A specific example with clarity will be helpful to understand.

thanks
smita 
I have created a flow and its working fine.
Now in the flow on a screen I have a link , when I click this link it should call a lightning component. 

But when I click this link it isthrowign an error as 
"We can’t display component 'c:MyComponent', because it isn't supported in Classic runtime. Ask your Salesforce admin to distribute this flow in Lightning runtime instead."

thanks

sheila
I created a visual flow. In the screen I dropped a displayText and the content inside  is "Please do . Appeal flow"
I  want to make the Phrase "Appeal Flow" as a link and when I click it the visual flow should end.

This screen is the last and when I click Finish it comes back to the start of the flow.

How to do this in the flow?

Please suggest urgent alternatives with solution.

thanks
smita 
 
I have a lightning component which display contact records.
I have exposed the component has a lightning TAB in LEX.
The code is working as shown below.
 
Base.cmp
-------------

<aura:component abstract="true"
                extensible="true">
	{!v.body}
</aura:component>

BaseHelper.js
-------------
({
    callServer : function(component,method,attributeName,params) {
        var action = component.get(method);
        if (params) {
            action.setParams(params);
        }
       
        action.setCallback(this,function(response){
            var state = response.getState();
        	console.log('State log '+state);
            if(state === 'SUCCESS'){
                component.set(attributeName,response.getReturnValue());
            }
            else if(state === 'ERROR'){
		         console.log('Error '+response.getError());
	}
        });
        $A.enqueueAction(action);
    }
})


CallApexClassComponentBase.cmp
------------------------------
<aura:component implements="flexipage:availableForAllPageTypes,
                            force:appHostable"
                            extends="c:Base"
                            controller="ContactController">

        <!--Declare Attributes-->
    <aura:attribute name="wrapperList" 
                    type="Object"/>
    
    <lightning:card title="Bring Contact data">
        
        <aura:set attribute="actions">
            
            <lightning:button label="Contact Data" 
                              onclick="{!c.Condata}" />
        </aura:set> 
        
    </lightning:card>
    
    <!-- Here I need an header to display the number of contacts-->
    <div class="slds-p-around--large">
     
        <p style="color:red">Total Contacts = {!v.wrapperList.CountContacts}</p>
      
    <table class="slds-table slds-table--bordered slds-table--cell-buffer">
        <thead>
            <tr class="slds-text-title--caps">
                <th scope="col">
                    <div class="slds-truncate" title="First Name">First Name</div>
                </th>
                <th scope="col">
                    <div class="slds-truncate" title="First Name">Last Name</div>
                </th>
                
                <th scope="col">
                    <div class="slds-truncate" title="First Name">Email</div>
                </th>
                <th scope="col">
                    <div class="slds-truncate" title="LeadSource">LeadSource</div>
                </th>
                
            </tr>
        </thead>
        <!--table body start, 
        Iterate contact list as a <tr> 
        -->
        <tbody>
            <aura:iteration items="{!v.wrapperList.lstContact}" 
                            var="con">
                
                <tr>
                    <th scope="row">
                        <div class="slds-truncate" title="{!con.FirstName}">{!con.FirstName}</div>
                    </th>
                    <th scope="row">
                        <div class="slds-truncate" title="{!con.LastName}">{!con.LastName}</div>
                    </th>
                    <th scope="row">
                        <div class="slds-truncate" title="{!con.Email}">{!con.Email}</div>
                    </th>
                    <th scope="row">
                        <div class="slds-truncate" title="{!con.LeadSource}">{!con.LeadSource}</div>
                    </th>
                    
                </tr>
            </aura:iteration>
            
        </tbody>
        
    </table>
    </div>
</aura:component>


CallApexClassComponentBaseController.js
---------------------------------------
({
 Condata : function(component,event,helper) {
 helper.callServer(
            component, //component
            "c.getContacts", //method
            "v.wrapperList"   //attribute , this goes into helper
        );
    }
})


ContactController.apxc
----------------------
public with sharing class ContactController {
    @AuraEnabled
    public static wrapperClass getContacts() {
        //create an object of wrapper class
        wrapperClass wrapClass = new wrapperClass();
        
        wrapClass.lstContact=[select Id, FirstName,LastName,Email,LeadSource FROM Contact 
                              where Email != NULL
                              AND Account.Name != NULL 
                              AND LeadSource != NULL
                              ORDER BY NAME];
        
        //now size of the list
        wrapClass.CountContacts=wrapClass.lstContact.size();
        
        return wrapClass;
    }
      public class wrapperClass{
        @AuraEnabled public List<contact> lstContact{get;set;}
        @AuraEnabled public Integer CountContacts{get;set;}
       
    }
 }

My requirement is I want to display the output in mobile devices say IPhone 6s , galaxy s9.

Please le tme know how to proceed on this? Is there a way where we can make the lightning URL available in sites?

smita

 
Hello
I am trying to understand how to use base utility helper method in lighting component.
Base.cmp
--------
<aura:component abstract="true">
	{!v.body}
</aura:component>


BaseHelper.js
--------------
({
    callServer : function(component,method,callback,params) {
        var action = component.get(method);
        if (params) {
            action.setParams(params);
        }
       
        action.setCallback(this,function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                // pass returned value to callback function
                callback.call(this,response.getReturnValue());  
            } else if (state === "ERROR") {
                // generic error handler
                var errors = response.getError();
                if (errors) {
                    console.log("Errors", errors);
                    if (errors[0] && errors[0].message) {
                        throw new Error("Error" + errors[0].message);
                    }
                } else {
                    throw new Error("Unknown Error");
                }
            }
        });
       
        $A.enqueueAction(action);
    }
})


ApexController.axpc
-------------------
public with sharing class ApexController {
    @AuraEnabled
    public static List<Contact> getContacts() {
        List<Contact> contacts = [select Id, Name, MailingStreet, Phone, Email FROM Contact];
        return contacts;
    }
}


CallApexClassCmpBase.cmp
------------------------

<aura:component controller="ApexController">
	
    <lightning:card title="Bring Contact data">
       
          <aura:set attribute="actions">
       
              <lightning:button label="Contact Data" onclick="{!c.Condata}" />
          </aura:set> 
   
    </lightning:card>
    
</aura:component>


In the controller.js of the above component

({
 Condata : function(component,event,helper) {
 helper.callServer(
            component,
            "c.getContacts",
            function(response) { 
               console.log('Contacts data'+JSON.stringify(response));
            }
        );
      
    }
})



<aura:application extends="force:slds">

    <c:CallApexClassCmpBase/>
     
 </aura:application>
when I preview this I am getting an error as below:

This page has an error. You might just need to refresh it. Action failed: etaPrime:CallApexclassCmpBase$controller$Condata [helper.callServer is not a function] Failing descriptor: {etaPrime:CallApexclassCmpBase$controller$Condata}

I am not able to figure out what is causing the issue,

Please help.

smita
I am newbie to lightining component and trying to understand applicaiton events.
I am passing value from child component to parent compnent via application event.

Here's the code. 
ApplicationCommunicationEvt
---------------------------

<aura:event type="APPLICATION" 
            description="Event template">
    <aura:attribute name="mesg"
                    type="string"
                    description="Communication Between Multiple Components"
                    access="global"/>

</aura:event>

ChildComponent.cmp
-------------------

<aura:component implements="flexipage:availableForAllPageTypes" 
                access="global">
    <aura:registerEvent type="c:ApplicationCommunicationEvt"
                        name="someName"/>
    
    <aura:attribute name="greeting"
                    type="string"/>
    
    <lightning:input type="string"
                     label="Enter Some Data Here"
                     aura:id="inpData"/>
    
    <lightning:button label="Click Here To Fire The Application Event"
                      onclick="{!c.FireApplicationEvent}"
                      variant="brand"/>
</aura:component>


ChilcComponentController.js
--------------------------

({
    FireApplicationEvent : function(component, event) {
        var message=component.find("inpData").get("v.value");
        alert('message='+message);
        var appEvent=$A.get("e.etaPrime:ApplicationCommunicationEvt");
        appEvent.setParams({"mesg":message});
        appEvent.fire();
    }
})


ParentComponent.cmp
--------------------

<aura:component implements="flexipage:availableForAllPageTypes"
                access="global">
    <!--This component will have an handle(or handle) the event-->
    
    <aura:attribute name="receivedevent"
                    type="string"/>

    <aura:handler event="c:ApplicationCommunicationEvt"
                  action="{!c.HandleTheApplicationEvent}"/>
    
    <!--Now this attribute receivedevent will get the value from the attribute of event-->
    <div class="slds-m-around_xx-small">
        <c:ChildComponent /> 
        <div>
        <p>{!v.receivedevent}</p> 
        </div>
        
    </div>
    
</aura:component>

ParentComponentController.js
-----------------------------

({
	HandleTheApplicationEvent : function(component, event) {
		var evtattribute=event.getParams("mesg");
        alert(evtattribute);
        var response="something is good";
        
        if (evtattribute==='Hi')
        {
            response="Hello";
        }
        
        alert('Now response='+response);
        component.set("v.receivedevent",response);
	}
})
My requirement is if attribute in event is   Hi  then it should show me output as    Hello.

But in parentcomponent controller, the alert(evtattribute) is returning [object object]
so its not taking value in attribute  mesg.

Please help me out.

smita
 
Hello
I am using rest api to update multiple records between two sfdc developer orgnzs using apex code.

Number of records to be updated is less than 50000.

Here is the approach I am following:
1. perform an HTTPGet to retrieve the records
2. Then perform HTTPPUT to update the records in destination.

HDFC is the destination orgnz.
@HTTPGET
webservice static List<Account> SendMultipleRecordsToSource()  
{
   List<Account> accList=[SELECT Id,Name,Phone FROM Account where Name LIKE '%LockHeed Martin%'];
   return accList;
}

@HTTPPUT
webservice static List<Account> UpdateMultipleAccounts()  
{
    RestRequest req=RestContext.Request;
    
    RestResponse res=RestContext.Response;
    
    string req_body=req.RequestBody.ToString();
    
    List<Account> FromSourceList;
        
    if (req_body != NULL)
    {
            
       FromSourceList=(List<Account>)JSOn.Deserialize(req_body,List<Account>.class);
            
       if (FromSourceList.size() > 0)
       {
         Upsert(FromSourceList);
       }
    }
    return FromSourceList;
}
Flipkart is the source orgnz
public PageReference FetchMultipleRecordsForUpdate()
     {
       if (accesstoken != NULL)  
       {
          Http h = new Http();
          
          HttpRequest req = new HttpRequest();
        
          req.setMethod('GET'); 
        
          req.setHeader('Authorization','Bearer '+Helper.GetAccessToken().access_token);
        
          req.setHeader('Content-Type','application/json; charset=UTF-8'); 
        
          req.setHeader('Accept','application/json');
        
          req.setEndpoint('https://ap2.salesforce.com/services/apexrest/AccountRest');   
            
          HttpResponse res;
          
          try
          {
           res=h.send(req);
           
          }   
          catch(System.CallOutException ex)
          {
            system.debug('--callout error:--'+ex);
          }         
           
          accList = (List<Account>)JSON.deserialize(res.getBody(),List<Account>.class);
            
          List<Account> newList=new List<Account>();
         
 for(Account a:accList)
          {
            a.Name='LockHeed Martin'+generateRandomString(2);
            a.Phone='3443244324';
            
            newList.add(a);
          }          
          accList=new List<Account>(newList);
          
          system.debug('--Final accList --'+accList );
        }  
         return null;
     }

a) Is it possible to perform a single rest api call for the above scenario? If yes please let me know.

b) If more than 50K records then what approach do we use?

smita




 
I am learning the basics of rest api integration.
I am using two sfdc developer orgnzs. flipkart(is the source) and hdfc(is the destination).

I am calling a webservice defined in destination from source to check if an account name already exists.

I am using OAUTH2.0 authentication and I have access token generated.

code in destination side.
code in destination side
===================
@RestResource(UrlMapping='/RestMapping1/*')
global class RestObject
{
@HTTPGet
   webservice static void SearchByAccountName()
   {
     String account_name=RestContext.request.params.get('accName');
     
     system.debug('account Name found in destination = '+account_Name);
     
   }
}

code in source side
==============
Public PageReference SearchByAccountName()
       {
         if (accesstoken != NULL)
         {
       
           HTTP h = new HTTP();
     
           HTTPRequest req = new HTTPrequest();
     
           req.setMethod('GET');
     
           req.setHeader('Authorization','Bearer '+accesstoken);
       
           req.setHeader('Content-Type','application/json; charset=UTF-8');
       
           req.setHeader('Accept','application/json');
       
           acc=[select Name from Account where Name LIKE '%Sunshine%' LIMIT 1];
           
           req.setEndpoint('https://ap2.salesforce.com/services/apexrest/RestMapping1?accName='+acc.Name);
           
           HTTPResponse resp;
           try
           {
             resp=h.send(req);
             string json=resp.getBody();
             system.debug('json = '+json);
            
           }
       
           catch(system.CallOutException ex)
           {
           
           }

when I check debug logs I am getting statuscode=400 (bad request).
Can any one tell me where is the issue and how to resolve it?

smita
I am new to named credential concept in sfdc rest integration.
can anyone explain this with an example?

smita
Hello
I am new to writing test class. I need help in writing test class for the following code.
scenairo: when I create a new account from UI, a nee opportunity record gets created under the account.
public class CreateNewOpportunity
{
   public List<Opportunity> oppList=new List<Opportunity>();
   
   public void CreateOpportunity(List<Account> accList)
   {
     for(Account a:accList)
     {
       Opportunity o = new Opportunity();
       o.AccountID=a.ID;
       
       o.Name=a.Name;
       o.CloseDate=System.Today().addDays(3);
       
       o.StageName='Prospecting';
       
       oppList.add(o);
     }
     
     if (oppList.size() > 0)
         Database.Insert(oppList);
   }
}

trigger trg_createnewoppor on Account (after Insert,after update)
{
  if ((Trigger.isInsert) || (Trigger.IsBefore))
  {
    CreateNewOpportunity o = new CreateNewOpportunity();
    o.CreateOpportunity(Trigger.New);
  }
}


Thanks
smita
I have a code where I am binding account object , Type field values to an custom picklist in visualforce page.
when I run the code many of the picklist values are repeated.
 
public class BindPicklistValues
{
    public String strSelected{get;set;}
    
    public List<SelectOption> options{get;set;}
    
    public List<SelectOption> getValues()
    {
      strSelected='';
      
      options=new List<SelectOption>();
      options.add(new selectOption('', '- None -'));
  
      
      for(Account a:[select ID,Type from Account])
       {
         if (a != NULL)
         {
         system.debug('value of a='+a);
           options.add(new SelectOption(a.ID,a.Type));
         }
       }
       
       return options;
    }
}

<apex:page controller="BindPicklistValues">

    <apex:form >
    
        <apex:selectList value="{!strSelected}" 
                         multiselect="false" 
                         size="1">
                         
            <apex:selectOptions value="{!Values}"/>
            
        </apex:selectList>
    </apex:form>
</apex:page>

Picklist values  'Prospect' is repeated two times , 'Customer-Direct" is repeated 3 times in the picklist.
please let me know the issue.

smita
Can any one please explain how remotng in salesforce works?
In what specific scenarios it is used and its advantages.

For ex: if I have json data and I need to display 1 lakh records in visual force page does remoting help?

I see the techncial jargon in all posts but its not very clear to me.

Thanks
smita
 
I am getting json data from an external webservice. The format of json data is as follows.
      Fullname=Michael$stone
      homephone=239923923 
I need to map the firstname and lastname to the Lead object standard fields.
so firstname=Michael and lastname=stone.

so my query is how to split the fulname in json data and then store into lead object fields.

Thanks
Smita B
 
I created a visual flow. In the screen I dropped a displayText and the content inside  is "Please do . Appeal flow"
I  want to make the Phrase "Appeal Flow" as a link and when I click it the visual flow should end.

This screen is the last and when I click Finish it comes back to the start of the flow.

How to do this in the flow?

Please suggest urgent alternatives with solution.

thanks
smita 
 
Hello
I am trying to understand how to use base utility helper method in lighting component.
Base.cmp
--------
<aura:component abstract="true">
	{!v.body}
</aura:component>


BaseHelper.js
--------------
({
    callServer : function(component,method,callback,params) {
        var action = component.get(method);
        if (params) {
            action.setParams(params);
        }
       
        action.setCallback(this,function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                // pass returned value to callback function
                callback.call(this,response.getReturnValue());  
            } else if (state === "ERROR") {
                // generic error handler
                var errors = response.getError();
                if (errors) {
                    console.log("Errors", errors);
                    if (errors[0] && errors[0].message) {
                        throw new Error("Error" + errors[0].message);
                    }
                } else {
                    throw new Error("Unknown Error");
                }
            }
        });
       
        $A.enqueueAction(action);
    }
})


ApexController.axpc
-------------------
public with sharing class ApexController {
    @AuraEnabled
    public static List<Contact> getContacts() {
        List<Contact> contacts = [select Id, Name, MailingStreet, Phone, Email FROM Contact];
        return contacts;
    }
}


CallApexClassCmpBase.cmp
------------------------

<aura:component controller="ApexController">
	
    <lightning:card title="Bring Contact data">
       
          <aura:set attribute="actions">
       
              <lightning:button label="Contact Data" onclick="{!c.Condata}" />
          </aura:set> 
   
    </lightning:card>
    
</aura:component>


In the controller.js of the above component

({
 Condata : function(component,event,helper) {
 helper.callServer(
            component,
            "c.getContacts",
            function(response) { 
               console.log('Contacts data'+JSON.stringify(response));
            }
        );
      
    }
})



<aura:application extends="force:slds">

    <c:CallApexClassCmpBase/>
     
 </aura:application>
when I preview this I am getting an error as below:

This page has an error. You might just need to refresh it. Action failed: etaPrime:CallApexclassCmpBase$controller$Condata [helper.callServer is not a function] Failing descriptor: {etaPrime:CallApexclassCmpBase$controller$Condata}

I am not able to figure out what is causing the issue,

Please help.

smita
I am newbie to lightining component and trying to understand applicaiton events.
I am passing value from child component to parent compnent via application event.

Here's the code. 
ApplicationCommunicationEvt
---------------------------

<aura:event type="APPLICATION" 
            description="Event template">
    <aura:attribute name="mesg"
                    type="string"
                    description="Communication Between Multiple Components"
                    access="global"/>

</aura:event>

ChildComponent.cmp
-------------------

<aura:component implements="flexipage:availableForAllPageTypes" 
                access="global">
    <aura:registerEvent type="c:ApplicationCommunicationEvt"
                        name="someName"/>
    
    <aura:attribute name="greeting"
                    type="string"/>
    
    <lightning:input type="string"
                     label="Enter Some Data Here"
                     aura:id="inpData"/>
    
    <lightning:button label="Click Here To Fire The Application Event"
                      onclick="{!c.FireApplicationEvent}"
                      variant="brand"/>
</aura:component>


ChilcComponentController.js
--------------------------

({
    FireApplicationEvent : function(component, event) {
        var message=component.find("inpData").get("v.value");
        alert('message='+message);
        var appEvent=$A.get("e.etaPrime:ApplicationCommunicationEvt");
        appEvent.setParams({"mesg":message});
        appEvent.fire();
    }
})


ParentComponent.cmp
--------------------

<aura:component implements="flexipage:availableForAllPageTypes"
                access="global">
    <!--This component will have an handle(or handle) the event-->
    
    <aura:attribute name="receivedevent"
                    type="string"/>

    <aura:handler event="c:ApplicationCommunicationEvt"
                  action="{!c.HandleTheApplicationEvent}"/>
    
    <!--Now this attribute receivedevent will get the value from the attribute of event-->
    <div class="slds-m-around_xx-small">
        <c:ChildComponent /> 
        <div>
        <p>{!v.receivedevent}</p> 
        </div>
        
    </div>
    
</aura:component>

ParentComponentController.js
-----------------------------

({
	HandleTheApplicationEvent : function(component, event) {
		var evtattribute=event.getParams("mesg");
        alert(evtattribute);
        var response="something is good";
        
        if (evtattribute==='Hi')
        {
            response="Hello";
        }
        
        alert('Now response='+response);
        component.set("v.receivedevent",response);
	}
})
My requirement is if attribute in event is   Hi  then it should show me output as    Hello.

But in parentcomponent controller, the alert(evtattribute) is returning [object object]
so its not taking value in attribute  mesg.

Please help me out.

smita
 
Hello
I am using rest api to update multiple records between two sfdc developer orgnzs using apex code.

Number of records to be updated is less than 50000.

Here is the approach I am following:
1. perform an HTTPGet to retrieve the records
2. Then perform HTTPPUT to update the records in destination.

HDFC is the destination orgnz.
@HTTPGET
webservice static List<Account> SendMultipleRecordsToSource()  
{
   List<Account> accList=[SELECT Id,Name,Phone FROM Account where Name LIKE '%LockHeed Martin%'];
   return accList;
}

@HTTPPUT
webservice static List<Account> UpdateMultipleAccounts()  
{
    RestRequest req=RestContext.Request;
    
    RestResponse res=RestContext.Response;
    
    string req_body=req.RequestBody.ToString();
    
    List<Account> FromSourceList;
        
    if (req_body != NULL)
    {
            
       FromSourceList=(List<Account>)JSOn.Deserialize(req_body,List<Account>.class);
            
       if (FromSourceList.size() > 0)
       {
         Upsert(FromSourceList);
       }
    }
    return FromSourceList;
}
Flipkart is the source orgnz
public PageReference FetchMultipleRecordsForUpdate()
     {
       if (accesstoken != NULL)  
       {
          Http h = new Http();
          
          HttpRequest req = new HttpRequest();
        
          req.setMethod('GET'); 
        
          req.setHeader('Authorization','Bearer '+Helper.GetAccessToken().access_token);
        
          req.setHeader('Content-Type','application/json; charset=UTF-8'); 
        
          req.setHeader('Accept','application/json');
        
          req.setEndpoint('https://ap2.salesforce.com/services/apexrest/AccountRest');   
            
          HttpResponse res;
          
          try
          {
           res=h.send(req);
           
          }   
          catch(System.CallOutException ex)
          {
            system.debug('--callout error:--'+ex);
          }         
           
          accList = (List<Account>)JSON.deserialize(res.getBody(),List<Account>.class);
            
          List<Account> newList=new List<Account>();
         
 for(Account a:accList)
          {
            a.Name='LockHeed Martin'+generateRandomString(2);
            a.Phone='3443244324';
            
            newList.add(a);
          }          
          accList=new List<Account>(newList);
          
          system.debug('--Final accList --'+accList );
        }  
         return null;
     }

a) Is it possible to perform a single rest api call for the above scenario? If yes please let me know.

b) If more than 50K records then what approach do we use?

smita




 
I am learning the basics of rest api integration.
I am using two sfdc developer orgnzs. flipkart(is the source) and hdfc(is the destination).

I am calling a webservice defined in destination from source to check if an account name already exists.

I am using OAUTH2.0 authentication and I have access token generated.

code in destination side.
code in destination side
===================
@RestResource(UrlMapping='/RestMapping1/*')
global class RestObject
{
@HTTPGet
   webservice static void SearchByAccountName()
   {
     String account_name=RestContext.request.params.get('accName');
     
     system.debug('account Name found in destination = '+account_Name);
     
   }
}

code in source side
==============
Public PageReference SearchByAccountName()
       {
         if (accesstoken != NULL)
         {
       
           HTTP h = new HTTP();
     
           HTTPRequest req = new HTTPrequest();
     
           req.setMethod('GET');
     
           req.setHeader('Authorization','Bearer '+accesstoken);
       
           req.setHeader('Content-Type','application/json; charset=UTF-8');
       
           req.setHeader('Accept','application/json');
       
           acc=[select Name from Account where Name LIKE '%Sunshine%' LIMIT 1];
           
           req.setEndpoint('https://ap2.salesforce.com/services/apexrest/RestMapping1?accName='+acc.Name);
           
           HTTPResponse resp;
           try
           {
             resp=h.send(req);
             string json=resp.getBody();
             system.debug('json = '+json);
            
           }
       
           catch(system.CallOutException ex)
           {
           
           }

when I check debug logs I am getting statuscode=400 (bad request).
Can any one tell me where is the issue and how to resolve it?

smita
Hello
I am new to writing test class. I need help in writing test class for the following code.
scenairo: when I create a new account from UI, a nee opportunity record gets created under the account.
public class CreateNewOpportunity
{
   public List<Opportunity> oppList=new List<Opportunity>();
   
   public void CreateOpportunity(List<Account> accList)
   {
     for(Account a:accList)
     {
       Opportunity o = new Opportunity();
       o.AccountID=a.ID;
       
       o.Name=a.Name;
       o.CloseDate=System.Today().addDays(3);
       
       o.StageName='Prospecting';
       
       oppList.add(o);
     }
     
     if (oppList.size() > 0)
         Database.Insert(oppList);
   }
}

trigger trg_createnewoppor on Account (after Insert,after update)
{
  if ((Trigger.isInsert) || (Trigger.IsBefore))
  {
    CreateNewOpportunity o = new CreateNewOpportunity();
    o.CreateOpportunity(Trigger.New);
  }
}


Thanks
smita
Can any one please explain how remotng in salesforce works?
In what specific scenarios it is used and its advantages.

For ex: if I have json data and I need to display 1 lakh records in visual force page does remoting help?

I see the techncial jargon in all posts but its not very clear to me.

Thanks
smita
 
Hello friends
I have a custom object called fan which has ID field(say fanID) and email as an mandatory field.
There is a validation code in apex which says every fan must have a unique emailID.
Before this email validation rule was written,   legacy records were inserted into the fan object, so as of now 30K users have the same email ID but different fanID.
I need to have one Fan ID per unique Email.

so can anyone please suggest how I approach this issue the bestv possible way?

thanks
smita
Hello
I have json data as follows.

I need help in creating an object design for this json data so when I deserialize the json then I want to store in backend.

Please help me in creating the object design.
{
  "invoiceList": [
    {
      "totalPrice": 5.5,
      "statementDate": "2011-10-04T16:58:54.858Z",
      "lineItems": [
        {
          "UnitPrice": 1,
          "Quantity": 5,
          "ProductName": "Pencil"
        },
        {
          "UnitPrice": 0.5,
          "Quantity": 1,
          "ProductName": "Eraser"
        }
      ],
      "invoiceNumber": 1
    },
    {
      "totalPrice": 11.5,
      "statementDate": "2011-10-04T16:58:54.858Z",
      "lineItems": [
        {
          "UnitPrice": 6,
          "Quantity": 1,
          "ProductName": "Notebook"
        },
        {
          "UnitPrice": 2.5,
          "Quantity": 1,
          "ProductName": "Ruler"
        },
        {
          "UnitPrice": 1.5,
          "Quantity": 2,
          "ProductName": "Pen"
        }
      ],
      "invoiceNumber": 2
    }
  ]
}
Thanks
smitaB