• Pratibh Prakash
  • NEWBIE
  • 50 Points
  • Member since 2011

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 14
    Replies

Hi to everyone!

 

How to activate/turn on Content Assist in Eclipse for VF pages, so I can press Ctrl+Space and see what tags I can use? It works in classes, but not in pages. Is it possible to have Content Assist for VF pages?

  • June 15, 2011
  • Like
  • 0

This is an odd one, hopefully one of you superstars can help a brother out.

 

I have a 'picker' page, where users chose a product and add it to a list. I have an action function processing the addition, and it's working fine. On completion of the action function, I rerender the dataTable with the added products. Here's the code for the dataTable:

 

        <apex:dataTable value="{!UserProducts}" var="userProd" id="tblUserProducts">
            <apex:column>
                <apex:facet name="header"><input id="chkSelectAllUserProducts" type="checkbox"/></apex:facet>
                <apex:inputcheckbox value="{!userProd.ID}"/>
            </apex:column>
            <apex:column >
                <apex:facet name="header"><b>Product</b></apex:facet>
                {!userProd.Name}
            </apex:column>         
            <apex:column >
                <apex:facet name="header"><b>Platform</b></apex:facet>
                {!userProd.Platform__c}
            </apex:column>
            <apex:column >
                <apex:facet name="header"><b>Media Group</b></apex:facet>
                {!userProd.Media_Group_Code__c}
            </apex:column>
        </apex:dataTable>

 Here's the problem: After the first insert, no other values can be inserted. I execute the code, and nothing happens. In fact, it breaks some of the other JS on my page. But, if I remove the <apex:inputCheckbox .../> from the first column, BANG!! It all works again. As you might guess, I'm providing the ability to remove multiple items at once, based on whether the items are checked or not. Any idea why the checkbox would cause this kind of error?

 

Thanks,
Gene

 

Hi All,

 

Hope someone can help as I'm still new to developing and trying to learn.

 

I have created a trigger to create a task when a contact record is saved and certain fields are filled in. However, this works fine but if someone goes into the record later and updates some other fields and saves because the fields are already filled in it creates another task. 

 

How can I get the code below to recognise that if a task called '30 Day Call' is already created against the contact to stop and not create another duplicate task?

 

 

trigger AssignNewMemberTask on Contact (after update) {
    List<Task> taskList = new List<Task>();
    for(integer i=0; i<trigger.new.size(); i++)
    {

        if ((trigger.new[i].Joined__c==true)&&(trigger.new[i].Joined_Date__c!=NULL)) {
         Task t = new Task(
         Subject = '30 Day Call',
         WhoId = trigger.new[i].id,
         Description = 'Call this Contact.',
         Priority = 'High',
         Status = 'Not Started',
         ActivityDate = trigger.new[i].Joined_Date__c+30,
         ReminderDateTime = System.now().addDays(2));
 
             if(trigger.new[i].Vistage_MSC__c!=null){
             t.OwnerId = trigger.new[i].Vistage_MSC__c;
             }else{
             t.OwnerId = '005E0000000YhNn';
             }
         taskList.add(t);
        }


    }
    insert taskList;
}

 

 

Many thanks

Kev

Hi 

Can we call a web service class using a trigger?please provide me with some examples as i am new to apex and just trying to explore it..

 

Any help in this regard is kindly appreciated.

 

 

regards,

Facebook

Hi to all,

Can any one Help to increase the code coverage @ present i am getting 75% .

Code in not covered in Red Part .

So please help regarding this part.

 

Apex Class:

 

 

