• Vidhi
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 20
    Questions
  • 8
    Replies
Hello,

I am trying to insert price book enty in test class.When i have inserted this and run that class it worked fine. But My so may test class is using price book.As i ran all the test class by clicking "Run All Test"  It is giving error

"System.DmlException: Insert failed. First exception on row 0; first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record: []"
How canm i solve this granulatity issue.

My code is this

Id pricebookId = Test.getStandardPricebookId();
     
        PricebookEntry standardPrice = new PricebookEntry(
             Pricebook2Id = pricebookId, Product2Id = objProduct.Id,
             UnitPrice = 10000, IsActive = true);
        insert standardPrice;
       
        // Create a custom price book
        Pricebook2 customPB = new Pricebook2(Name='Custom Pricebook', isActive=true);
        insert customPB;
       
        // 2. Insert a price book entry with a custom price.
        PricebookEntry customPrice = new PricebookEntry(
            Pricebook2Id = customPB.Id, Product2Id = objProduct.Id,
            UnitPrice = 12000, IsActive = true);
        insert customPrice;
  • September 03, 2014
  • Like
  • 0
Can we schedule a normal class which not batchable in apex.I  have a class in apex salesforce  to which i want to scheule but it is not batchable .Is there is any way to schedule the same ???
  • July 13, 2014
  • Like
  • 0
public void completeAuthorization() {
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setMethod('POST');
        req.setEndpoint('https://api.xero.com/oauth/AccessToken');
        req.setBody('');
        //req.setHeader('Content-Type','text/html');
        sign(req);
        HttpResponse res = null;
        res = new HttpResponse();
        res = h.send(req);
        System.debug('Response from request token request: ('+res.getStatusCode()+')'+res.getBody());
    }
  • May 13, 2014
  • Like
  • 0

Hello Friends,

 

I am trying to get the access token via Oauth 1.0 .But every time I am getting Oauth signature_invalid error.My header 

baseString = 'MyEndPoint'+'&'+EncodingUtil.urlEncode('oauthcallbackcall back PAge&oauth_consumer_key=myconsumerkey&oauth_nonce='+String.valueOf(Crypto.getRandomLong())+'&oauth_signature_method=HMAC-SHA1&oauth_timestamp='+String.valueOf(DateTime.now().getTime() / 1000)+ '&oauth_version=1.0','UTF-8');

 

I am getting the signature via    

Blob OAuth = Crypto.generateMac('hmacSHA1' , Blob.valueOf(baseString) , Blob.valueOf(signkey));

 

my signKey is :  signkey = consumer_secret+'&';

 

 oauth_signature = EncodingUtil.urlEncode(EncodingUtil.base64Encode(OAuth),'UTF-8');  

 

 

Can Anybody tell me where i am doing the mistake for doing the process.Any immediate help will be very needful.

 

thanks in advance

 

  • August 26, 2013
  • Like
  • 0

HI friends,

 

I need to create the record in salesforce using Rest API.For this hoe i need to give the end point point URL and how i have to post the request .Can anybody tell me.

 

Quick Response will be very usefull.

 

 

Thanks in advance.

  • July 10, 2013
  • Like
  • 0

Hi  friends,

 

I want to open by VF page in IE 9 compatibitlity mode  on IE 10 I have used this 

 

  <meta http-equiv="X-UA-Compatible" content="IE=9"/> in head

 

bt Unfortunatley its not working .Can Any Body help me to implement  this?????????

 

Thanks in advance

 

  • April 26, 2013
  • Like
  • 0

Hello Friends,

I am  having partner portal.In sales force i have created two lead layout. just say A and B.   A is for salesforce crm and B is for partner portal.When i am creating the lead from salesforce it is auto matically taking lead record type A. But when i am creating the lead from partner portal  i have to select record type from the picklist.
I dont want the record type picklist  or just default value B(not editable) .


How can i do the same????????


Thanks

  • April 05, 2013
  • Like
  • 0

hello Friends,

 

I am tring to put my data in one wrapper class list but is ts givin the list out of bound exception.

