• sonali verma
  • NEWBIE
  • 195 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 41
    Questions
  • 56
    Replies
Hi
I have a custom setting defined as Countries__c which has field  CountryCode__c. so I store as

United States Of Ameria    US
Canada                             CA
Congo                               CG

I have custom object C1__c which has a field called  country_region__c.

In browser URL I will append the ID of the C1 object and fetch the values in fields in visual force page

assume in record we have   country_region__c=United States Of Ameria 

I keep debug statement , value comes in C1Country_Region  property but it doesnt show country Name in picklist in visual force page.
public class C1Controller {

     public String C1Country_Region { get; set; }

     public String C1ID{get;set;}

    public C1__c   c1{get;set;}

   private List<SelectOption> countryCodeList = new List<SelectOption>();

   public String selectedCountryCode {get; set;}

   public C1Controller()

    {

        C1ID=ApexPages.currentpage().getparameters().get('id');

                
        if(String.isBlank(C1ID))

        {

                ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Invalid Id.');

                ApexPages.addMessage(myMsg);

                return;

        }

        else

        {

          try

          {

            fetchC1values();

          }

          catch(System.QueryException ex){
                 
              Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, 'No Record'));

          }

}

public List<SelectOption> getCountryCodes(){

    if(countryCodeList.isEmpty()){

        countryCodeList.add(new SelectOption("None", "--Select--"));

        for(Countries__c country :Countries__c.getAll().values()){

            countryCodeList.add(new SelectOption(country.CountryCode__c, country.Name));

        }

    }

    return countryCodeList;

}

  public void fetchC1values()

    {

         c1 = new C1__c();

          c1=[SELECT id, Country_Region__c

             FROM C1__c
           WHERE Encrypted_ID__c=:C1ID];

         if (c1 != NULL)

         {

             
       if(!string.isBlank(c1.Country_Region__c))

       {

          system.debug('country'+c1.Country_Region__c);

          C1Country_Region =c1.Country_Region__c;

         }
}

 In visual force page

 <apex:selectList value="{!C1Country_Region}" size="1">

 
               <apex:selectOptions value="{!countryCodes}"></apex:selectOptions>

                                                 
  </apex:selectList>

also if I select UnitedState of america from picklist then the same should be stored in the sobject.
any help will be grealty helpful

thanks
sonali
Hello 
can any one pls explain what is opportunity line items schedule, actually I dont see it in workbench object.

How it related to opportunity line items and what actuall process involved.

thanks
sonali
Hi
I am just learning custom settings and here is my code.
I created a custom setting name as CustAccount and inserted 3 records having fields ID and Name, both are type Text.
public class customsettings
{
   public List<CustAccount__c> code { get; set; }
   public customsettings()
   {
     code=CustAccount__c.getall().values();
   }
}
<apex:page controller="customsettings">
 <apex:form >
 <apex:pageBlock >
 <apex:pageBlockTable value="{!code}"
                      var="a">
                      
         <apex:column value="{!a.Name}"/>  
     </apex:pageBlockTable>
 </apex:pageBlock>
 </apex:form>
</apex:page>

Now I want to update single record at a time.
Please tell me how this can be achieved.

Thanks
sonali verma
 
Hi
I wan to display all contacts associated with account name once the account is seledted through a lookup in a selarate pagebblock table
in same vf page.
public class SelectAccountThroughLookup
{
    //I need to select account name from contact lookup. so I need variable of type contact
    private Contact con;
    
    public boolean check{get;set;}
    
    public SelectAccountThroughLookup(ApexPages.StandardController stdcontroller) 
    {
      this.con=(Contact)stdcontroller.getRecord();
    }
    
    public SelectAccountThroughLookup()
    {
      //check=false;
    }
    
    public List<Contact> getShowContactName()
    {
      List<Contact> conList=[select LastName from Contact where Name=:con.AccountID];
      return conList;
    }
 
}
<apex:page standardController="contact"
           extensions="SelectAccountThroughLookup">

<apex:form >
<apex:pageBlock title="Select Account Name from Lookup">
<apex:outputLabel >Select Account Name</apex:outputLabel>

<apex:inputField id="field1"
                 value="{!Contact.AccountID}">
         
 <apex:actionSupport event="onchange"
                     id="id1"
                     reRender="check"/>
                                         
 </apex:inputField>
</apex:pageBlock>

<apex:outputPanel id="check">
<apex:pageBlock title="Contact Details">
<apex:pageBlockTable value="{!showContactName}"
                     var="c">
        <apex:outputText value="{!c.LastName}"></apex:outputText>
         
</apex:pageBlockTable>
   
</apex:pageBlock>
</apex:outputPanel>
</apex:form>           
</apex:page>
But action support is not working . pls guide me.

Thanks
sonali
 
Hi
I have 2 custom objects say Book1 and Book2 and I insert exactly same records in both the objects.
There is no relaitonship between Book1 and Book2.
Both objects have same fields Name and price respectively.
My requirement is when I update a record in Book1, then it should update the matching record in Book2.

I am stuck at the update level, pls help me out
here is the code
public class Book1Scenarios
{
  
  Book2__c book2=new Book2__c();      

//Insert is working
  public void Create(List<Book1__c> book1)
  {
    for(Book1__c b1: book1)
    {
      book2.Name=b1.Name;
      book2.price__c=b1.price__c;
      
    }
    
    insert book2;
   } 
   

// update operation.
   public void UpdateRecord(List<Book1__c> oldbook1)
   {
    List<Book2__c> oldbook2=[select Name,price__c from Book2__c];
    
    for(Book1__c b1:oldbook1)
    {
      for(Book2__c b2:oldbook2)
      {
         if((b1.Name == b2.Name) && (b1.price__c == b2.price__c))
         {
            b2.Name=b1.Name;
            b2.price__c=b1.price__c;
         }
      }
    }
    Database.update(oldbook2);
   }
   
}


trigger trg_Book1Scenarios on Book1__c (after Insert)
{
   Book1Scenarios b1=new Book1Scenarios();
   
   if (trigger.isInsert)
   {
    b1.create(Trigger.New);
   }
   
  if (trigger.isUpdate)
  {
    b1.UpdateRecord(Trigger.Old);
  }

   
}

sonali verma
divya

 
Hi
I have a requirement.When we update  Account record, the related Description field of contact object should get updated automatically.
 
I am able to achieve the requirement but I want to know whether we can use Map to optimize the code further.
Pls help me.
 
public class Account_ContactDescription
{
     public static void Update_Description(Set<Id> accountIds)
    {
                    
           list<Account> accountsWithContacts =[select Id,Name, (select Id,FirstName,LastName from Contacts) from Account  where Id IN : accountIds];
           
           list<Contact> contactsToUpdate=new list<Contact>();
           
           for(Account a:accountsWithContacts)   //loop through all queries 
          {
                 for(Contact convals:a.Contacts)
                {
                        convals.Description=convals.FirstName+' '+convals.LastName;
                         
                        contactsToUpdate.add(convals);
               }
           }
           
           update contactsToUpdate;
    }
}

trigger trg_Description on Account (before Update)
{
   
    Account_ContactDescription c=new Account_ContactDescription();
     
    Map<Id,Account> amap = new Map<Id,Account>([select Id from Account]);
     
    Set<Id> accountIds = amap.KeySet();
     
    c.Update_Description(accountIds);
          
}

Thanks
sonali

 
Hi
I have rest resource thru which I want to create multiple account and for each account I want to create multiple contacts.
Its working for single accout and multiple contacts.
Pls help me in understanding how to create multiple accounts and how to frame the json query for multiple account.
 
@RestResource(urlMapping='/BulkInsertaccountcontact/*')
global class Bulkinsert_accountcontact
{
   global class RequestBody 
   {
       Account a; //create single account
       List<Contact> cList;
   }
   
   global class myWrapper
   {
      List<Account> a;
      List<Contact> cList;
      public string status;
      public string message;
   }
   
   @HttpPost
   global static myWrapper doPost(RequestBody rb)
   {
      RestRequest req=RestContext.request;
      RestResponse res=RestContext.response;
   
      myWrapper response=new myWrapper(); //this is object of wrapper class
      
      List<Account> myList=new List<Account>();
      
      try
      {
        myList.add(rb.a);
        
        Insert myList;
        response.a=myList;
                
        for(Contact con:rb.cList)
        {
           con.AccountID=rb.a.ID;
        }
        
        //we need to insert contact List also
        Insert rb.cList;
        response.cList=rb.cList;
        response.status='Success';
        response.message='Created Successfully';
        
      }
      catch(exception ex)
      {
         response.a=null;
         response.cList=null;
         response.status='ERROR';
         response.Message='could not create record'+ ex.getMessage();
      }
      
      return response;
   }
}

workbench:
==========

{
   "rb":{

      "a":{

         "Name":"LG1",

         "SLAExpirationDate__c":"2016-4-21",

         "Active__c":"Yes",

         "SLA__c":"Platinum",

         "SLASerialNumber__c":"200"

      },

      "cList":[

         {

            "FirstName":"K1",

            "LastName":"K2"

         },

         {

            "FirstName":"K3",

            "LastName":"K4"

         }

      ]
      }
             
}

 
greetings
Has any body worked on community portal?
If so pls provide links and how to go about it.
In what way it is useful?​​​

sonali
Hi
Pls provide a basic example to start with soap api.
actually I need to execute it on my terminal & see the result.
I am not familiar with web services but yes I will brush up ​​​on that.
I request the people to be elaborate while replying.
a) In what type of scenario we use soap api
b) advantages and disadvantages of soap api compared to other api's.
c) what errors occur when we use soap api and how to resolve


