• V Anand
  • NEWBIE
  • 35 Points
  • Member since 2012

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 57
    Questions
  • 58
    Replies

is there any possibility to make  Multiple contacts to be associated to a single record .(preferably in a primary contact and secondary contact structure similar to events) ?

  • August 26, 2013
  • Like
  • 0

Hi

 

Listview contains group of records as per filter criteria. Now I want to crate a visualforce page in that first selet the list view based on the list vew all  records of that list view will be updated.

 

simply , update the records based on the list view selection.

any one suggest me how to retrieve  record ids of list view in apex

  • September 06, 2013
  • Like
  • 0

Hi...

 

I have to create a attachment programmatically, there is create button on accounts when user clicks on that button one attachment will be created.

 

I have done above perfectly .. but problem is have to maintain version numbers of newly created attachment . like below

 

each button click

Attachment_V1

Attachment_V2

Attachment_V3 ........

 

like quote  PDF ganeration on opportunity...

How will I maintain version numbers programatically.....

Any help appriciated.....

 

 

 

If it is possible how can we do that? I am trying to display contact object related attachments in force.com site as logged in user but I got "Error: Insufficient Privileges " . anyone help me to achieve this.

 HI..,,,

 

I have created a Batch apex on accounts ,, and If I deployed Batch apex class to production org, can I run batch apex using developer console of production org?

 

any Help?

 

 

 

Hi...

 

I am trying to insert more thant 60,000 records throuth Data loader in my instance and there is a berfore insert trigger on that  object..

 

my question is that ... Is that trigger  fired on all 60,000 records?

 

I am using SOQL query in trigger, as per governor limits SOQL query handles only 10,000 records ... is it possible to fire on all records ? any one please clarify my doubt .
 

I have created a apex controller in that I calculated

 

 

 List<PManagement__c PM=[select Rep__c,Revenue___c,Quantity___c,Month_Starting__c,Month_Ending__c from PManagement__c where id=:scon.getId()];
    }
   