public class ClS_RecentItem {
public string RecOpp{get;set;}
public list<opportunity> lstOpp{get;set;}
public list<string> name{get;set;}
public list<id> ids{get;set;}

public list<wrpclass> lstWrp{get;set;}

public void Search()
{


name= new list<string>();
ids= new list<id>();
lstWrp=new list<wrpclass> ();
Http httpProtocol = new Http();
HttpRequest request = new HttpRequest();
request.setHeader('Authorization', 'OAuth '+UserInfo.getSessionId());
request.setEndPoint('https://cs6.salesforce.com/services/data/v26.0/recent');
//request.setEndPoint('https://ap1.salesforce.com/services/data/v26.0/sobjects/Opportunity');
request.setMethod('GET');
HttpResponse response = httpProtocol.send(request);
String jsonInput = response.getBody();
system.debug('===>'+jsonInput);
System.JSONParser parser = JSON.createParser(jsonInput);

system.debug('***parser***'+parser);

String JSONString = JSON.serialize(jsonInput);

system.debug('***response***'+JSONString);
while (parser.nextToken() != null) {
System.debug('Current token: ' + parser.getCurrentToken());
if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&(parser.getText() == 'name'))

{
parser.nextToken();
name.add(parser.getText());
System.debug('---------------name---------------------Recent Item = '+name);
System.debug('-----------------------------------------------Recent Item = '+parser.getText());

}
if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&(parser.getText() == 'id'))
{
parser.nextToken();

ids.add(parser.getText());


System.debug('------------------name--------------------Recent Item id = '+ids);
System.debug('-size of name= '+name.size());
System.debug('-size of nids= '+name.size());
integer i;
for(i=0;i<name.size();i++){
{

for(string s:name){
wrpclass w=new wrpclass(s);
lstWrp.set(i,w);            //Here i am getting error


}
for(id d:ids){
wrpclass a=new wrpclass(d);
lstWrp.set(i,w);    //Here i am getting error


}

System.debug('-Wrapper List--------- = '+lstWrp);
}




}

}
}

}


public class wrpclass{

public string objname{get;set;}
public string objid{get;set;}
public wrpclass(string l)
{

objname=l;

}
public wrpclass(id d)
{

objid=d;

}
}
}

 

 

Any help will be appreciated

  • March 15, 2013
  • Like
  • 0

Hello Friend I am getting the error of attemt to de-reference a null object.I am trying to giving product in quote line item

public class CLS_NewQuoteLineItems {
public string surl='';
public string pricebookentry {get;set;}

public string name{get;set;}
public id qid{get;set;}
public boolean b{get;set;}
public boolean b1{get;set;}
public boolean b2{get;set;}
public List<WrapperProduct> prodlist ;
public List<WrapperProduct> selectprodlist {get;set;}
public list<product2> plist{get;set;}
public list<product2> plists{get;set;}
public quote q;

public list<Quotelineitem> qlist{get;set;}
public CLS_NewQuoteLineItems(){

b1=false;

qlist=new list<Quotelineitem>();
surl = ApexPages.currentPage().getUrl();
if(surl.contains('0Q0'))
{
q=new quote();
qid=ApexPages.currentPage().getParameters().get('id');
q=[select name,Pricebook2Id from quote where id=:qid];
name=q.name;
}
if(q.Pricebook2id==null)
{
b2=true;
b=false;
}
else
{
b=true;
b2=false;
}
plist=new list<product2>();
prodlist=new List<WrapperProduct>();
selectprodlist=new List<WrapperProduct>();
plist=[select name,ProductCode ,Family,Description from product2];
system.debug('ppppppppppppp'+plist);

 

}

 

public List<WrapperProduct> getprodlist () {

integer i = 0;


for(product2 p: plist)
{


WrapperProduct lw = new WrapperProduct(p);
prodlist.add(lw);
i++;
}
system.debug('222222222222'+prodlist);
return prodlist;


}

public pageReference selectproduct()
{
b=false;
b1=true;
b2=false;
plists=new list<product2>();
for (WrapperProduct wp : prodlist)
{
if (wp.checked)
{
plists.add(wp.pro);
selectprodlist.add(wp);
}
}

System.debug('@@@@@selected product@@@@@@@'+ selectprodlist);
return null;
}

public pageReference CancelRec()
{

pagereference pr = new pagereference('/apex/VF_QuoteDetailPage?id='+qid);
return pr;
}

public void savepricebook()
{

b2=false;
b=true;
b1=false;
Pricebook2 prc=new Pricebook2();
system.debug('ppppppricebookpppppppp'+pricebookentry);
prc=[select id,Name from Pricebook2 where name=:pricebookentry];
system.debug('ppppppppppppp'+plist);

if(q.Pricebook2Id==null)
{
q.Pricebook2Id=prc.id;
update q;
}
system.debug('aaaaaaaaaaaa'+plist);
system.debug('WWWWWaupdatedquoteaaa'+q);

}
public pageReference insertQuoteItem()
{
System.debug('@@@@@selected product@@@on insertion@@@@'+ selectprodlist);

pricebookentry pEntry = new pricebookentry();
pEntry=[select Id,Pricebook2Id from PricebookEntry where Pricebook2Id=:q.Pricebook2Id limit 1];
product2 pronew=new product2();
for(WrapperProduct p:selectprodlist)
{

Quotelineitem qa=new Quotelineitem();
qa.pricebookentryId= pEntry.id;
qa.pricebookentry.product2id=p.prodid;***********//For this line i am getting the error.
qa.UnitPrice=p.salesprice;
qa.QuoteId=qid;
qa.Quantity=p.Quan;
qa.Description=p.LineItemDescription;
qlist.add(qa);

}
System.debug('uuuuuuuuuuuuuuu'+ qlist);
System.debug('u4444444444444444'+ selectprodlist);
insert qlist;
System.debug('iiiiiiiiiiiii'+qlist);
pagereference pr = new pagereference('/apex/VF_QuoteDetailPage?id='+qid);
return pr;
//return null;
}

public class WrapperProduct
{
public boolean checked {get;set;}
public string productName{get;set;}
public string productcode{get;set;}
public Decimal listprice{get;set;}
public string productdescription{get;set;}
public string productfamily{get;set;}
public id prodid{get;set;}
public product2 pro{get;set;}
public Integer Quan{get;set;}
public Integer Discount{get;set;}
public String LineItemDescription{get;set;}
public Decimal salesprice{get;set;}


public WrapperProduct()
{
checked = false;

}

public WrapperProduct(product2 p)
{
// pro=p;
prodid=p.id;
productName =p.name;
productcode=p.ProductCode;
productdescription=p.Description;
productfamily = p.Family;
}
}
}

 

