• Nageswara reddy
  • NEWBIE
  • 25 Points
  • Member since 2012

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 43
    Questions
  • 16
    Replies

HI ALL,

 

          I am new to devleopment.  i have  one custom filed in  account  named as 'NoofContacts ' data type is Integer,  i need tigger code  how many contacts are there in particular account, when i am inserting one contact in particular account, hte noofcontact fileld  in account increased one automatically, same as delete contact, the noofcontact  will be decreased, i am able  to do this, but i am logged ate updating the contact , if  i update the contact ,i will change the account,then old acocunt noofcontact filed  willbe decreased by one and new account noofcontacts filed is deleted by one, iam logged here ,plz any one help

 

HI all,

 

 

 I am facing problem  with string .Split using a semi-colon

 

String address=add2;  

address=Abbyville,null,Kansas,92274|1520 Malley Road,Anchorage,Alaska,99501|

string[] spilt= address.split('\\;'); or String[]split=address.split(';');
for(string s: spilt)
{
system.debug('***********'+s);

}

 

 

 i  am getting like this way

5]
03:18:49.816 (816967000)|HEAP_ALLOCATE|[375]|Bytes:4
03:18:49.817 (817007000)|HEAP_ALLOCATE|[375]|Bytes:8
03:18:49.817 (817015000)|HEAP_ALLOCATE|[375]|Bytes:4
03:18:49.817 (817047000)|HEAP_ALLOCATE|[375]|Bytes:76
03:18:49.817 (817063000)|VARIABLE_SCOPE_BEGIN|[375]|spilt|LIST<String>|true|false
03:18:49.817 (817092000)|VARIABLE_ASSIGNMENT|[375]|spilt|["Abbyville,null,Kansa (48 more) ..."]|0x56145e09
03:18:49.817 (817125000)|SYSTEM_METHOD_ENTRY|[376]|LIST<String>.iterator()
03:18:49.817 (817269000)|SYSTEM_METHOD_EXIT|[376]|LIST<String>.iterator()
03:18:49.817 (817293000)|SYSTEM_METHOD_ENTRY|[376]|system.ListIterator.hasNext()
03:18:49.817 (817309000)|HEAP_ALLOCATE|[376]|Bytes:5
03:18:49.817 (817323000)|SYSTEM_METHOD_EXIT|[376]|system.ListIterator.hasNext()
03:18:49.817 (817339000)|HEAP_ALLOCATE|[376]|Bytes:68
03:18:49.817 (817360000)|VARIABLE_SCOPE_BEGIN|[376]|s|String|false|false
03:18:49.817 (817380000)|VARIABLE_ASSIGNMENT|[376]|s|"Abbyville,null,Kansa (48 more) ..."
03:18:49.817 (817392000)|STATEMENT_EXECUTE|[377]
03:18:49.817 (817403000)|STATEMENT_EXECUTE|[378]
03:18:49.817 (817413000)|HEAP_ALLOCATE|[378]|Bytes:11
03:18:49.817 (817430000)|HEAP_ALLOCATE|[378]|Bytes:79
03:18:49.817 (817445000)|SYSTEM_METHOD_ENTRY|[378]|System.debug(ANY)
03:18:49.817 (817480000)|USER_DEBUG|[378]|DEBUG|***********Abbyville,null,Kansas,92274&#124;1520 Malley Road,Anchorage,Ala

HI all,

 

  String method is not  working  in my apex class  ,

 I have written in my apex class like this

 

String address=add2;
string[] spilt= address.split(';');           
for(string s: spilt)
{
system.debug('***********'+s);

}

 Its  Not spiltting,

 

 Bur same code  when run in  console it will  work

 

String address='Abbyville,null,Kansas,92274&#124;1520 Malley Road,Anchorage,Alaska,99501&#124;';
string[] spilt= address.split(';');
for(string s: spilt)
{
system.debug('***********'+s);
}

 can any one help y it is not spiltting

 

Thanks

Nageswar

 

 

Hi alll,

  I Have witten test Calss  for apex class It covers 71%,

 

@isTest
private class TestAIOlineitems
{
static TestMethod void testAI01Line()
{
AIOlineitems.wrappo w=new AIOlineitems.wrappo();
Products__c p=new Products__c(name='xxxxx');
insert p;
Purchase_Order__c po=new Purchase_Order__c();
insert po;
Availability_In_Order__c ava =new Availability_In_Order__c(Purchase_Order__c=po.id);
insert ava;
Availability_In_Order_Lineitems__c ao=new Availability_In_Order_Lineitems__c(Availability_In_Order__c=ava.id,Products__c=p.id);
insert ao;
ApexPages.Currentpage().getParameters().put('id',ava.ID);

ApexPages.StandardController sc = new ApexPages.StandardController(ao);
AIOlineitems ai=new AIOlineitems(sc);
ai.Cancelpoedit();
ai.getproducts1();
ai.newPoline();
ApexPages.Currentpage().getParameters().put('id',ao.ID);
ai.editprodu();
ai.savepoedit();
ai.deleteprodu();

}

----------------------------------------------

