• SaurabhDua
  • NEWBIE
  • 15 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
Hello Experts, 

I am looking for the way to insert multiple records using XML and standard rest API. 
using JSON in am able to do for example
{
"records" :[{
    "attributes" : {"type" : "Account", "referenceId" : "ref1"},
    "name" : "SampleAccount1",
    "phone" : "1111111111",
    "website" : "www.salesforce1.com",
    "numberOfEmployees" : "100",
    "industry" : "Banking"   
    },{
    "attributes" : {"type" : "Account", "referenceId" : "ref2"},
    "name" : "SampleAccount2",
    "phone" : "2222222222",
    "website" : "www.salesforce2.com",
    "numberOfEmployees" : "250",
    "industry" : "Banking"
    },{
    "attributes" : {"type" : "Account", "referenceId" : "ref3"},
    "name" : "SampleAccount3",
    "phone" : "3333333333",
    "website" : "www.salesforce3.com",
    "numberOfEmployees" : "52000",
    "industry" : "Banking"
    },{
    "attributes" : {"type" : "Account", "referenceId" : "ref4"},
    "name" : "SampleAccount4",
    "phone" : "4444444444",
    "website" : "www.salesforce4.com",
    "numberOfEmployees" : "2500",
    "industry" : "Banking"
    }]

i am able to insert single records using XMl for example

<Account>
<name>SampleAccount1</name>
<phone>111111111</phone>
<website>www.salesforce.com</website>
</account>

is there a way to insert bulk records in the same format. 
what should be the end point for the composite structure

Regards
Saurabh
Help needed with the below error
User-added image

Here is my component

<aura:component>
     <aura:attribute name="boat" type="BoatType__c" access="public"/>
    <aura:handler name="change" value="{!v.boat}" action="{!c.refresh}"/>
    <!-- set up the aura:method for refresh -->
    <aura:method name="refresh" action="{!c.doInit}" access="public"
                 description="BoatDetailsController.js invokes refresh whenever boat is updated">
    </aura:method>
     
    <ui:scrollerWrapper class="scrollerSize">
        <!--Scrollable content here -->
        <aura:if isTrue="{!v.boatReviews.length==0}">
            <lightning:layoutItem class="slds-align_absolute-center" flexibility="auto" padding="around-small">   
                <ui:outputText value="No Reviews Available" />
            </lightning:layoutItem>
        </aura:if>
        <div class="slds-feed">
            <ul class="slds-feed__list">
                <aura:iteration items="{!v.boatReviews}" var="boatReview">
                    <li class="slds-feed__item">
                        <div class="slds-media__body">
                       <div class="slds-grid slds-has-flexi-truncate">
                            <a href="javascript:void(0)" onclick="{!c.onUserInfoClick}"
          data-userid="{!boatReview.CreatedBy.Id}">
          {!boatReview.CreatedBy.Name}
      </a>
                        &nbsp; &mdash; &nbsp; {!boatReview.CreatedBy.CompanyName}
   </div>
                         <p><lightning:formattedDateTime value="{!boatReview.CreatedDate}" 
                                   year="numeric" month="short" day="numeric"  
                                   hour="2-digit" minute="2-digit" hour12="true"/></p>
                        </div>
                    </li>
                </aura:iteration>
            </ul>
        </div>
    </ui:scrollerWrapper>
    
    
</aura:component>
Help needed with the below error
User-added image

Here is my component

<aura:component>
     <aura:attribute name="boat" type="BoatType__c" access="public"/>
    <aura:handler name="change" value="{!v.boat}" action="{!c.refresh}"/>
    <!-- set up the aura:method for refresh -->
    <aura:method name="refresh" action="{!c.doInit}" access="public"
                 description="BoatDetailsController.js invokes refresh whenever boat is updated">
    </aura:method>
     
    <ui:scrollerWrapper class="scrollerSize">
        <!--Scrollable content here -->
        <aura:if isTrue="{!v.boatReviews.length==0}">
            <lightning:layoutItem class="slds-align_absolute-center" flexibility="auto" padding="around-small">   
                <ui:outputText value="No Reviews Available" />
            </lightning:layoutItem>
        </aura:if>
        <div class="slds-feed">
            <ul class="slds-feed__list">
                <aura:iteration items="{!v.boatReviews}" var="boatReview">
                    <li class="slds-feed__item">
                        <div class="slds-media__body">
                       <div class="slds-grid slds-has-flexi-truncate">
                            <a href="javascript:void(0)" onclick="{!c.onUserInfoClick}"
          data-userid="{!boatReview.CreatedBy.Id}">
          {!boatReview.CreatedBy.Name}
      </a>
                        &nbsp; &mdash; &nbsp; {!boatReview.CreatedBy.CompanyName}
   </div>
                         <p><lightning:formattedDateTime value="{!boatReview.CreatedDate}" 
                                   year="numeric" month="short" day="numeric"  
                                   hour="2-digit" minute="2-digit" hour12="true"/></p>
                        </div>
                    </li>
                </aura:iteration>
            </ul>
        </div>
    </ui:scrollerWrapper>
    
    
</aura:component>
Hi ,

I have written a test class nad  I am getting this error in test class (System.QueryException: List has no rows for assignment to SObject), please help me . below is my test class and apex class 
 
public without sharing class CountCon {
    Integer count = 0;
    public Account a {get;set;}        
    
    public CountCon()
    {
        Account a = new Account();
        a = [Select NumberOfEmployees from Account where id = '0019000000DNnwo'];
        if(a.NumberOfEmployees != null)
            count = a.NumberOfEmployees;
    }           
    public PageReference incrementCounter() {
            count++;
            try
            {
                a = [Select id from Account where id = '0019000000DNnwo'];
                a.NumberOfEmployees = count;
                update a;
            }
            catch(exception e)
            {
                ApexPages.addMessages(e);
            }
            return null;
    }
       
                       
    public Integer getCount() {
        return count;
    }
}


Test class



@istest
public class CountCon_test
{ 
 static testmethod void test()
 {
 Account acc= new Account();
 Acc.name='test';
 insert Acc;
 
 CountCon cn = new CountCon ();
 cn.incrementCounter();
 cn.getCount();
 
 }
}

User-added image
Thanks,
Chanti.