how can i remove this

  • March 01, 2013
  • Like
  • 0

Hello Friends ,

 

I am trying to insert quote line item list but it is giving error.I am not able to understand why i am getting this error.

ublic class CLS_NewQuoteLineItems {
public string surl='';
public string name{get;set;}
public id qid{get;set;}
public boolean b{get;set;}
public boolean b1{get;set;}
public List<WrapperProduct> prodlist ;
public List<WrapperProduct> selectprodlist {get;set;}
public list<product2> plist{get;set;}
public list<product2> plists{get;set;}
public quote q;
public list<Quotelineitem> qlist{get;set;}
public CLS_NewQuoteLineItems(){
b=true;
b1=false;
qlist=new list<Quotelineitem>();
surl = ApexPages.currentPage().getUrl();
if(surl.contains('0Q0'))
{
q=new quote();
qid=ApexPages.currentPage().getParameters().get('id');
q=[select name from quote where id=:qid];
name=q.name;
}
plist=new list<product2>();
prodlist=new List<WrapperProduct>();
selectprodlist=new List<WrapperProduct>();
plist=[select name,ProductCode ,Family,Description from product2];
system.debug('ppppppppppppp'+plist);

 

}
public List<WrapperProduct> getprodlist () {

integer i = 0;


for(product2 p: plist)
{


WrapperProduct lw = new WrapperProduct(p);
prodlist.add(lw);
i++;
}
system.debug('222222222222'+prodlist);
return prodlist;


}

public pageReference selectproduct()
{
b=false;
b1=true;
plists=new list<product2>();
for (WrapperProduct wp : prodlist)
{
if (wp.checked)
{
plists.add(wp.pro);
selectprodlist.add(wp);
}
}

System.debug('@@@@@@@@@@@@'+ selectprodlist);
return null;
}

public pageReference CancelRec()
{

pagereference pr = new pagereference('/apex/VF_QuoteDetailPage?id='+qid);
return pr;
}
public pageReference insertQuoteItem()
{

for(product2 p:plists)
{
Quotelineitem q=new Quotelineitem();
q.pricebookentry.product2id='01tA0000003IUkaIAG';//Here i am getting error.
q.QuoteId=qid;
q.Quantity=1;
q.Description='test';
qlist.add(q);

}
System.debug('uuuuuuuuuuuuuuu'+ qlist);
insert qlist;
pagereference pr = new pagereference('/apex/VF_QuoteDetailPage?id='+qid);
return pr;
}

public class WrapperProduct
{
public boolean checked {get;set;}
public string productName{get;set;}
public string productcode{get;set;}
public Decimal listprice{get;set;}
public string productdescription{get;set;}
public string productfamily{get;set;}
public id prodid{get;set;}
public product2 pro{get;set;}

public WrapperProduct()
{
checked = false;

}

public WrapperProduct(product2 p)
{
pro=p;
prodid=p.id;
productName =p.name;
productcode=p.ProductCode;
productdescription=p.Description;
productfamily = p.Family;
}
}
}

 