 The apex class is

-------------------------------------------------------------

public class AIOlineitems {
public boolean check{set;get;}
id pid;
public boolean Newpol{set;get;}
public Integer sno{set;get;}
public Id poedit{set;get;}
public Availability_In_Order_Lineitems__c newPO{set;get;}
public Id poid{set;get;}
public map<id,Availability_In_Order_Lineitems__c> polmap{set;get;}
public Id productname{set;get;}
public integer cou{set;get;}
public List<SelectOption> productlist{set;get;}
public Availability_In_Order_Lineitems__c edu{set;get;}
public list<wrappo> POlist{set;get;}
public class wrappo{
public Availability_In_Order_Lineitems__c pol{set;get;}
public boolean newp{set;get;}
public integer no{set;get;}
public wrappo(){
pol=new Availability_In_Order_Lineitems__c();
newp=false;
}
}
    public AIOlineitems(ApexPages.StandardController controller) {
    productlist=new List<SelectOption>();
     polmap=new map<id,Availability_In_Order_Lineitems__c>();
    for(products__c p:[select id,Name from products__c ORDER BY Name DESC limit 1000])
    productlist.add(new SelectOption(p.Id,p.Name));
NewPol=false;
PoId=Apexpages.currentpage().getParameters().get('id');
POlist=new list<wrappo>();
cou=0;
general();

    }
    public void Cancelpoedit(){
    edu=null;
    }
    public void general(){
    edu=null;
    if(polist.size()>0)
    polist.clear();
for(Availability_In_Order_Lineitems__c pol:[select Id,Name,Products__c,Products__r.name,Ordered_Quantity__c,Available_Quantity__c,Total_Product_price__c  from Availability_In_Order_Lineitems__c where Availability_In_Order__c=:poid ORDER BY Name DESC limit 1000])
{
wrappo w=new wrappo();
w.pol=pol;
w.newp=false;
w.no=cou+1;
cou=cou+1;
polmap.put(pol.id,pol);
polist.add(w);

}
for(Availability_In_Order__C a:[select id,Purchase_Order__c from Availability_In_Order__C where id=:poid])
pid=a.Purchase_Order__c;
Purchase_Order__c p1=[select id,Available_Order_Accepted_by_executive__c from Purchase_Order__c where id=:pid];
check=p1.Available_Order_Accepted_by_executive__c;
}
    public List<SelectOption> getproducts1(){
return productlist;
}
    Public void newPoline(){
   wrappo w=new wrappo();
   
    newpo=new Availability_In_Order_Lineitems__c();
    w.pol=newpo;
    w.newp=true;
    w.no=cou+1;
cou=cou+1;
    polist.add(w);
    }
    
    public void editprodu(){
     poedit=Apexpages.currentpage().getParameters().get('editid');
     edu=polmap.get(poedit);
     productname=edu.products__c;
    sno=Integer.valueof(Apexpages.currentpage().getParameters().get('sno'));
    }
public pagereference savepoedit(){
pagereference p;
if(edu!=null){
If(edu.products__c!=productname)
edu.products__c=productname;
update edu;
polist[sno-1].newp=false;
}
else{
polist[cou-1].pol.Availability_In_Order__c=poid;
polist[cou-1].pol.Products__c=productname;
insert polist[cou-1].pol;
polist[cou-1].newp=false;
}
general();
p=new pagereference('/'+poid);
return p;
}
public pagereference deleteprodu(){
pagereference p;
   poedit=Apexpages.currentpage().getParameters().get('deid');
     Availability_In_Order_Lineitems__c delpo=polmap.get(poedit);
     if(delpo!=null)
     delete delpo;
     //polist.clear();
     p=new pagereference('/'+poid);
    //general();
    return p;
}
}

 

 this code is not covering rajesh can help me to  cover that code

Hi all. 