sonali verma
​Hi all
I have 2 departments. hr_dept and finance_dept. User_A from hr_dept wants to share records to user_B   of finance dept.
How to do this?

I know in profiles for hr_dept object should have VIEW all permission.​ so user_A belonging to hr_dept object can share records.
Pls correct my understanding if wrong and if I am missing anything concrete pls do let me know

sonali verma​
Hello
I am updating account rating from opportunity trigger. whenever opportunity stagename='Closed won', then in acocount , rating = 'Hot'

public class AccountUpdates_from_oppor
{
   public void updateaccount(list<Opportunity> accountid)
   {
      list<ID> accids = new list<ID>();
     
      list<Account> accountratings_new  = new list<Account>();
     
      for(Opportunity o:accountid)
      {
         accids.add(o.accountid);        
      }
     
      list<Account> acctratings = [select Id,rating from Account where ID=:accids];
     
      for(Opportunity opp:accountid)
      {
         for(Account a:acctratings)
         {
           if (opp.StageName == 'Closed Won')
               a.Rating='Hot';
        
               accountratings_new.add(a);
         }       
      }
      Database.Update(accountratings_new);
  }
}

trigger trg_updateaccountratings on Opportunity (before Insert,before Update)
{
  if (trigger.IsBefore)
  {
    if (trigger.IsUpdate)
    {
     AccountUpdates_from_oppor a1 = new AccountUpdates_from_oppor();
     a1.updateaccount(Trigger.New);
    }
  }
}