public pageReference UpdatePerformance(){
   
   if(!PM.IsEmpty()){
      PManagement__c PMD= PM[0];
      list<sales__c> BS=[select SRep__c,Total_Products__c,Total_Sale_Val__c from SMB_Sales__c   where sale_date__c >=:PMD.Month_Starting__c and sale_date__c <=:PMD.Month_Ending__c AND SRep__c=:PMD.Rep__c ];
if(SMBS.size()!=0){
for(Sales__c BS1:BS){ TotalRev += BS1.Total_sale_Val__c; // I think problem is here TotalRev is incremented with null value.. TotalTar += BS1.Total_Products__c; } PMD.Revenue__c=TotalRev; PMD.Quantity__c=TotalTar; Update PMD; return null; }

 Now I am writing test case for above controller

ApexPages.StandardController stdcon=new ApexPages.StandardController(PM); 
     RevTarCon Con= new RevTarCon(stdcon);
       Con.UpdatePerformance(); // This generates error 
    }

 I Got System.NullPointerException: Argument 1 cannot be null , error in test class

How I can I solve this problem.. please help me ?

 

for(Sales__c BS1:BS){          
TotalRev += BS1.Total_sale_Val__c;
// I think problem is here TotalRev is incremented with null value.. TotalTar += BS1.Total_Products__c;
)

Hi..... 

I have written a trigger on lead for awaiding duplication of leads . I have a problem with test case, my test class is

@isTest
private class TestDuplead{
 static testMethod void tm1(){
   lead l=new lead();
   l.lastname='sss';
   l.company='yyy';
   l.email='ve123@gmail.com';
   insert l;
   
   lead l1=new lead();
   l1.lastname='sss1';
   l1.company='yyy1';
   l1.email='ve123@gmail.com';
   try
      {
        insert l1;
      }catch(System.DMLException e){
      system.assert(e.getmessage().contains('lead with this email address already exists')); //line 18
       } 

 I am getting  

 

 

System.AssertException: Assertion FailedClass..TestDuplead.tm1: line 18, column 1

 

If Assertion failed .....is there any problem? 

Trigger AttachTrig on Attachment (after delete, after insert, after update) {
 
 folder f=[select id,name,type from folder where name='xxx' and type='document' limit 1];
 list<document> docc=[select name,body,description,folderid,bodylength from document where folderid=:f.id ];
 list<contact> con=[select id from contact where recordtypeid=:[select id from recordtype where name='abc']]; 
  
  
  if(trigger.isInsert){
     document doc= new document();
      attachment attach=[select name,description,body,parentid from     attachment where id=:trigger.new and parentid in :con];
contact c=[select id,Cn__c from contact where id=:attach.parentid];
        doc.name=attach.name;     
        doc.body=attach.body;
        doc.folderid=f.id;
        doc.keywords=c.Cn__c;
        insert doc;
       
  }

}

 some times its works perfectly....some times above code cause an error  like System.QueryException: List has no rows for assignment to SObject

 

please help me for better coding.....

 

I created a trigger for attachment .IF attachment is created on contact object  then create a document.  Document is created  easily. but when I updated attachment then these updates are not reflects to documents .

 

How do I perform updation.  insert trigger code is...

trigger doccon on attachment (after insert, after update) {
 
 folder f=[select id,name,type from folder where name='children' and type='document' limit 1];
 list<contact> con=[select id from contact]; 
  
if(trigger.isInsert){
     document doc= new document();
      for(attachment attach:[select name,body,parentid from attachment         where id=:trigger.new and parentid in :con]){
 
        doc.name=attach.name;     
        doc.body=attach.body;
        doc.folderid=f.id;
        insert doc;
      } 
  }
    
    if(trigger.isUpdate){
     ...........help me to update document.
    }
    
}

 

 

  • September 27, 2012
  • Like
  • 0

I am displaying documents in force.com sites but  large document with size 300kb  not displayed in sites.

I got the error like  Error: Insufficient Privileges .  Small size documents are  displaying perfectly but  large size documents are not displaying............


How to print large size documents in force.com sites.

my apex code is

 public transient list<document> doc {get;set;}
         public list<document> getFile() {
     
            doc = [SELECT Id, Name, Description, ContentType, Type, Url, BodyLength, Body ,keywords
                    FROM Document where name like 'a%'];
                 
           return doc;            
        } 

 

<apex:dataTable value="{!file}" var="item3"> 

   <apex:outputLink target="_blank" value="/servlet/servlet.FileDownload?file={!item3.Id}">  document view  </apex:outputLink>                                         

      </apex:dataTable>

 

Please help me !.....

  • September 24, 2012
  • Like
  • 0


When I am trying to Displaying attachments in force.com sites,I got this Error: Insufficient Privileges.
When I have logged in site as "preview as admin " I got this note below the page like "File not allowed for profile".
How to set profile permissions for attachments .
I am trying to display customer portal user contact attachments . And I set "read " permissions for contact object in profile.

How can I display contact attachments in force.com sites.

  • September 14, 2012
  • Like
  • 0

When  I am trying to Displaying attachments in force.com sites,I got this Error: Insufficient Privileges.

When  I have logged in site as  "preview as admin "  I got this note below the page like "File not allowed for profile".

How to set profile permissions for attachments .

I am trying to display customer portal user contact attachments . And I set  "read " permissions for contact object in profile.

 

How can I display contact attachments in force.com sites.

 

  • September 14, 2012
  • Like
  • 0

In SOQL I want to display the contacts  details....

There is another custom object called "Tester". There is lookup relation between Tester and contact.

 

 my SOQL query is  


nlist=[select lastname,firstname,email,phone from contact where id in


(select contact__c from tester where name='abc' order by status__c) ]

 

I got  this error

 Compile Error: expecting a right parentheses, found 'order' at line 15 column 1

 

I have to display the contacts in soring order based on status__c value.

but this field belongs to the object of Tester.  

How can I achive this any suggestions.....

 

 

 

 

 

  • September 07, 2012
  • Like
  • 0

I got this error  when  I including TestMethod with in the apex class like this...

 

 

public class nsorcon {
    public nsorcon(ApexPages.StandardSetController controller) {

    }

     private  list<contact> conlist;
     id uid=userinfo.getuserid();
     user u=[select id,contactid from user where id=:uid];  
     public list<contact> getcontacts(){
          
           conlist=[select ....................];
         return conlist;
    }
  @istest
  static testmethod void testmehod1(){ 
  PageReference pg = Page.mysponsors; 
  Test.setCurrentPage(pg);
  
   contact[] cc=new contact[]{
   new contact(lastname='sample'),new contact(lastname='sample1')};
       
    ApexPages.StandardsetController strcontroller = new ApexPages.StandardsetController(cc);
     
   nsorcon qcc = new nsorcon(strcontroller);
    qcc.getcontacts();
    
   }
  
}

 If I remove @istest in apex class No error. Should I use apex TestMethod in apex class directly or any other  restrictions ...

HI...

 

I have created a website with customer portal enabled. Now I want to download attachments of perticular contacts from site. I got this error   Error: Insufficient Privileges

I am using apex for displaying attachments my code is

 n = [SELECT id,name,contenttype,isprivate FROM Attachment WHERE Isprivate=false and ParentID=:Apexpages.currentpage().getparameters().get('id')];
            
             if(n.size() > 0)
               renderlist = true;
               return n;
            
     }   
      
        public Boolean getRenderlist(){ 
           getNotes();
           return renderlist; 
        }

 

<apex:dataTable value="{!notes}" var="cont" width="60%"  cellpadding="10" cellspacing="5" border="0" style="font-family:arial;font-size:14px"  rendered="{!renderlist}">
             <hr/> 
             <h1 style="font-family:arial;font-size:16px;color:red">Attachments</h1>
             <apex:column headerValue="File Name" value="{!cont.name}"  headerClass="headervalue" />
             <apex:column headerValue="Type" value="{!cont.contenttype}"  headerClass="headervalue"/>
             <apex:column headerValue="Content"> <a href="{!URLFOR($Action.Attachment.Download, cont.Id)}" >View</a> 
             <!--<apex:outputLink value="/servlet/servlet.FileDownload?file={!cont.id}" style="font-family:arial;font-size:14px:font-weight:bold;"> View</apex:outputlink>--></apex:column>  
           </apex:dataTable>

 

 and I set contact : read on profile permissions.

But still I am getting this error anyone please solve my problem.

HI...

 

I have created a website with customer portal enabled. Now I want to download attachments of perticular contacts from site. I got this error   Error: Insufficient Privileges

I am using apex for displaying attachments my code is

 n = [SELECT id,name,contenttype,isprivate FROM Attachment WHERE Isprivate=false and ParentID=:Apexpages.currentpage().getparameters().get('id')];
            
             if(n.size() > 0)
               renderlist = true;
               return n;
            
     }   
      
        public Boolean getRenderlist(){ 
           getNotes();
           return renderlist; 
        }

 

<apex:dataTable value="{!notes}" var="cont" width="60%"  cellpadding="10" cellspacing="5" border="0" style="font-family:arial;font-size:14px"  rendered="{!renderlist}">
             <hr/> 
             <h1 style="font-family:arial;font-size:16px;color:red">Attachments</h1>
             <apex:column headerValue="File Name" value="{!cont.name}"  headerClass="headervalue" />
             <apex:column headerValue="Type" value="{!cont.contenttype}"  headerClass="headervalue"/>
             <apex:column headerValue="Content"> <a href="{!URLFOR($Action.Attachment.Download, cont.Id)}" >View</a> 
             <!--<apex:outputLink value="/servlet/servlet.FileDownload?file={!cont.id}" style="font-family:arial;font-size:14px:font-weight:bold;"> View</apex:outputlink>--></apex:column>  
           </apex:dataTable>

 

 and I set contact : read on profile permissions.

But still I am getting this error anyone please solve my problem.

Hi...

 

I want to print notesandattachments relatedlist of contacts in sites, but it is not displayed in sites and it displayed in visualforce page.

 

I add this page to my site ,here relatedlist is not displayed.

How can I display notesandattachment in sites.

I am using custom controller to handle data in visualforce page.Now there is a requirement for me to display  relatedlist of notes and attachments in vf page.

How to display the related list of perticular contact  using apex controller?

 

Please help me to achieve  this..thanks in advance

 

 

 

Hi...

 

I want to print notesandattachments relatedlist of contacts in sites, but it is not displayed in sites and it displayed in visualforce page.

 

I add this page to my site ,here relatedlist is not displayed.

How can I display notesandattachment in sites.

HI...

I have created a component .It contains some outputlinks like......

<apex:outputlink value="/apex/Home" ><font color="white" size="4">Home</font></apex:outputlink>

  Now I want to rerender  the above link ,and I am using this component in template .How can I rerender the apex/home  page...

 

Is there any other way to implement this Please suggest me?

 

Thanks in advance

I have a related list for "Assets" on my Accounts Page Layout.  There is a particular value in the Assets related list - Deployment Type.  Deployment Type is a picklist field with 3 different possible values.

 

I would like to be able to create a new Case under that Account and pull the value in the Deployment Type field of the Assets related list on the Account page into a new custom field on the Case Page Layout.

 

Is this possible?

is there any possibility to make  Multiple contacts to be associated to a single record .(preferably in a primary contact and secondary contact structure similar to events) ?

  • August 26, 2013
  • Like
  • 0

Hi All,

 

I need help on Reports. I have a custom object say "ObjectA" with Lookup to Account and Contact. Now i have to create a report with "ObjectA" where ObjectA.Account__c != ObjectA.Contact__r.Accountid.

 

Best Regards,

NHK

  • August 26, 2013
  • Like
  • 0

Hello,

 

I'd like to use Test.loadData to create some attachments with createddate in the past for test purpose. What should I put for the Body field (base64) in the csv file?

 

Thanks in advance.

public class jointactionplancon {

//variable declaration
        public id i ;
        public List<Business_Plan_Response__c> bp{get; set;}
        public Business_Plan_Response__c bpr{get; set;}
        public  List<Business_Plan_Proposal__c> bprlst{get; set;}
        public integer num{get; set;}
          public integer num1{get; set;}
        public Business_Plan_Proposal__c bpprop{get; set;}
//constructor

        public jointactionplancon ()
    
        {   bpr=new Business_Plan_Response__c();
            i=Apexpages.currentpage().getparameters().get('id');
              bprlst= new List<Business_Plan_Proposal__c>();
                bprlst=[SELECT id, Proposal_Txt__c,Action_Txt__c,Priority_Num__c,Business_Plan_SFID__c, Review_Txt__c FROM Business_Plan_Proposal__c  WHERE Business_Plan_SFID__c=:i ORDER BY Priority_Num__c asc limit 2 ];
            bpprop=new Business_Plan_Proposal__c();
             bp= new list<Business_Plan_Response__c>();
             bp=[SELECT id,Question_Txt__c,Display_Order_Num__c,Response_Txt__c FROM Business_Plan_Response__c WHERE Business_Plan_SFID__c=:i  ORDER BY Display_Order_Num__c asc ];
      
           
        }


       
        
        
//this method is to Add a row in list
        public PageReference Add_Row()
        {  //bprlst= new List<Business_Plan_Proposal__c>();
            for(integer i=0; i<num; i++){
             bprlst.add(new Business_Plan_Proposal__c());}
                return null;
        }
         public PageReference Add_Row1()
        {  
            for(integer i=0; i<num1; i++){
             bp.add(new Business_Plan_Response__c());}
                return null;
        }
        
//to pull  list of Active Campaigns based on vob  
          public list<Campaign> getcamp(){
          list<Campaign> ca= new list<Campaign>();
          ca=[select Name from Campaign where Type='VOB' and  IsActive=true limit 10 ];
          return ca;
          }
// Saving & Cancel the record and navigating to view page
          public PageReference saverec() {
          
        //this loop for updating bp response
             for( Business_Plan_Response__c bprs: bp){
                 if(bprs.id!=null){
             bpr.id=bprs.id;
             bpr.Question_Txt__c=bprs.Question_Txt__c;
             bpr.Response_Txt__c=bprs.Response_Txt__c;
             
             update bpr;}
             else{
             bprs.Business_Plan_SFID__c=i;
             insert bprs;
                   }
                   }
           //this loop for updating bp proposal      
                   for(Business_Plan_Proposal__c bpps:bprlst){
                     
                      if(bpps.id!=null)
                      {
                       bpprop.id=bpps.id;
                       bpprop.Proposal_Txt__c=bpps.Proposal_Txt__c;
                       bpprop.Action_Txt__c=bpps.Action_Txt__c;
                       bpprop.Review_Txt__c=bpps.Review_Txt__c;
                
               update bpprop;
               }else{
               bpps.Business_Plan_SFID__c=i;
               insert bpps;
               }
                }
               
                               
                return null;
            }
            
        
         public PageReference cancel() {
                return null;
            }
  }

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

Test class:-

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

@istest
private class testjointActionplan{
static testMethod void testjointActionplan()
{
 Business_Plan__c bp= new Business_Plan__c( name='test',Account_SFID__c='00130000011kO2F');
 insert bp;
 system.assertnotEquals(bp,null);
 Business_Plan_Response__c bprs= new Business_Plan_Response__c();
Business_Plan_Response__c bpr= new Business_Plan_Response__c();
bpr.Business_Plan_SFID__c=bp.id;
 bpr.id=bprs.id;
    bpr.Question_Txt__c=bprs.Question_Txt__c;
       bpr.Response_Txt__c=bprs.Response_Txt__c;
insert bpr;
Business_Plan_Proposal__c bplst= new Business_Plan_Proposal__c();
bplst.Business_Plan_SFID__c=bp.id;
insert bplst;
jointactionplancon con= new jointactionplancon ();
 con.Add_Row();
 con.Add_Row1();
con.saverec();
con.getcamp();
con.cancel() ;
}
}

Am gettin 65% code coverage could any one help me on this

 

 

Thanks In advance

In the standard Lead detail page in Service Console,  i have added a custom button, and  on click of that button i am opening a new popup window(visualforce) and after processing is done in Apex controller, the popup should be closed and parent lead detail page should be refreshed with another url. 

Please let me if the above can be achieved, if so, pls give me an example.  thanks. Jaya.

Hi...

 

I have to create a attachment programmatically, there is create button on accounts when user clicks on that button one attachment will be created.

 

I have done above perfectly .. but problem is have to maintain version numbers of newly created attachment . like below

 

each button click

Attachment_V1

Attachment_V2

Attachment_V3 ........

 

like quote  PDF ganeration on opportunity...

How will I maintain version numbers programatically.....

Any help appriciated.....

 

 

 

how to bulkify a trigger  , is there any seperate process to bulkify a trigger. 

  • January 24, 2013
  • Like
  • 0

I have created a apex controller in that I calculated

 

 

 List<PManagement__c PM=[select Rep__c,Revenue___c,Quantity___c,Month_Starting__c,Month_Ending__c from PManagement__c where id=:scon.getId()];
    }
   
public pageReference UpdatePerformance(){
   
   if(!PM.IsEmpty()){
      PManagement__c PMD= PM[0];
      list<sales__c> BS=[select SRep__c,Total_Products__c,Total_Sale_Val__c from SMB_Sales__c   where sale_date__c >=:PMD.Month_Starting__c and sale_date__c <=:PMD.Month_Ending__c AND SRep__c=:PMD.Rep__c ];
if(SMBS.size()!=0){
for(Sales__c BS1:BS){ TotalRev += BS1.Total_sale_Val__c; // I think problem is here TotalRev is incremented with null value.. TotalTar += BS1.Total_Products__c; } PMD.Revenue__c=TotalRev; PMD.Quantity__c=TotalTar; Update PMD; return null; }

 Now I am writing test case for above controller

ApexPages.StandardController stdcon=new ApexPages.StandardController(PM); 
     RevTarCon Con= new RevTarCon(stdcon);
       Con.UpdatePerformance(); // This generates error 
    }

 I Got System.NullPointerException: Argument 1 cannot be null , error in test class

How I can I solve this problem.. please help me ?

 

for(Sales__c BS1:BS){          
TotalRev += BS1.Total_sale_Val__c;
// I think problem is here TotalRev is incremented with null value.. TotalTar += BS1.Total_Products__c;
)
Trigger AttachTrig on Attachment (after delete, after insert, after update) {
 
 folder f=[select id,name,type from folder where name='xxx' and type='document' limit 1];
 list<document> docc=[select name,body,description,folderid,bodylength from document where folderid=:f.id ];
 list<contact> con=[select id from contact where recordtypeid=:[select id from recordtype where name='abc']]; 
  
  
  if(trigger.isInsert){
     document doc= new document();
      attachment attach=[select name,description,body,parentid from     attachment where id=:trigger.new and parentid in :con];
contact c=[select id,Cn__c from contact where id=:attach.parentid];
        doc.name=attach.name;     
        doc.body=attach.body;
        doc.folderid=f.id;
        doc.keywords=c.Cn__c;
        insert doc;
       
  }

}

 some times its works perfectly....some times above code cause an error  like System.QueryException: List has no rows for assignment to SObject

 

please help me for better coding.....

 

I want to write a trigger on Account so that when I edit the Phone field of an existing Account record ,the same Phone also auto populate in the Phone field of associated Contacts of that Account .

 

I have created a trigger but it shows exception .Please give me genuine way to avoid this exception or help me with code .

 

Here is my code

trigger updtPhone on Account (before update) {

for(Account acc:trigger.new){
List<contact> lst=new List<contact>();
Contact c=new Contact();
c=[SELECT Phone FROM Contact WHERE AccountId=:acc.id];
c.Phone=acc.Phone;
lst.add(c);
update acc;
}
}

 

I created a trigger for attachment .IF attachment is created on contact object  then create a document.  Document is created  easily. but when I updated attachment then these updates are not reflects to documents .

 

How do I perform updation.  insert trigger code is...

trigger doccon on attachment (after insert, after update) {
 
 folder f=[select id,name,type from folder where name='children' and type='document' limit 1];
 list<contact> con=[select id from contact]; 
  
if(trigger.isInsert){
     document doc= new document();
      for(attachment attach:[select name,body,parentid from attachment         where id=:trigger.new and parentid in :con]){
 
        doc.name=attach.name;     
        doc.body=attach.body;
        doc.folderid=f.id;
        insert doc;
      } 
  }
    
    if(trigger.isUpdate){
     ...........help me to update document.
    }
    
}

 

 

  • September 27, 2012
  • Like
  • 0

Hi...

 

I want to print notesandattachments relatedlist of contacts in sites, but it is not displayed in sites and it displayed in visualforce page.

 

I add this page to my site ,here relatedlist is not displayed.

How can I display notesandattachment in sites.