Urgent reply will be helpfull.

 

Thanks

  • February 26, 2013
  • Like
  • 0

Hello Friends i have wriiten a wrapper class.It is working correctly but when i am writting the test class for it i am getting error 

Error: Compile Error: Invalid type: CategoryWrapper at line 15 column 36

Class 

public class Cls_OppRelatedList {
List<categoryWrapper> categories {get;set;}
public id  aid{get;set;}
public string surl = '';
public list<opportunity> opportunityList{get;set;}

 public Cls_OppRelatedList(ApexPages.StandardController controller) {
opportunityList=new list<opportunity>();
categories=new List<categoryWrapper>();
if(ApexPages.currentPage().getUrl() != null)
     {
     
     aid= ApexPages.currentPage().getParameters().get('id');
     }
     if(aid!=null){
    opportunityList=[select name,accountid,stagename,closedate,Amount from opportunity where Accountid=:aid ] ;
     system.debug('%%%%%%%%%%%%%%%%'+opportunityList);
         }
    }
public List<categoryWrapper> getCategories() {
    
     integer i = 0;
     for(opportunity a: opportunityList)
            {
           CategoryWrapper lw = new CategoryWrapper(a);
            categories.add(lw);
            i++;
            } 
             return categories;  
                           
                           
               }


public class CategoryWrapper {
   public string oppname { get; set;}
   public date closedate { get; set;}
   public string stagename { get; set;}
   public id opportunityid{get;set;}
   public CategoryWrapper(opportunity c){
       opportunityid=c.id;
        oppname =c.name;
         stagename=c.stagename;
         closedate=c.closedate;
       
    } 
}

}              

+++++++++++++++++++

Test Class :

@isTest(SeeAllData=True)
Public class Test_Cls_OppRelatedList
{
   Public static testMethod void OppRelatedList()
   {
       List<Opportunity> Opp = New List<opportunity>();
       Account a=new Account();
       a.Name='Test';
       insert a;
       Opp = [select name,accountid,stagename,closedate,Amount from opportunity limit 2];
       ApexPages.StandardController controller=new ApexPages.StandardController(a);  
       Cls_OppRelatedList obj = new Cls_OppRelatedList(controller);
       obj.getCategories();
       
       CategoryWrapper obj1 = New CategoryWrapper(new Opportunity(Name ='Test Oppty', CloseDate = System.today(), StageName = 'Closed Lost', AccountId = a.Id));
     
   }
}

 

 Pls let me know where i am wrong and how can we correct this?

 

  • February 25, 2013
  • Like
  • 0

Hello Friends,

 

I am trying to create a table where we can show the data by wrapper class.here is my code

public class CLS_LeadPagination {

public List<leadWrapper> leadlist {get;set;}
public list<lead> leads{get;set;}
public list<string> leadString{get;set;}

public CLS_LeadPagination()
{

leadlist= new List<leadWrapper>();
leads=new list<lead>();
leadString=new list<string>();
leads= [select name,Email from lead order by name];
leadWrapper objwrap;
for(lead l:leads)
{
objwrap=new leadWrapper();
objwrap.leadobj=l;
leadlist.add(objwrap);
leadString.add(l.name);
}
}
public ApexPages.StandardSetController con {
get {
if(con == null) {
con = new ApexPages.StandardSetController(Database.getQueryLocator([Select Id, Name FROM lead Order By Name ]));

con.setPageSize(10);
}
return con;
}
set;
}







public Boolean hasNext {
get {
return con.getHasNext();
}
set;
}
public Boolean hasPrevious {
get {
return con.getHasPrevious();
}
set;

}

public Integer pageNumber {
get {
return con.getPageNumber();
}
set;
}
public void first() {
con.first();
}

// returns the last page of records
public void last() {
con.last();
}
public void previous() {
con.previous();
}

// returns the next page of records
public void next() {
con.next();
}

// returns the PageReference of the original page, if known, or the home page.


public pageReference SelectRecord()
{

pageReference pr=new pageReference('/apex/VF_LeadNew_Edit_Page');
return pr;
}
public pageReference Cancel()
{

return null;
}

 

public class leadWrapper {

public Boolean checked{ get; set; }
public lead leadobj { get; set;}
public string leadname { get; set;}

public leadWrapper(){
leadobj = new lead();
leadname=leadobj.name;
checked = false;
}
}
}