  i need test coverage for apex class,  My apex, calss is

 

public class AIOlineitems {
public boolean check{set;get;}
id pid;
public boolean Newpol{set;get;}
public Integer sno{set;get;}
public Id poedit{set;get;}
public Availability_In_Order_Lineitems__c newPO{set;get;}
public Id poid{set;get;}
public map<id,Availability_In_Order_Lineitems__c> polmap{set;get;}
public Id productname{set;get;}
public integer cou{set;get;}
public List<SelectOption> productlist{set;get;}
public Availability_In_Order_Lineitems__c edu{set;get;}
public list<wrappo> POlist{set;get;}
public class wrappo{
public Availability_In_Order_Lineitems__c pol{set;get;}
public boolean newp{set;get;}
public integer no{set;get;}
public wrappo(){
pol=new Availability_In_Order_Lineitems__c();
newp=false;
}
}
    public AIOlineitems(ApexPages.StandardController controller) {
    productlist=new List<SelectOption>();
     polmap=new map<id,Availability_In_Order_Lineitems__c>();
    for(products__c p:[select id,Name from products__c ORDER BY Name DESC limit 1000])
    productlist.add(new SelectOption(p.Id,p.Name));
NewPol=false;
PoId=Apexpages.currentpage().getParameters().get('id');
POlist=new list<wrappo>();
cou=0;
general();

    }
    public void Cancelpoedit(){
    edu=null;
    }
    public void general(){
    edu=null;
    if(polist.size()>0)
    polist.clear();
for(Availability_In_Order_Lineitems__c pol:[select Id,Name,Products__c,Products__r.name,Ordered_Quantity__c,Available_Quantity__c,Total_Product_price__c  from Availability_In_Order_Lineitems__c where Availability_In_Order__c=:poid ORDER BY Name DESC limit 1000])
{
wrappo w=new wrappo();
w.pol=pol;
w.newp=false;
w.no=cou+1;
cou=cou+1;
polmap.put(pol.id,pol);
polist.add(w);

}
for(Availability_In_Order__C a:[select id,Purchase_Order__c from Availability_In_Order__C where id=:poid])
pid=a.Purchase_Order__c;
Purchase_Order__c p1=[select id,Available_Order_Accepted_by_executive__c from Purchase_Order__c where id=:pid];
check=p1.Available_Order_Accepted_by_executive__c;
}
    public List<SelectOption> getproducts1(){
return productlist;
}
    Public void newPoline(){
   wrappo w=new wrappo();
   
    newpo=new Availability_In_Order_Lineitems__c();
    w.pol=newpo;
    w.newp=true;
    w.no=cou+1;
cou=cou+1;
    polist.add(w);
    }
    
    public void editprodu(){
     poedit=Apexpages.currentpage().getParameters().get('editid');
     edu=polmap.get(poedit);
     productname=edu.products__c;
    sno=Integer.valueof(Apexpages.currentpage().getParameters().get('sno'));
    }
public pagereference savepoedit(){
pagereference p;
if(edu!=null){
If(edu.products__c!=productname)
edu.products__c=productname;
update edu;
polist[sno-1].newp=false;
}
else{
polist[cou-1].pol.Availability_In_Order__c=poid;
polist[cou-1].pol.Products__c=productname;
insert polist[cou-1].pol;
polist[cou-1].newp=false;
}
general();
p=new pagereference('/'+poid);
return p;
}
public pagereference deleteprodu(){
pagereference p;
   poedit=Apexpages.currentpage().getParameters().get('deid');
     Availability_In_Order_Lineitems__c delpo=polmap.get(poedit);
     if(delpo!=null)
     delete delpo;
     //polist.clear();
     p=new pagereference('/'+poid);
    //general();
    return p;
}
}

 

 i have   written test class for the apex calss bu t i m getting error like  Compile Error: Constructor not defined: [AIOlineitems].<Constructor>() at line 15 column 23

@isTest
private class TestAIOlineitems
{
static TestMethod void testAI01Line()
{
Products__c p=new Products__c(name='xxxxx');
insert p;
Purchase_Order__c po=new Purchase_Order__c();
insert po;
Availability_In_Order__c ava =new Availability_In_Order__c(Purchase_Order__c=po.id);
insert ava;
Availability_In_Order_Lineitems__c ao=new Availability_In_Order_Lineitems__c(Availability_In_Order__c=ava.id,Products__c=p.id);
insert ao;
ApexPages.Currentpage().getParameters().put('id',p.ID);
AIOlineitems ai=new AIOlineitems();
ai.getproducts1();
ai.Cancelpoedit();
ai.newPoline();
ai.editprodu();
ai.savepoedit();
ai.deleteprodu();

}
}


HI all,

     