@istest(SeeAllData=false)
private class Accountopportunity_Test
{
    private static testmethod void validatetest()
    {
         Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator'];
         User u = new User(Alias = 'sample', Email='standarduser@testorg.com',
         EmailEncodingKey='UTF-8', LastName='sampleLname', LanguageLocaleKey='en_US',
         LocaleSidKey='en_US', ProfileId = p.Id,
         TimeZoneSidKey='America/Los_Angeles', UserName='testnamesss@testorg.com');
        
         system.runAs(u)
         {
        
              Account  acn = new Account();
              acn.Name='test1';
            
              Opportunity opp = new Opportunity();
              opp.Name='test opp';
              opp.CloseDate=System.Today();
              opp.StageName='Closed Won';
             
              Test.StartTest();
             
              Database.Insert(acn);
              Database.Insert(opp);
              system.assertEquals(acn.Rating,''Hot');
             
              Test.StopTest();
          }
       }
   }

Apex class & trigger working fine.​
​But when I execute test class I am getting error as :  " System.AssertException: Assertion Failed: Expected: None, Actual: Hot"

Thanks
sonali​​
Hello
what is difference between stateful and stateless?
​Any issues if batch class is executed statelss (without stateful)?

when do we go for stateful and when do we go for stateless?

Please explain​
what is the difference between bulk api and batch apex?
is bulk api an substitute for batch apex and can we write code in bulk api based on business requirement?
How many records does BULK api process compared to batch apex
Do we have to manually write entire code when using BULK api to salesorce or is there in auto generate tool?

what errors do we encounter in bulk api?

like batch classescan multiple bulk api's be chained?

Please help me in understanding.

sonali​​​​
Hi
I want to understand a specific concept.
I have created​​ 2 batch apex classes say account and contact and now I need to run contact class only after account class fully completes(without any errors of course).

I schedule account class & then contact class, so when I click setup --> jobs --> scheduled jobs,   I can see both these jobs

As per documentation order of execution of jobs is not guaranteed.

so how do I make sure that contact batch job executes only successful execution of account batch job.

please be specific in replies.

sonali​​​
friends
can we call Database.executebatch in trigger?
if yes, then how to do and if no what can be the limitation.
concrete example will be helpful

sonali​​​​
Hello
I want to explictly use HTML tags & standard CSS for visual force page creation.
visual force page compiles but some how I am not able to display the data.

<apex:page standardController="Contact"
           extensions="MyContactInfo">
   <apex:form >
      <style>
         tr.dataRow {
           background-color:white;
         }
         tr.dataRow:hover {
           background-color: #e3f3ff;
         };
     </style>
     <apex:pageBlock >
        <table class="list " border="0" cellpadding="0" cellspacing="0">
           <tr class="headerRow">
              <th class="headerRow"> First Name</th>
              <th class="headerRow"> Last Name </th>
              <th class="headerRow"> Phone </th>
             
             
           </tr>
           <tr class="dataRow">
           <apex:pageBlock>
                <apex:pageBlockTable value="{!contvals}"
                                      var="c">
               <td class="dataCell">{!c.FirstName}</td>
              <td class="dataCell">{!c.LastName}</td>
              <td class="dataCell">{!c.phone}</td>
               