++++++++++++++++++++++++++++++++
<apex:page controller="CLS_LeadPagination" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons location="top">
<apex:commandButton action="{!SelectRecord}" value="NewLead"/>

</apex:pageBlockButtons>
<apex:pageMessages />
<apex:pageBlockSection title="Leads - Page #{!pageNumber}" columns="1">
<apex:pageBlockTable value="{!leadlist}" var="lead">
<apex:column headerValue="Name">
<apex:outputLink value="/{!lead.leadobj.Id}/e">{!lead.leadobj.name} </apex:outputLink>
</apex:column>
<apex:column value="{!lead.leadobj.Email}" headerValue="Email"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:panelGrid columns="4">
<apex:commandLink action="{!first}">First</apex:commandlink>
<apex:commandLink action="{!previous}" rendered="{!hasPrevious}">Previous</apex:commandlink>
<apex:commandLink action="{!next}" rendered="{!hasNext}">Next</apex:commandlink>
<apex:commandLink action="{!last}">Last</apex:commandlink>
</apex:panelGrid>
</apex:form>
</apex:page>

but here i dont want to display data using standard variable(!lead.leadobj.name).Is there is any way to take variable in wrapper class and showing the name of lead by that.

 

Any quick reply will be very helpfull

 

  • February 20, 2013
  • Like
  • 0

Hello Friends,

 

I have some PDF file and informatiom in them. I have to create the records in salesforce by using the data of pdf.Is there is any way to import those records in salesforce and crate the records.

 

Thanks

  • February 15, 2013
  • Like
  • 0

Hello friends,

 

I am trying to make one formula field based on one date field. My all the field in the formula are date field. It is executing the false part but for true part of the if it is not working.

 

IF( Date_Paid__c = Null, TODAY()- Invoice_Date_Capture__c , Date_Paid__c - Invoice_Date_Capture__c )

 

My  Date_Paid__c - Invoice_Date_Capture__c is giving value but TODAY()- Invoice_Date_Capture__c is not giving value 

 

Thank in advance

  • February 15, 2013
  • Like
  • 0

Hello friends,

 

I am trying to make one formula field based on one date field. My all the field in the formula are date field. It is executing the false part but for true part of the if it is not working.

 

IF( Date_Paid__c = Null, TODAY()- Invoice_Date_Capture__c , Date_Paid__c - Invoice_Date_Capture__c )

 

My  Date_Paid__c - Invoice_Date_Capture__c is giving value but TODAY()- Invoice_Date_Capture__c is not giving value 

 

Thank in advance

  • February 15, 2013
  • Like
  • 0

 

Hello Friends,

 

I am giving this input value and i want to access it in class .I took one variable of id type (Because it is a look field)

 

<apex:inputField value="{!TmMembobj.HS_Codes__c}" id="teammem"  />

I took one variable of id type and passed the value in that.But is giving null

 

hscode=TmMembobj.HS_Codes__c;

 

Any idea how to do the same????????????

 

Thanks in advance

  • February 14, 2013
  • Like
  • 0

Hello Friends,

 

I am developing a VF Page in which I am hiding a table with java script .It is hiding the table perfectly but it is leaving the space after hidding the table.How can i remove the space after hidding the image.

 

Thanks

  • February 12, 2013
  • Like
  • 0

Hello friends,

 

I amhaving the list of  custom object t which i want to give numbers bt all the time it is giving me list of work order of same name.