public class Dev_Package_RNController
{
   public Dev_Package_RNController(ApexPages.StandardController controller) {
   
 }
Public Final RN__c rn;
Public Final RN_Payment_Line_Item__c rnpli;
public Dev_Package_RNController()
 {
   rn = [Select id,Dev_Date__c ,Dev_Patient_Name__c ,Dev_Printable_Address__c ,Dev_Patient_Telephone__c,Dev_Package_Branch__c ,Dev_Package_Invoice__c ,
Dev_Patient_Identification__c,Dev_Printable_Address_2__c ,Dev_Package_Item__c,Dev_Utilised_Treatment__c ,Dev_Package_Amount_Paid__c ,Dev_Refund_Admin_Fee__c ,Dev_Nett_Amount_After_Admin_Fee__c ,Dev_Qty_used__c,Dev_Average_Treatment_Price__c ,Dev_Amount_Refundable__c, Dev_Refund_Branch_Logo_URL__c
      from RN__c where id = :ApexPages.currentPage().getParameters().get('id')];
 
   try{
rnpli = [Select id ,name , RecordTypeId ,Dev_Payment_Description__c ,Refund_Note_Number__c,
   Dev_Payment_Date__c,Dev_Amount_Refunded__c  from RN_Payment_Line_Item__c 
   where RecordTypeId= '01290000000KV51' and Refund_Note_Number__c =:rn.id ];
} catch(System.QueryException e){
 
}
    
      }
   public String getname() {
return 'Dev_Package_RNController';
}
public RN__c getRN() {
return rn;
}
public RN_Payment_Line_Item__c getRNpli() {
return rnpli;
}
}

 

 

 

Test Case:

 

 

@isTest

 

private class Dev_Package_RNController_Test{

 

static testmethod void testPackageController()

   {

 

 ApexPages.StandardController con = new ApexPages.StandardController(new rn__c());

 

     Dev_Package_RNController Control  = new Dev_Package_RnController(con); 

 

     control.getname();

     control.getRN();

      control.getRNpli();

 

   Dev_Package_RNController Control1 = new Dev_Package_RnController(con); 

          }

}

 

Hi to everyone!

 

How to activate/turn on Content Assist in Eclipse for VF pages, so I can press Ctrl+Space and see what tags I can use? It works in classes, but not in pages. Is it possible to have Content Assist for VF pages?

  • June 15, 2011
  • Like
  • 0

In a pageblock table I want to render more than one records returned by statndardcontroller or extension controoler.

How can I specify the recordId or the record index in pageblock table?

e.g.

 

sr no.                   name                  age              city

1)                          tom                   22               boston

2)                           jim                       33              ny

3)                         shaun                     34               LA

 

I can retrieve name,aga and city.. but my controller can not get record index

i.e 1 for Tom

2 for Jim

3 for shaun etc.

Is there any way to render dynamically in visualforce?

i have two custom object Asset and Goal. i have to write a formula for goal object field where i need to use a field of asset object. there is no relation between these two objects then how do i use the field of Asset object.

 can i get a solution for the same

This is an odd one, hopefully one of you superstars can help a brother out.

 

I have a 'picker' page, where users chose a product and add it to a list. I have an action function processing the addition, and it's working fine. On completion of the action function, I rerender the dataTable with the added products. Here's the code for the dataTable:

 

        <apex:dataTable value="{!UserProducts}" var="userProd" id="tblUserProducts">
            <apex:column>
                <apex:facet name="header"><input id="chkSelectAllUserProducts" type="checkbox"/></apex:facet>
                <apex:inputcheckbox value="{!userProd.ID}"/>
            </apex:column>
            <apex:column >
                <apex:facet name="header"><b>Product</b></apex:facet>
                {!userProd.Name}
            </apex:column>         
            <apex:column >
                <apex:facet name="header"><b>Platform</b></apex:facet>
                {!userProd.Platform__c}
            </apex:column>
            <apex:column >
                <apex:facet name="header"><b>Media Group</b></apex:facet>
                {!userProd.Media_Group_Code__c}
            </apex:column>
        </apex:dataTable>

 Here's the problem: After the first insert, no other values can be inserted. I execute the code, and nothing happens. In fact, it breaks some of the other JS on my page. But, if I remove the <apex:inputCheckbox .../> from the first column, BANG!! It all works again. As you might guess, I'm providing the ability to remove multiple items at once, based on whether the items are checked or not. Any idea why the checkbox would cause this kind of error?

 

Thanks,
Gene

 