                </apex:pageBlockTable>
          
           </apex:pageBlock>
                         </tr>
               </table>
   </apex:pageBlock>
 </apex:form>
</apex:page>
​​
public class MyContactInfo
{
    list<Contact> con = [select FirstName,LastName,Phone from Contact];
   
    public MyContactInfo(ApexPages.StandardController controller)
    {
    }
       public list<Contact> getcontvals()
    {
           return con;   
    }
  }

​Pleas let me know where I am going wrong.

sonali​
Hello friends
I have search page, I enter account name and it will fetch relevant fields
I have given code in Visual force page and apex class
<apex:page standardController="Account"
           extensions="MySearch">
           tabStyle="Account">
          
 <apex:form>
 
       <apex:inputText value="{!searchstring}"/>
      
       <apex:commandButton value="{!SearchAccount}"
                           title="Account Search}"/>
                          
       <apex:pageBlock title="Account Info">
      
           <apex:pageBlockTable value="{!accts}"
                                var="a">
                               
                <apex:column value="{!a.Name}"/>
                <apex:column value="{!a.Type}"/>
               <apex:column value="{!a.Industry}"/>          
          
           </apex:pageBlockTable>
      
       </apex:pageBlock>
 
 </apex:form>
  </apex:page>

public class MySearch
{
    list<Account> accts;
    public String searchstring{get;set;}
    public MySearch(ApexPages.StandardController controller)
    {
    }
    public list<Account> getaccts()
    {
       return accts;
    }
      
    public PageReference SearchAccount()
    {
       accts = (list<Account>) [FIND :searchstring IN ALL FIELDS RETURNING Account(Name, Type, Industry)];
       return null;
    }
   
}
​​
when I compile apex class I am getting an error as : "Compile Error: Incompatible types since an instance of List<List<SObject>> is never an instance of List<Account> at line 18 column 16​

Please let me know how I can resolve this​

thanks
sonali
 
Hello
Please share knowledge .
like I want to know how​ we write code in eclipse
 like I have no knowledge on how deployment done in salesforce, what tools are used, what objects to deploy.

​what errors likewise how to fix them?
like when we deploy from eclipse.
please share ur knowledge.
thanks
sonali verma​

thanks
sonali​​​​
Hello
I want to understand critical differences between trigger.new & trigger.old.
trigger.old used in which events?
I see lot of documentation but any specific scenario will be helpful​​

thanks
sonali​​
Hi
I need help in writing a trigger for the below apex class.
when I create a new account, an opportunity record is created.


Public class OpporInsertAfterAccount
{
   public void Display(List<Account> accounts)
   {
         List<Opportunity> listOpportunities = new List<Opportunity>();
         for(Account oAccount:accounts)
        {
             Opportunity oOpportunity = new Opportunity();
             oOpportunity.Name = oAccount.Name;
             oOpportunity.AccountId = oAccount.Id;
             oOpportunity.StageName = 'Qualification';
             oOpportunity.CloseDate = System.today() + 30; //Closes 30 days from today
             listOpportunities.add(oOpportunity);
        }
    if (listOpportunities.isEmpty() == false)
    {
        Database.insert(listOpportunities);
    }
   }  
}

Thanks
sonali​​​
Hello friends
 I have a requirement where I need to display under each account name its related contacts & opportunities in a single visual force page.
like as follows:

Accname:AxisBank
contact1:
oppor1:

Kindly let me know.
regards
sonali verma


 
Hi
I have a custom setting defined as Countries__c which has field  CountryCode__c. so I store as

United States Of Ameria    US
Canada                             CA
Congo                               CG

I have custom object C1__c which has a field called  country_region__c.

In browser URL I will append the ID of the C1 object and fetch the values in fields in visual force page

assume in record we have   country_region__c=United States Of Ameria 

I keep debug statement , value comes in C1Country_Region  property but it doesnt show country Name in picklist in visual force page.
public class C1Controller {