public static integer c=0;
public ID QID {get; set;}
public List<ID> ProdList=new List<ID>();
public Work_Orders__c wo = new Work_Orders__c();
public list< Work_Orders__c> wos = new list<Work_Orders__c>();
public list<Work_Orders__c> woinsert = new list<Work_Orders__c>();
public Quote q = new Quote();
Public list<QuoteLineItem> QlIm=new list<QuoteLineItem>();
public list <Work_Schedule__c> wslist=new list<Work_Schedule__c>();
public list <Work_Schedule__c> wslist1=new list<Work_Schedule__c>();
public set<date> datelist=new set<date>();
public List<date> listdate=new List<date>();
integer i;
public void ConvertWorkOrder()
{
QID = ApexPages.currentPage().getParameters().get('ID');
QlIm=[ SELECT ListPrice, PricebookEntryId, Quantity, QuoteId, Id, UnitPrice FROM QuoteLineItem where QuoteId=:QID];
system.debug('@@@@@@@@@@@@@@@@@@'+QlIm);
wslist=[select date__c,product__c,quote__c from Work_Schedule__c where quote__c =:QID and product__c!=null];
system.debug('*****************'+QlIm);
for(Work_Schedule__c w:wslist)
{

datelist.add(w.date__c);
}

for(date d:datelist)
{
listdate.add(d);
}
system.debug('lllllllllllllllllllll'+datelist);
for(i=0;i<listdate.size();i++)
{

for(Work_Schedule__c ws:[select date__c,product__c,quote__c from Work_Schedule__c where quote__C=:QID and date__c=:listdate.get(i)])
{
wslist1.add(ws);
}

}
system.debug('*******List of WOrk Order*********'+wslist1);
integer n=listdate.size();

for(i=0;i<n;i++)
{
system.debug('bbbbbbbbbbbbbbbbbb'+i);

for(quote q : [Select ID, Name, Description, Summary__c, Notes__c, OpportunityID, contactID, Opportunity.AccountId,Opportunity.Location__c from Quote where Id =: QID])
{
string name;
if(q != null)
{
wo.Name =q.name;
wo.Quote__c = q.ID;

}
woinsert.add(wo);

}


}

system.debug('WWWWWWWWWWWWWWWWW'+woinsert);
for(Work_Orders__c won:woinsert )
{
integer k;
k=c;
system.debug('ccccccccccc'+k);
won.name=string.valueOf(k);
wos.add(won);
c++;
system.debug('ooooooooooooooo'+wos);

}




}
}

  • February 01, 2013
  • Like
  • 0

Hello friends,

 

In my apex:input text field the text is comming align to the border. I want to give some space between the input text field border and text.I have used padding and left margin for this.And beside to this i am giving some default input in the input text which should be grey and on click it should turn black.How can i do the same?????

 

  • January 29, 2013
  • Like
  • 0

Hello Friends,

I am  having partner portal.In sales force i have created two lead layout. just say A and B.   A is for salesforce crm and B is for partner portal.When i am creating the lead from salesforce it is auto matically taking lead record type A. But when i am creating the lead from partner portal  i have to select record type from the picklist.
I dont want the record type picklist  or just default value B(not editable) .


How can i do the same????????


Thanks

  • April 05, 2013
  • Like
  • 0

Hello Friend I am getting the error of attemt to de-reference a null object.I am trying to giving product in quote line item

public class CLS_NewQuoteLineItems {
public string surl='';
public string pricebookentry {get;set;}

public string name{get;set;}
public id qid{get;set;}
public boolean b{get;set;}
public boolean b1{get;set;}
public boolean b2{get;set;}
public List<WrapperProduct> prodlist ;
public List<WrapperProduct> selectprodlist {get;set;}
public list<product2> plist{get;set;}
public list<product2> plists{get;set;}
public quote q;

public list<Quotelineitem> qlist{get;set;}
public CLS_NewQuoteLineItems(){

b1=false;

qlist=new list<Quotelineitem>();
surl = ApexPages.currentPage().getUrl();
if(surl.contains('0Q0'))
{
q=new quote();
qid=ApexPages.currentPage().getParameters().get('id');
q=[select name,Pricebook2Id from quote where id=:qid];
name=q.name;
}
if(q.Pricebook2id==null)
{
b2=true;
b=false;
}
else
{
b=true;
b2=false;
}
plist=new list<product2>();
prodlist=new List<WrapperProduct>();
selectprodlist=new List<WrapperProduct>();
plist=[select name,ProductCode ,Family,Description from product2];
system.debug('ppppppppppppp'+plist);

 

}

 

public List<WrapperProduct> getprodlist () {

integer i = 0;


for(product2 p: plist)
{


WrapperProduct lw = new WrapperProduct(p);
prodlist.add(lw);
i++;
}
system.debug('222222222222'+prodlist);
return prodlist;


}

public pageReference selectproduct()
{
b=false;
b1=true;
b2=false;
plists=new list<product2>();
for (WrapperProduct wp : prodlist)
{
if (wp.checked)
{
plists.add(wp.pro);
selectprodlist.add(wp);
}
}

System.debug('@@@@@selected product@@@@@@@'+ selectprodlist);
return null;
}

public pageReference CancelRec()
{

pagereference pr = new pagereference('/apex/VF_QuoteDetailPage?id='+qid);
return pr;
}

public void savepricebook()
{

b2=false;
b=true;
b1=false;
Pricebook2 prc=new Pricebook2();
system.debug('ppppppricebookpppppppp'+pricebookentry);
prc=[select id,Name from Pricebook2 where name=:pricebookentry];
system.debug('ppppppppppppp'+plist);

if(q.Pricebook2Id==null)
{
q.Pricebook2Id=prc.id;
update q;
}
system.debug('aaaaaaaaaaaa'+plist);
system.debug('WWWWWaupdatedquoteaaa'+q);

}
public pageReference insertQuoteItem()
{
System.debug('@@@@@selected product@@@on insertion@@@@'+ selectprodlist);

pricebookentry pEntry = new pricebookentry();
pEntry=[select Id,Pricebook2Id from PricebookEntry where Pricebook2Id=:q.Pricebook2Id limit 1];
product2 pronew=new product2();
for(WrapperProduct p:selectprodlist)
{

Quotelineitem qa=new Quotelineitem();
qa.pricebookentryId= pEntry.id;
qa.pricebookentry.product2id=p.prodid;***********//For this line i am getting the error.
qa.UnitPrice=p.salesprice;
qa.QuoteId=qid;
qa.Quantity=p.Quan;
qa.Description=p.LineItemDescription;
qlist.add(qa);

}
System.debug('uuuuuuuuuuuuuuu'+ qlist);
System.debug('u4444444444444444'+ selectprodlist);
insert qlist;
System.debug('iiiiiiiiiiiii'+qlist);
pagereference pr = new pagereference('/apex/VF_QuoteDetailPage?id='+qid);
return pr;
//return null;
}

public class WrapperProduct
{
public boolean checked {get;set;}
public string productName{get;set;}
public string productcode{get;set;}
public Decimal listprice{get;set;}
public string productdescription{get;set;}
public string productfamily{get;set;}
public id prodid{get;set;}
public product2 pro{get;set;}
public Integer Quan{get;set;}
public Integer Discount{get;set;}
public String LineItemDescription{get;set;}
public Decimal salesprice{get;set;}


public WrapperProduct()
{
checked = false;

}

public WrapperProduct(product2 p)
{
// pro=p;
prodid=p.id;
productName =p.name;
productcode=p.ProductCode;
productdescription=p.Description;
productfamily = p.Family;
}
}
}

 