Re-Posting to the Apex Board per a suggestion...(http://boards.developerforce.com/t5/Formulas-Validation-Rules/Execute-Workflow-Rules-from-Apex/td-p/272059)

 

Is it possible to execute a workflow rule from an Apex class?

 

For example could I query the metadata of an Opportunity and get back the array of all workflow rules (e.g., WorkflowRule[]) then execute a specific one?

 

 

//pseudo code//

//could one perform something to the effect of...

 

WorkFlowRule[] rules = gatherRules();

 

WorkflowRule rule = WorkflowRules[0];

 

rule.execute();

 

 

 

Thanks in advance.

 

 

Hi, 

 

I have something of a minor issue using the send mail feature in Apex. I am trying to avoid having to hard code the email by using an email template instead. 

 

I would like this template to be sent to a Contacts email, and the template will use merge fields from a Lead record.

 

Now i'm using 'setTargetObject' as the lead record in which merge fields will be applied. And im using 'setToAddresses' as the email address of the contact in which to send the email to. 

 

What happens is that when the email template is sent to the Contact, it is also sent to the email address in the Lead record. I absolutely do not want the message going to the Lead.

 

So i've had to manually script the email in Apex to keep this from happening. 

 

Does anyone know a better way of handling this. Where i can use merge fields from the lead record to send an email template to an email address outside of the lead object?

I don't think this is possible in SF, but wanted to ask.  I would like to be able to send customers an email with a link to a document in our SF instance.  However, it prompts for a login and password.  Is there a way to publish some documents online in SF?

I have used <apex:param> in a selectList. But it doesn't pass the parameter to the controller. Is there any solution for this case?

 

<apex:page standardController="Applicant__c" recordSetVar="applicant" extensions="view">
  <apex:form >
<apex:pageBlock > <apex:outputLabel value="Status :" for="status"/> <apex:inputField id="status" value="{!Applicant__c.Status__c}"> <apex:actionSupport event="onchange" action="{!getApplicantByStatus}" reRender="view"/> <apex:param name="para" value="{!Applicant__c.Status__c}" assignTo="{!para}"/> </apex:inputField> </apex:pageBlock>
</apex:form>
</apex:page>

 

public class view {

    public Applicant__c applicant;
    public List<Applicant__c> applicantByStatusList {get;set;}
    private ApexPages.StandardSetController controller;
   
    public List<String> applicantNameByStatus{get;set;}
    
    public String para{
        get;
        
        set{
           para=value;
        
        }
    }
    
     
    public view(ApexPages.StandardSetController controller) {
        this.applicant=(Applicant__c)controller.getRecord();
        //this.controller = controller;
    }
    
  /*  public List<String> getApplicantByStatus(){
        
         applicantByStatusList =new List<Applicant__c>();
         applicantByStatusList =[SELECT Name,Name__c,Status__c,Interview_Date_Time__c FROM Applicant__c WHERE Status__c =:para];
         
         if(applicantByStatusList ==null){
             System.Debug('APPLICANT STATUS IS NULL');
         }
         for(Applicant__c app:applicantByStatusList ){
             String name=app.Name__c;
             System.Debug('CHECK :: '+app.Name__c);
             applicantNameByStatus.add('app.Name__c');
         }
         
         //applicantNameByStatus.add('Chamil');
          //applicantNameByStatus.add('madusanka');
          // applicantNameByStatus.add('applicant1');
         
         return applicantNameByStatus;
    } */
    
     public PageReference getApplicantByStatus(){
        
         applicantByStatusList =new List<Applicant__c>();
         System.Debug('PARAMETER :: '+para);
         applicantByStatusList =[SELECT Name,Name__c,Status__c,Interview_Date_Time__c FROM Applicant__c WHERE Status__c =:para];
         
         if(applicantByStatusList !=null){
            
            
            for(Applicant__c app:applicantByStatusList ){
             String name=app.Name__c;
             System.Debug('CHECK :: '+app.Name__c);
             applicantNameByStatus.add('app.Name__c');
             
             }
         }else{
               System.Debug('APPLICANT STATUS IS NULL');
         }
         
         
         
         //applicantNameByStatus.add('Chamil');
          //applicantNameByStatus.add('madusanka');
          // applicantNameByStatus.add('applicant1');
         
         return null;
    }
}

 

 

 

The following is a simplified version of a table that sits in the page layout of the Case standard object.

 

<apex:page standardController="Case" extensions="aResourcesListController">
<apex:form >
    <apex:pageBlock id="table1">
        <apex:pageBlockTable value="{!aResourcesList}" var="aResource" >
            <apex:column >
                <apex:facet name="header">Column 1</apex:facet>
                <apex:inputField value="{!aResource.field__c}"/>
            </apex:column>
            <apex:column >
                <apex:facet name="header">Column 1</apex:facet>
                <apex:outputText value="{!aResource.field__r.someOtherField}"/>
            </apex:column>
        </apex:pageBlockTable>
        <br/> 
        <apex:commandButton action="{!updateTable}" value="Save" rerender="table1"/>
        <apex:commandButton action="{!insertRow}" value="New" rerender="table1"/>
    </apex:pageBlock>
</apex:form>
</apex:page>

 This should update the table when the Save commandButton is clicked. It does update the database but to get the visualforce page to update the user must manually refresh the whole page. How can I get the VisualForce PageBlock to refresh when the user clicks save? Is this possible to do without refreshing the entire page?

 

Thanks,

Matt

 

  • April 22, 2011
  • Like
  • 0

Hello Everyone,

 

am facing some problem in test method code, actually am new to this and don't knw much about test method,  code coverage is done by this test method is 59%, but probelm am facing is ,So pls anyone check the code and tell me where am doing wrong, its giving error of :

Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Candidate_Name__c, Father_Name__c]: [Candidate_Name__c, Father_Name__c]
 