     public String C1Country_Region { get; set; }

     public String C1ID{get;set;}

    public C1__c   c1{get;set;}

   private List<SelectOption> countryCodeList = new List<SelectOption>();

   public String selectedCountryCode {get; set;}

   public C1Controller()

    {

        C1ID=ApexPages.currentpage().getparameters().get('id');

                
        if(String.isBlank(C1ID))

        {

                ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Invalid Id.');

                ApexPages.addMessage(myMsg);

                return;

        }

        else

        {

          try

          {

            fetchC1values();

          }

          catch(System.QueryException ex){
                 
              Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, 'No Record'));

          }

}

public List<SelectOption> getCountryCodes(){

    if(countryCodeList.isEmpty()){

        countryCodeList.add(new SelectOption("None", "--Select--"));

        for(Countries__c country :Countries__c.getAll().values()){

            countryCodeList.add(new SelectOption(country.CountryCode__c, country.Name));

        }

    }

    return countryCodeList;

}

  public void fetchC1values()

    {

         c1 = new C1__c();

          c1=[SELECT id, Country_Region__c

             FROM C1__c
           WHERE Encrypted_ID__c=:C1ID];

         if (c1 != NULL)

         {

             
       if(!string.isBlank(c1.Country_Region__c))

       {

          system.debug('country'+c1.Country_Region__c);

          C1Country_Region =c1.Country_Region__c;

         }
}

 In visual force page

 <apex:selectList value="{!C1Country_Region}" size="1">

 
               <apex:selectOptions value="{!countryCodes}"></apex:selectOptions>

                                                 
  </apex:selectList>

also if I select UnitedState of america from picklist then the same should be stored in the sobject.
any help will be grealty helpful

thanks
sonali
Hi
I am just learning custom settings and here is my code.
I created a custom setting name as CustAccount and inserted 3 records having fields ID and Name, both are type Text.
public class customsettings
{
   public List<CustAccount__c> code { get; set; }
   public customsettings()
   {
     code=CustAccount__c.getall().values();
   }
}
<apex:page controller="customsettings">
 <apex:form >
 <apex:pageBlock >
 <apex:pageBlockTable value="{!code}"
                      var="a">
                      
         <apex:column value="{!a.Name}"/>  
     </apex:pageBlockTable>
 </apex:pageBlock>
 </apex:form>
</apex:page>

Now I want to update single record at a time.
Please tell me how this can be achieved.

Thanks
sonali verma
 
Hi
I wan to display all contacts associated with account name once the account is seledted through a lookup in a selarate pagebblock table
in same vf page.
public class SelectAccountThroughLookup
{
    //I need to select account name from contact lookup. so I need variable of type contact
    private Contact con;
    
    public boolean check{get;set;}
    
    public SelectAccountThroughLookup(ApexPages.StandardController stdcontroller) 
    {
      this.con=(Contact)stdcontroller.getRecord();
    }
    
    public SelectAccountThroughLookup()
    {
      //check=false;
    }
    
    public List<Contact> getShowContactName()
    {
      List<Contact> conList=[select LastName from Contact where Name=:con.AccountID];
      return conList;
    }
 
}
<apex:page standardController="contact"
           extensions="SelectAccountThroughLookup">

<apex:form >
<apex:pageBlock title="Select Account Name from Lookup">
<apex:outputLabel >Select Account Name</apex:outputLabel>

<apex:inputField id="field1"
                 value="{!Contact.AccountID}">
         
 <apex:actionSupport event="onchange"
                     id="id1"
                     reRender="check"/>
                                         
 </apex:inputField>
</apex:pageBlock>

<apex:outputPanel id="check">
<apex:pageBlock title="Contact Details">
<apex:pageBlockTable value="{!showContactName}"
                     var="c">
        <apex:outputText value="{!c.LastName}"></apex:outputText>
         
</apex:pageBlockTable>
   
</apex:pageBlock>
</apex:outputPanel>
</apex:form>           
</apex:page>
But action support is not working . pls guide me.

Thanks
sonali
 
Hi
I have 2 custom objects say Book1 and Book2 and I insert exactly same records in both the objects.
There is no relaitonship between Book1 and Book2.
Both objects have same fields Name and price respectively.
My requirement is when I update a record in Book1, then it should update the matching record in Book2.

I am stuck at the update level, pls help me out
here is the code
public class Book1Scenarios
{
  
  Book2__c book2=new Book2__c();      

//Insert is working
  public void Create(List<Book1__c> book1)
  {
    for(Book1__c b1: book1)
    {
      book2.Name=b1.Name;
      book2.price__c=b1.price__c;
      
    }
    
    insert book2;
   } 
   

// update operation.
   public void UpdateRecord(List<Book1__c> oldbook1)
   {
    List<Book2__c> oldbook2=[select Name,price__c from Book2__c];
    
    for(Book1__c b1:oldbook1)
    {
      for(Book2__c b2:oldbook2)
      {
         if((b1.Name == b2.Name) && (b1.price__c == b2.price__c))
         {
            b2.Name=b1.Name;
            b2.price__c=b1.price__c;
         }
      }
    }
    Database.update(oldbook2);
   }
   
}


trigger trg_Book1Scenarios on Book1__c (after Insert)
{
   Book1Scenarios b1=new Book1Scenarios();
   
   if (trigger.isInsert)
   {
    b1.create(Trigger.New);
   }
   
  if (trigger.isUpdate)
  {
    b1.UpdateRecord(Trigger.Old);
  }

   
}

sonali verma
divya

 
Hi
I have a requirement.When we update  Account record, the related Description field of contact object should get updated automatically.
 
I am able to achieve the requirement but I want to know whether we can use Map to optimize the code further.
Pls help me.
 
public class Account_ContactDescription
{
     public static void Update_Description(Set<Id> accountIds)
    {
                    
           list<Account> accountsWithContacts =[select Id,Name, (select Id,FirstName,LastName from Contacts) from Account  where Id IN : accountIds];
           
           list<Contact> contactsToUpdate=new list<Contact>();
           
           for(Account a:accountsWithContacts)   //loop through all queries 
          {
                 for(Contact convals:a.Contacts)
                {
                        convals.Description=convals.FirstName+' '+convals.LastName;
                         
                        contactsToUpdate.add(convals);
               }
           }
           
           update contactsToUpdate;
    }
}

trigger trg_Description on Account (before Update)
{
   
    Account_ContactDescription c=new Account_ContactDescription();
     
    Map<Id,Account> amap = new Map<Id,Account>([select Id from Account]);
     
    Set<Id> accountIds = amap.KeySet();
     
    c.Update_Description(accountIds);
          
}

Thanks
sonali

 
Hi
I have rest resource thru which I want to create multiple account and for each account I want to create multiple contacts.
Its working for single accout and multiple contacts.
Pls help me in understanding how to create multiple accounts and how to frame the json query for multiple account.
 
@RestResource(urlMapping='/BulkInsertaccountcontact/*')
global class Bulkinsert_accountcontact
{
   global class RequestBody 
   {
       Account a; //create single account
       List<Contact> cList;
   }
   
   global class myWrapper
   {
      List<Account> a;
      List<Contact> cList;
      public string status;
      public string message;
   }
   
   @HttpPost
   global static myWrapper doPost(RequestBody rb)
   {
      RestRequest req=RestContext.request;
      RestResponse res=RestContext.response;
   
      myWrapper response=new myWrapper(); //this is object of wrapper class
      
      List<Account> myList=new List<Account>();
      
      try
      {
        myList.add(rb.a);
        
        Insert myList;
        response.a=myList;
                
        for(Contact con:rb.cList)
        {
           con.AccountID=rb.a.ID;
        }
        
        //we need to insert contact List also
        Insert rb.cList;
        response.cList=rb.cList;
        response.status='Success';
        response.message='Created Successfully';
        
      }
      catch(exception ex)
      {
         response.a=null;
         response.cList=null;
         response.status='ERROR';
         response.Message='could not create record'+ ex.getMessage();
      }
      
      return response;
   }
}

workbench:
==========

{
   "rb":{

      "a":{

         "Name":"LG1",

         "SLAExpirationDate__c":"2016-4-21",

         "Active__c":"Yes",

         "SLA__c":"Platinum",

         "SLASerialNumber__c":"200"

      },

      "cList":[

         {

            "FirstName":"K1",

            "LastName":"K2"

         },

         {

            "FirstName":"K3",

            "LastName":"K4"

         }

      ]
      }
             
}

 
Hi
Pls provide a basic example to start with soap api.
actually I need to execute it on my terminal & see the result.
I am not familiar with web services but yes I will brush up ​​​on that.
I request the people to be elaborate while replying.
a) In what type of scenario we use soap api
b) advantages and disadvantages of soap api compared to other api's.
c) what errors occur when we use soap api and how to resolve