how can i remove this

  • March 01, 2013
  • Like
  • 0

Hello Friends ,

 

I am trying to insert quote line item list but it is giving error.I am not able to understand why i am getting this error.

ublic class CLS_NewQuoteLineItems {
public string surl='';
public string name{get;set;}
public id qid{get;set;}
public boolean b{get;set;}
public boolean b1{get;set;}
public List<WrapperProduct> prodlist ;
public List<WrapperProduct> selectprodlist {get;set;}
public list<product2> plist{get;set;}
public list<product2> plists{get;set;}
public quote q;
public list<Quotelineitem> qlist{get;set;}
public CLS_NewQuoteLineItems(){
b=true;
b1=false;
qlist=new list<Quotelineitem>();
surl = ApexPages.currentPage().getUrl();
if(surl.contains('0Q0'))
{
q=new quote();
qid=ApexPages.currentPage().getParameters().get('id');
q=[select name from quote where id=:qid];
name=q.name;
}
plist=new list<product2>();
prodlist=new List<WrapperProduct>();
selectprodlist=new List<WrapperProduct>();
plist=[select name,ProductCode ,Family,Description from product2];
system.debug('ppppppppppppp'+plist);

 

}
public List<WrapperProduct> getprodlist () {

integer i = 0;


for(product2 p: plist)
{


WrapperProduct lw = new WrapperProduct(p);
prodlist.add(lw);
i++;
}
system.debug('222222222222'+prodlist);
return prodlist;


}

public pageReference selectproduct()
{
b=false;
b1=true;
plists=new list<product2>();
for (WrapperProduct wp : prodlist)
{
if (wp.checked)
{
plists.add(wp.pro);
selectprodlist.add(wp);
}
}

System.debug('@@@@@@@@@@@@'+ selectprodlist);
return null;
}

public pageReference CancelRec()
{

pagereference pr = new pagereference('/apex/VF_QuoteDetailPage?id='+qid);
return pr;
}
public pageReference insertQuoteItem()
{

for(product2 p:plists)
{
Quotelineitem q=new Quotelineitem();
q.pricebookentry.product2id='01tA0000003IUkaIAG';//Here i am getting error.
q.QuoteId=qid;
q.Quantity=1;
q.Description='test';
qlist.add(q);

}
System.debug('uuuuuuuuuuuuuuu'+ qlist);
insert qlist;
pagereference pr = new pagereference('/apex/VF_QuoteDetailPage?id='+qid);
return pr;
}

public class WrapperProduct
{
public boolean checked {get;set;}
public string productName{get;set;}
public string productcode{get;set;}
public Decimal listprice{get;set;}
public string productdescription{get;set;}
public string productfamily{get;set;}
public id prodid{get;set;}
public product2 pro{get;set;}

public WrapperProduct()
{
checked = false;

}

public WrapperProduct(product2 p)
{
pro=p;
prodid=p.id;
productName =p.name;
productcode=p.ProductCode;
productdescription=p.Description;
productfamily = p.Family;
}
}
}

 