Please check the same if anyone knows....code of class is given below:

/*This apex class is used to save the Entrance Registration Data Entrance Registration Object, and Educational Information
of student. And educational information data is saving in Educational Information object.*/

//Apex Class
public class EntranceRegistrationCls{
 
    //Variable Declaration
    public String MasterId = '';
    public String EduRecordID;
    String TabURL;
    
    //Getter Setter Property Declaration
    public List<Educational_Information__c> EduList{get; set;}
    public Educational_Information__c Education{get;set;}
    
    //List Delcaration
    public list<Educational_Information__c> delList = new list<Educational_Information__c>();   
    public Entrance_Registration__c EntranceReg = new Entrance_Registration__c();
    public Entrance_Registration__c CurrentEntranceReg {get;set;}     
    ApexPages.StandardController controller;
    
    //constructor of EntranceRegistrationCls class
    public EntranceRegistrationCls(ApexPages.StandardController controller){        
        try{
            system.debug('yess');
            this.controller = controller;
            EntList = new List<Entrance_Registration__c>();
            EduList= new List<Educational_Information__c>();        
            EduList.add(new Educational_Information__c());
            Education= new Educational_Information__c();
            getMasterId();            
                if(MasterId == null || MasterId == ''){
                }else{
                    system.debug('Truee..>>'+MasterId);     
                    EntranceReg =[SELECT Id,Name FROM Entrance_Registration__c WHERE Id =:MasterId];
                    EduList=  [SELECT Id,Board_University__c,Degree_Diploma_Certificate_Etc_specify__c, Year_of_Passing__c,Education__c,Institute_College__c,Marks_CGPA__c,Mode_of_Education__c,
                               Status__c FROM Educational_Information__c WHERE Entrance_Master_Id__c =: EntranceReg.Id ];
                    system.debug('Yesssss--->>'+EduList);
                } 
        }
        catch(Exception ex){  
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR, ex.getMessage());
            ApexPages.addMessage(myMsg);
        }
    }
    //End of Constructor
    
    //Get Method for getting the current page id of Entrance Registration    
    public String getMasterId() {
        if(MasterId == null || MasterId == '')
            MasterId= ApexPages.CurrentPage().getParameters().get('ID');
            return MasterId;
    }
    //End of Get Method
    
    //Set Method for setting the value of Enratnce Registration    
    public void setMasterId(String val){
        MasterId = val;
    }
    //End of Set Method
    
    //To add any row method  
    public void addrow() {                              
        for(Integer i=0;i<EduList.size();i++){           
            EduList.add(new Educational_Information__c());                 
            return;
        }
    }
    //To remove any row method        
    public void removeRow(){  
        Integer i = EduList.size();
        if(EduList[i-1].Id <> null)
        delList.add(EduList[i-1]);
        EduList.remove(i-1); 
    }  
    // Save method to save whole data
    public PageReference save(){        
        Schema.DescribeSObjectResult SObjectResult = Schema.SObjectType.Entrance_Registration__c;
        String ObjectKey = SObjectResult.getKeyPrefix();
        TabURL = '/'+ ObjectKey +'/o';
        system.debug('Yes....>>'+TabURL);
            try{
                EntranceReg = (Entrance_Registration__c)controller.getRecord();
                CurrentEntranceReg = EntranceReg;
                system.debug('Yuuuupp>>>>'+CurrentEntranceReg);
                        
            }
            catch (Exception ex){
                ApexPages.Message errMsg = new ApexPages.Message(ApexPages.Severity.ERROR, ex.getMessage());
                ApexPages.addMessage(errMsg);
                return null;
            }
            try{
                if(CurrentEntranceReg.id <> null){
                        update CurrentEntranceReg;
                } else{
                        insert CurrentEntranceReg;
                  }
                  system.debug('Yes'+EduList);
                  
                for(Educational_Information__c ast: EduList){
                    if(ast.Id == null) 
                        ast.Entrance_Master_Id__c =  CurrentEntranceReg.ID;                        
                        ast.Education__c = ast.Education__c;
                        system.debug('Trueeeee...>'+ast.Entrance_Master_Id__c);
                        ast.Board_University__c = ast.Board_University__c;
                        ast.Institute_College__c = ast.Institute_College__c;
                        ast.Marks_CGPA__c = ast.Marks_CGPA__c;
                        ast.Mode_of_Education__c = ast.Mode_of_Education__c;
                        ast.Status__c = ast.Status__c;
                        ast.Year_of_Passing__c = ast.Year_of_Passing__c;
                        ast.Degree_Diploma_Certificate_Etc_specify__c=ast.Degree_Diploma_Certificate_Etc_specify__c;                    
                 }
                 system.debug('TRUE--->'+EduList);   
                upsert EduList;          
            }
            catch (Exception ex){
                ApexPages.Message errMsg = new ApexPages.Message(ApexPages.Severity.ERROR, ex.getMessage());
                ApexPages.addMessage(errMsg);
                return null;
            }            
            PageReference home = new PageReference(TabURL);        
            home.setRedirect(true);        
            return home;                                                
    }
    //End of Save Method
    static testMethod void testEntranceReg(){
        
        Test.startTest();
        PageReference PageRef = Page.EntranceRegistrationVf;
        test.setCurrentPage(PageRef);
        
       ApexPages.StandardController thecontroller = new ApexPages.StandardController(new Entrance_Registration__c());
       EntranceRegistrationCls controller = new EntranceRegistrationCls(thecontroller);
       controller.addrow();
       controller.removeRow();
        
        for(Entrance_Registration__c Ent:controller.CurrentEntranceReg){
            Ent.Candidate_Name__c ='Neeru';
            Ent.Father_Name__c ='Mr. Rakesh Nagpal';
        }
        controller.save();
        Test.stopTest();    
    }
        /*Entrance_Registration__c[] EntReg = new Entrance_Registration__c[]{
            new Entrance_Registration__c(
                Candidate_Name__c='Test Name',Father_Name__c='Test Father Name')};
         insert EntReg;
         
       ApexPages.StandardController thecontroller = new ApexPages.StandardController(new Entrance_Registration__c());
       EntranceRegistrationCls controller = new EntranceRegistrationCls(thecontroller);
       EntranceRegistrationCls  Ent =new EntranceRegistrationCls (thecontroller);
       Ent.save();
       Ent.addrow();
       Ent.removeRow(); */           
   
   /* static testMethod void myUnitTest() {
        PageReference PageRef = Page.EntranceRegistrationVf;
        test.setCurrentPage(PageRef); 
        Apexpages.Standardcontroller sc = new Apexpages.Standardcontroller(new Entrance_Registration__c());
        EntranceRegistrationCls controller = new EntranceRegistrationCls(sc);
        String MasterId;
        controller.setMasterId(MasterId);
        controller.addrow();
        controller.removeRow();
        controller.save();
    }*/
 
}
//End of Apex Class

 

when am saving this its giving error :

Compile Error: Loop must iterate over a collection type: SOBJECT:Entrance_Registration__c at line 140 column 42

Thanks In Advance

  • April 21, 2011
  • Like
  • 0