 Hi need to test coverage  for the apex class ,I am getting 66%, can any one help  to get more that 75%, My apex class is

 

 

public class acceptavailability
{
id i;
id pid;
public acceptavailability()
{
i=apexpages.currentpage().getparameters().get('id');
system.debug('i===='+i);
for(Availability_In_Order__c a:[select id,Purchase_Order__c from Availability_In_Order__c where id=:i])
{
pid=a.Purchase_Order__c;
system.debug('+++'+pid);
}
}
public pagereference update1()
{
pagereference p2=new pagereference('/'+i);
purchase_order__C p=[select id,Available_Order_Accepted_by_executive__c from purchase_order__C where id=:pid];
system.debug('p===='+p.id);
p.Available_Order_Accepted_by_executive__c=true;
update p;
return p2;
}
}

 

_---------------------- 

My test class is

 

 

@isTest
Private class Testacceptavailability
{
static TestMethod void TestAccept()
{
id i ='a07U000000AK8mW';
id pid;
Purchase_Order__c p = new Purchase_Order__c();
insert p;

Availability_In_Order__c a= New Availability_In_Order__c(Purchase_Order__c=p.id );
insert a;

acceptavailability ac= new acceptavailability();
ac.update1();

}

}

  The red lines are not covered any can help


HI all

  I hava On e XML File , Now i Want Get the value of particular Tag   from that XMl,  Suppose MY  XML file 

 is 

 

<GeocodeResponse>
<status>OK</status>
<result>
<type>locality</type>
<type>political</type>
<formatted_address>Hyderabad, Andhra Pradesh, India</formatted_address>
<address_component>
<long_name>Hyderabad</long_name>
<short_name>Hyderabad</short_name>
<type>locality</type>
<type>political</type>
</address_component>
<address_component>
<long_name>Ranga Reddy</long_name>
<short_name>R.R. District</short_name>
<type>administrative_area_level_2</type>
<type>political</type>
</address_component>
<address_component>
<long_name>Andhra Pradesh</long_name>
<short_name>Andhra Pradesh</short_name>
<type>administrative_area_level_1</type>
<type>political</type>
</address_component>
<address_component>
<long_name>India</long_name>
<short_name>IN</short_name>
<type>country</type>
<type>political</type>
</address_component>
<geometry>
<location>
<lat>17.3850440</lat>
<lng>78.4866710</lng>
</location>
<location_type>APPROXIMATE</location_type>
<viewport>
<southwest>
<lat>17.2145925</lat>
<lng>78.2305522</lng>
</southwest>
<northeast>
<lat>17.5553369</lat>
<lng>78.7427898</lng>
</northeast>
</viewport>
<bounds>
<southwest>
<lat>17.2383708</lat>
<lng>78.2401411</lng>
</southwest>
<northeast>
<lat>17.5794481</lat>
<lng>78.6913581</lng>
</northeast>
</bounds>
</geometry>
</result>
</GeocodeResponse>
 I want  that  coloured Location value , Any body can  help me 
 Thanks 
 Nageswar

Hi All,

 

 I have  Asingto field in event object , it  is related to user and calender objects, 

 

  Field Label is AsignTo , Filed Name is Owner,   Now I want the  Asignto   field ApI Name.

 

   Field Label  Field Name

 Asingto           Owner(user,calender)

 

 

Thanks All.

HI All,

 

  I  have written trigger  on School_del__c, that  will be updated phone number filed in acoount. but Now  I am  creating   a record in School_del__c  i am getting errormeassage like   

 

""Apex trigger UpdatephoneNumber caused an unexpected exception, contact your administrator: UpdatephoneNumber: execution of AfterInsert caused by: System.StringException: Invalid id: 467894: Trigger.UpdatephoneNumber: line 6, column 1"

 

 the  trigger code is

 

 

 

 

trigger UpdatephoneNumber on School_del__c (after insert ,after update) {

set<id> ss=new set<id>();
for(School_del__c sc:trigger.new) {
if(sc.PhoneNumber__c == null || sc.PhoneNumber__c != null) {
ss.add(sc.PhoneNumber__c );
}
}

map<id, Account> app=new map<id, Account>();
List<Account> accountsToUpdate = new List<Account>();

for(account a:[select id,phone from account where id in:ss limit 50000])
app.put(a.id, a);

for(School_del__c sc:trigger.new) {
if(sc.PhoneNumber__c == null ||sc.PhoneNumber__c != null) {
Account acc = app.get(sc.PhoneNumber__c );
acc.phone = sc.PhoneNumber__c;
accountsToUpdate.add(acc);
}
}

if(!accountsToUpdate.isEmpty()) {
update accountsToUpdate;
}
}

 

  any one can help to solve this error

 

 

Thanks

Nageswara Reddy.

Hi all,

         which formula or workflow suitable  for every two days sent the mail automatically eg: 29/5/2012(dd/mm/yy) after

two day 31/5/2012 then after 2 days 2/6/2012.....................