Urgent reply will be helpfull.

 

Thanks

  • February 26, 2013
  • Like
  • 0

Hello Friends,

 

I am trying to create a table where we can show the data by wrapper class.here is my code

public class CLS_LeadPagination {

public List<leadWrapper> leadlist {get;set;}
public list<lead> leads{get;set;}
public list<string> leadString{get;set;}

public CLS_LeadPagination()
{

leadlist= new List<leadWrapper>();
leads=new list<lead>();
leadString=new list<string>();
leads= [select name,Email from lead order by name];
leadWrapper objwrap;
for(lead l:leads)
{
objwrap=new leadWrapper();
objwrap.leadobj=l;
leadlist.add(objwrap);
leadString.add(l.name);
}
}
public ApexPages.StandardSetController con {
get {
if(con == null) {
con = new ApexPages.StandardSetController(Database.getQueryLocator([Select Id, Name FROM lead Order By Name ]));

con.setPageSize(10);
}
return con;
}
set;
}







public Boolean hasNext {
get {
return con.getHasNext();
}
set;
}
public Boolean hasPrevious {
get {
return con.getHasPrevious();
}
set;

}

public Integer pageNumber {
get {
return con.getPageNumber();
}
set;
}
public void first() {
con.first();
}

// returns the last page of records
public void last() {
con.last();
}
public void previous() {
con.previous();
}

// returns the next page of records
public void next() {
con.next();
}

// returns the PageReference of the original page, if known, or the home page.


public pageReference SelectRecord()
{

pageReference pr=new pageReference('/apex/VF_LeadNew_Edit_Page');
return pr;
}
public pageReference Cancel()
{

return null;
}

 

public class leadWrapper {

public Boolean checked{ get; set; }
public lead leadobj { get; set;}
public string leadname { get; set;}

public leadWrapper(){
leadobj = new lead();
leadname=leadobj.name;
checked = false;
}
}
}

++++++++++++++++++++++++++++++++
<apex:page controller="CLS_LeadPagination" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons location="top">
<apex:commandButton action="{!SelectRecord}" value="NewLead"/>

</apex:pageBlockButtons>
<apex:pageMessages />
<apex:pageBlockSection title="Leads - Page #{!pageNumber}" columns="1">
<apex:pageBlockTable value="{!leadlist}" var="lead">
<apex:column headerValue="Name">
<apex:outputLink value="/{!lead.leadobj.Id}/e">{!lead.leadobj.name} </apex:outputLink>
</apex:column>
<apex:column value="{!lead.leadobj.Email}" headerValue="Email"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:panelGrid columns="4">
<apex:commandLink action="{!first}">First</apex:commandlink>
<apex:commandLink action="{!previous}" rendered="{!hasPrevious}">Previous</apex:commandlink>
<apex:commandLink action="{!next}" rendered="{!hasNext}">Next</apex:commandlink>
<apex:commandLink action="{!last}">Last</apex:commandlink>
</apex:panelGrid>
</apex:form>
</apex:page>

but here i dont want to display data using standard variable(!lead.leadobj.name).Is there is any way to take variable in wrapper class and showing the name of lead by that.

 

Any quick reply will be very helpfull

 

  • February 20, 2013
  • Like
  • 0

 

Hello Friends,

 

I am giving this input value and i want to access it in class .I took one variable of id type (Because it is a look field)

 

<apex:inputField value="{!TmMembobj.HS_Codes__c}" id="teammem"  />

I took one variable of id type and passed the value in that.But is giving null

 

hscode=TmMembobj.HS_Codes__c;

 

Any idea how to do the same????????????

 

Thanks in advance

  • February 14, 2013
  • Like
  • 0

Hello Friends,

 

I am developing a VF Page in which I am hiding a table with java script .It is hiding the table perfectly but it is leaving the space after hidding the table.How can i remove the space after hidding the image.

 

Thanks

  • February 12, 2013
  • Like
  • 0