sonali verma
​Hi all
I have 2 departments. hr_dept and finance_dept. User_A from hr_dept wants to share records to user_B   of finance dept.
How to do this?

I know in profiles for hr_dept object should have VIEW all permission.​ so user_A belonging to hr_dept object can share records.
Pls correct my understanding if wrong and if I am missing anything concrete pls do let me know

sonali verma​
Hello
I am updating account rating from opportunity trigger. whenever opportunity stagename='Closed won', then in acocount , rating = 'Hot'

public class AccountUpdates_from_oppor
{
   public void updateaccount(list<Opportunity> accountid)
   {
      list<ID> accids = new list<ID>();
     
      list<Account> accountratings_new  = new list<Account>();
     
      for(Opportunity o:accountid)
      {
         accids.add(o.accountid);        
      }
     
      list<Account> acctratings = [select Id,rating from Account where ID=:accids];
     
      for(Opportunity opp:accountid)
      {
         for(Account a:acctratings)
         {
           if (opp.StageName == 'Closed Won')
               a.Rating='Hot';
        
               accountratings_new.add(a);
         }       
      }
      Database.Update(accountratings_new);
  }
}

trigger trg_updateaccountratings on Opportunity (before Insert,before Update)
{
  if (trigger.IsBefore)
  {
    if (trigger.IsUpdate)
    {
     AccountUpdates_from_oppor a1 = new AccountUpdates_from_oppor();
     a1.updateaccount(Trigger.New);
    }
  }
}

@istest(SeeAllData=false)
private class Accountopportunity_Test
{
    private static testmethod void validatetest()
    {
         Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator'];
         User u = new User(Alias = 'sample', Email='standarduser@testorg.com',
         EmailEncodingKey='UTF-8', LastName='sampleLname', LanguageLocaleKey='en_US',
         LocaleSidKey='en_US', ProfileId = p.Id,
         TimeZoneSidKey='America/Los_Angeles', UserName='testnamesss@testorg.com');
        
         system.runAs(u)
         {
        
              Account  acn = new Account();
              acn.Name='test1';
            
              Opportunity opp = new Opportunity();
              opp.Name='test opp';
              opp.CloseDate=System.Today();
              opp.StageName='Closed Won';
             
              Test.StartTest();
             
              Database.Insert(acn);
              Database.Insert(opp);
              system.assertEquals(acn.Rating,''Hot');
             
              Test.StopTest();
          }
       }
   }

Apex class & trigger working fine.​
​But when I execute test class I am getting error as :  " System.AssertException: Assertion Failed: Expected: None, Actual: Hot"

Thanks
sonali​​
Hello
what is difference between stateful and stateless?
​Any issues if batch class is executed statelss (without stateful)?

when do we go for stateful and when do we go for stateless?

Please explain​
Hi
I want to understand a specific concept.
I have created​​ 2 batch apex classes say account and contact and now I need to run contact class only after account class fully completes(without any errors of course).

I schedule account class & then contact class, so when I click setup --> jobs --> scheduled jobs,   I can see both these jobs

As per documentation order of execution of jobs is not guaranteed.

so how do I make sure that contact batch job executes only successful execution of account batch job.

please be specific in replies.

sonali​​​
Hello friends
I just begining to understand concept of batch apex.
But pls explain what is stateful & stateless in batch apex:?
In what scenario in real time do we implement statefull & vice versa.
which is better:?

Thanks
sonali