• sfdotcom
  • NEWBIE
  • 90 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 2
    Likes Given
  • 16
    Questions
  • 33
    Replies
Hi All,

Please help me on writing visualforce pie chart to display cases count by status as shown below. I have done this using Salesforce dashboard. But i want the same using visualforce pages. 

 User-added image

Thanks.
Hi,

I am new to lightning components. Could you please help me on achieving the actionSupport functionality in lightningcomponents.
Requirement: 
If Account Type is "Prospect" then Description will be displayed.
If Account Type is "Customer - Direct" then "Phone" field should be required.

Here is the visualforce page for above requirement. I want the same functionality using Lightning Components. Thanks in Advance.
<apex:page standardController="Account"  >
    <apex:sectionHeader title="Account" subtitle="Edit Page" />
    <apex:form>
        <apex:pageBlock title="Account Information" mode="mainDetail">
            <apex:pageBlockButtons>
                <apex:commandButton value="Save" action="{!save}" />
            </apex:pageBlockButtons>
            
            <apex:pageBlockSection title="Info">
                <apex:inputField value="{!Account.Name}" />
                <apex:pageBlockSectionItem>
                    <apex:outputLabel> Account Type</apex:outputLabel>
                    <apex:actionRegion>
                        <apex:inputField value="{!Account.Type}" >
                            <apex:actionSupport event="onchange" reRender="showDescription" />
                        </apex:inputField>
                    </apex:actionRegion>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
            
            <apex:pageBlockSection title="Details" id="showDescription"  >
                <apex:inputField value="{!Account.Description}" rendered="{!Account.Type=='Prospect'}" />
                <apex:inputField value="{!Account.Phone}" required="{!Account.Type=='Customer - Direct'}" />
            </apex:pageBlockSection>
        </apex:pageBlock>
      </apex:form>
</apex:page>


Thank You.
Hi,

Could you please help me on changing the below trigger (which is written by Sandeep sankhla) , so that Plan__c status will be changed based on Account. That is if Account status is Active, then Plan__ c status should be Active, if Account status is InActive, then Plan__ c status should be InActive, if Account status is null, then Plan__ c status should be null.

Here
1. Account and Plan objects with many to many relationship and Accountplan as a Junction Object
2. Account obj with status field Active and inactive.
3. and Plan obj with status field Active and inactive

Trigger AccountTrigger on Account(After Update)
{
    set<Id> setAccIds = new set<Id>();
    list<Plan__c> lstPlanToUpdate = new list<Plan__C>();
    
    
    for(Id objAcc : trigger.newmap.Keyset())
    {
        if((trigger.newmap.get(objAcc).Status__c == 'InActive')  &&(trigger.newmap.get(objAcc).Status__c != trigger.oldMap.get(objAcc).Status__c))
        {
            setAccIds.add(objAcc);
        }
    }
    
    for(AccountPlan__c objAP : [Select Id, Plan__c, Account__c from AccountPlan__c where Account__c IN :setAccIds])
    {
            Plan__c objPlan = new Plan__c(Id = objAP.Plan__c);
            objPlan.Status__C = 'InActive';
            lstPlanToUpdate.add(objPlan);
    }
    
    update lstPlanToUpdate;

}

Thank You
Hi,

How to embed Digital Assets (images, videos, audios) and serach page into single visualforce page.
​Thank You.
Hi,

How to embed Digital Assets (images, videos, audios) and serach page into single visualforce page.
Thank You.
Hi,
Please help me on writing test class for below controller.

Controller:
public class ItemInsertDisplay {
    public Item__c newItem {get; set;}
  
    //Constructor
    public ItemInsertDisplay(){
        newItem = new Item__c();
    }
    public List<Item__c> existingItems{
        get{    
            existingItems = [Select Id, Name, Item_Name__c, Unit_Price__c from Item__c order by Item__c.Item_Name__c];
            return existingItems;
        }
        set;
    }
    
    public PageReference save(){
        try{
            insert newItem;
            newItem = new Item__c();
        }
        catch(Exception e)
        {
            ApexPages.addMessages(e);
        }
        return null;
    }
}

Thanks.
Hi, I wrote an exension, which is used to retrieve the data from from another object to Case page based on picklist value "Type". "Type" picklist has two values. They are 1. Regular  2. Contract. If Regular is selected then it fetches the related data. For this i have created a value in other object Employee. But when i select Type as "Contract". Then it's giving me error. Because I haven't given any value for "Contract" in Employee object.
 Please help me on fixing this error.

Controller Extension:
Public class TestCase_Controller{
    Public Case caseData {get; set;}
    Public Member__c memberData {get; set;}
    Public Employee__c employeeData {get; set;}
    Id accId {get; set;}
  //  Id recordTypeValue {get; set;}
    
    Public TestCase_Controller(ApexPages.StandardController stdCtr){
        caseData = (Case)stdCtr.getRecord();
        memberData = new Member__c ();
        employeeData = new Employee__c();
        accId = ApexPages.CurrentPage().getParameters().get('AccountId');
   //     recordTypeValue = ApexPages.currentPage().getParameters().get('RecordType');
        caseData.AccountId = accId;
       // caseData.RecordTypeId = recordTypeValue;
    }
    
    Public void populateMemberDetails(){
    if(!String.isBlank(caseData.Member__c)){
    memberData = [Select ID, Description__c from Member__c where ID = :caseData.Member__c ];
    caseData.Description = memberData.Description__c ; 
    }
     else
        {
            memberData=null;
            caseData.Description = null;
        }
   
    }
    
     Public void populateEmployeeDetails(){
    if((!String.isBlank(caseData.Type__c) )){
    employeeData = [Select ID, Employee_Description__c, Type__c from Employee__c where Type__c = :caseData.Type__c ];
   
    caseData.Employee_Description__c = employeeData.Employee_Description__c ; 
    }
    
     else
        {
            employeeData.type__c =null;
            caseData.Employee_Description__c = null;
        }
   
    }
    
    
    Public pageReference customSave(){
        Try{
        
            Upsert caseData;
            Return new PageReference('/' +caseData.Id);
              }
        Catch(Exception e){
            ApexPages.addMessages(e);
            Return null;
        }
        
        }
    }

Error:
Visualforce ErrorHelp for this Page
System.QueryException: List has no rows for assignment to SObject
Error is in expression '{!populateEmployeeDetails}' in page testcase: Class.TestCase_Controller.populateEmployeeDetails: line 33, column 1
Class.TestCase_Controller.populateEmployeeDetails: line 33, column 1
Hi,
Please help me on writing test class for .addError for below trigger. I am getting 100% code coverage but test methods not are getting passed. 
Thanks in advance.

Trigger:
trigger OpportunityTrigger on Opportunity (before update) {
    for(Opportunity oppty : trigger.new) {
        if(trigger.oldMap.get(oppty.Id).StageName == 'Closed Won') {
            oppty.addError('Closed Opportunity cannot be updated');
        }
    }
}

Test class: 100 % code coverage
@isTest
public class test_OpportunityTrigger {
    static testMethod void testUpdate(){
        Opportunity opp = new Opportunity(Name = 'Test', StageName = 'Closed Won', CloseDate = System.Today().addMonths(1));
        insert opp;
        opp.Name = 'Test1';
        try{
        update opp;
        }
       catch (Exception e){

        System.assert(e.getMessage().contains('Can not add'));

}
    }
}
Hi,
I have created an object. Object Name: Text
Fieds:
1. Text Name(Standard field)
2. values (picklist field: values: 1, 2, 3)
3. Text 1 (Text field)
4. Text 2 (Text field)
5. Text 3 (Text field)

Now, I need a vf page. If I select picklist value as '1', then 'Text 1 ' field should be marked as required. If I select value '2', then 'Text 2 ' should be marked as required(red). Here we have to use reRender attribute and fields should be marked as required before saving.


<apex:page standardController="Text__c">
<apex:form>
<apex:pageBlock >
<apex:pageBlockSection id="thePageBlockSection">
<apex:inputField value="{!Text__c.Name}"/>
<apex:inputField value="{!Text__c.Text_values__c}" /> 
<apex:inputField  value="{!Text__c.Text_1__c}" required="{!if(Text__c.Text_values__c== '1'), true, false}"/>
<apex:inputField  value="{!Text__c.Text_2__c}" required="{!if(Text__c.Text_values__c== '2'), true, false}"/> 
<apex:inputField  value="{!Text__c.Text_3__c}" required="{!if(Text__c.Text_values__c== '3'), true, false}"/> 

</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

Thank You.
Hi,
I need help on writing test class for below trigger. I have wrote test class but not any coverage.
Trigger:
trigger sampleTrigger on Object1__c (After Update) {

 if((trigger.IsAfter) && (trigger.Isupdate))
  {
   list<Object1__c> object1List = trigger.new;
 
   list<Object2__c> object2List = new  list<Object2__c > ();
   list<Object2__c> oldObject2List =[select id,name,Marks__c from Object2__c where Object1__c=:trigger.new];
  
   for(Object1__c obj1: trigger.new)
   {
      for(Object2__c obj2:oldObject2List)
      {
    
       obj2.Marks__c=obj1.Marks__c;
          object2List.add(obj2);
      }   
   }
   
    Update object2List;
  
   }

}

______________
Test class:

@isTest
public class sampleTrigger_Test {
    public static testMethod void testUpdate(){
       
        Account acc = new Account(Name = 'Test');
        insert acc;
        Contact con  =new Contact( LastName = 'Test',  AccountId = acc.Id);
        insert Con;
        Order__c ord = new Order__c(Account__c = acc.Id, Contact__c = con.Id);
        insert ord;       
        Object1__c obj1 = new Object1__c(Marks__c = 10.00);
        insert tp;
       
        Object2__c obj2 = new Object2__c ( Name = 'Test',
                                                             Marks__c = 12.12,
                                                            Account__c = acc.Id,
                                                            Object1__c = obj1.Id); // Here object1 has relationship with obj2
        insert obj2;
        obj2.Marks__c = obj1.Marks__c;
        update obj2;
        }
}

Thanks in advance..
Hi, I need test class for below controller.

public class Sum
{
 public integer first { get; set;}
  public integer second { get; set;}
  public integer result {get; set;}
  public void add()
  {
   result = first + second ;
  }
 public void sub()
  {
   result = first - second ;
   }
 public void mul()
  {
   result = first * second ;
   }
public void mod()
 {
   result = first / second ;
 }
  }
Hi,
Please help me on writing test class for below standard controller extesnion..
Here "Case" is standard controller. We have 2 record types for Case.

public with sharing class CaseController {
    public Id caseId {get;set;}
    Case casePage;
    public CaseController (ApexPages.StandardController controller) {
        caseId = ApexPages.CurrentPage().getParameters().get('id');
      }
   
    public PageReference redirectRecordType(){
        Case cs = [select id, recordTypeId from case where id =: caseId];
 
        if(cs.recordTypeId =='XXXXXXXXXX'){
            return new PageReference ('/apex/vfpage1?id='+cs.Id);
        }
        if(cs.recordTypeId == 'YYYYYYYYYY'){
            return new PageReference ('/apex/vfpage2?id='+cs.Id);
        }
        else{
                       return new PageReference ('/'+cs.Id+'/e?retURL=%2F'+cs.ID+'&nooverride=1');
        }
    }
}

Here is the Test class;
@isTest
public class Test_CaseController{


public static testMethod void test1(){
 Test.startTest();
Case testCase = new Case(
        Status ='New',
        Origin='Phone',
        Subject='This is a test case');
        insert(testCase);
        
    ApexPages.StandardController sc = new ApexPages.StandardController(testCase);
    CaseController ctr = new CaseController (sc);
    PageReference ref = new PageReference('/apex/vfpage'); 
    Test.setCurrentPage(ref);
}
}

Thanks in advance..
Hi All,

I have a requirement to create a custom object name: Status__c


   and field is Staus_name__c    and picklist values for this Status Name__c are 

    1. Task
    2. email alert
    3. chatter post
    4. field update

    --> If task is selected then it should ask Start date, End Date, Assign task to whom
    --> If email alert is selected then it should ask Email template
    --> If Field Update is selected then it should ask field name
    --> If Chatter post is selected then it should ask post name.

Can you please write the VF and Apex Controller code for above task..

Thanks in Advance..
I need a query to fetch Team Members who have no quotes on Opportunity and send email to those..

Plz give the solution
I want the Visualforce code for creating login form & whenever user create the account, form should automatically  generating new password same as username & password should be sent in email.?

plz give me code for above task. i need it.

thanks in advance..............
I want the Visualforce code for creating login form & whenever user create the account, form should automatically  generating new password same as username & password should be sent in email.?

plz give me code for above task. i need it.

thanks in advance..............
Hi,
I have created an object. Object Name: Text
Fieds:
1. Text Name(Standard field)
2. values (picklist field: values: 1, 2, 3)
3. Text 1 (Text field)
4. Text 2 (Text field)
5. Text 3 (Text field)

Now, I need a vf page. If I select picklist value as '1', then 'Text 1 ' field should be marked as required. If I select value '2', then 'Text 2 ' should be marked as required(red). Here we have to use reRender attribute and fields should be marked as required before saving.


<apex:page standardController="Text__c">
<apex:form>
<apex:pageBlock >
<apex:pageBlockSection id="thePageBlockSection">
<apex:inputField value="{!Text__c.Name}"/>
<apex:inputField value="{!Text__c.Text_values__c}" /> 
<apex:inputField  value="{!Text__c.Text_1__c}" required="{!if(Text__c.Text_values__c== '1'), true, false}"/>
<apex:inputField  value="{!Text__c.Text_2__c}" required="{!if(Text__c.Text_values__c== '2'), true, false}"/> 
<apex:inputField  value="{!Text__c.Text_3__c}" required="{!if(Text__c.Text_values__c== '3'), true, false}"/> 

</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

Thank You.
I want the Visualforce code for creating login form & whenever user create the account, form should automatically  generating new password same as username & password should be sent in email.?

plz give me code for above task. i need it.

thanks in advance..............
Hi,

Could you please help me on changing the below trigger (which is written by Sandeep sankhla) , so that Plan__c status will be changed based on Account. That is if Account status is Active, then Plan__ c status should be Active, if Account status is InActive, then Plan__ c status should be InActive, if Account status is null, then Plan__ c status should be null.

Here
1. Account and Plan objects with many to many relationship and Accountplan as a Junction Object
2. Account obj with status field Active and inactive.
3. and Plan obj with status field Active and inactive

Trigger AccountTrigger on Account(After Update)
{
    set<Id> setAccIds = new set<Id>();
    list<Plan__c> lstPlanToUpdate = new list<Plan__C>();
    
    
    for(Id objAcc : trigger.newmap.Keyset())
    {
        if((trigger.newmap.get(objAcc).Status__c == 'InActive')  &&(trigger.newmap.get(objAcc).Status__c != trigger.oldMap.get(objAcc).Status__c))
        {
            setAccIds.add(objAcc);
        }
    }
    
    for(AccountPlan__c objAP : [Select Id, Plan__c, Account__c from AccountPlan__c where Account__c IN :setAccIds])
    {
            Plan__c objPlan = new Plan__c(Id = objAP.Plan__c);
            objPlan.Status__C = 'InActive';
            lstPlanToUpdate.add(objPlan);
    }
    
    update lstPlanToUpdate;

}

Thank You
Hi,
Please help me on writing test class for below controller.

Controller:
public class ItemInsertDisplay {
    public Item__c newItem {get; set;}
  
    //Constructor
    public ItemInsertDisplay(){
        newItem = new Item__c();
    }
    public List<Item__c> existingItems{
        get{    
            existingItems = [Select Id, Name, Item_Name__c, Unit_Price__c from Item__c order by Item__c.Item_Name__c];
            return existingItems;
        }
        set;
    }
    
    public PageReference save(){
        try{
            insert newItem;
            newItem = new Item__c();
        }
        catch(Exception e)
        {
            ApexPages.addMessages(e);
        }
        return null;
    }
}

Thanks.
Hi, I wrote an exension, which is used to retrieve the data from from another object to Case page based on picklist value "Type". "Type" picklist has two values. They are 1. Regular  2. Contract. If Regular is selected then it fetches the related data. For this i have created a value in other object Employee. But when i select Type as "Contract". Then it's giving me error. Because I haven't given any value for "Contract" in Employee object.
 Please help me on fixing this error.

Controller Extension:
Public class TestCase_Controller{
    Public Case caseData {get; set;}
    Public Member__c memberData {get; set;}
    Public Employee__c employeeData {get; set;}
    Id accId {get; set;}
  //  Id recordTypeValue {get; set;}
    
    Public TestCase_Controller(ApexPages.StandardController stdCtr){
        caseData = (Case)stdCtr.getRecord();
        memberData = new Member__c ();
        employeeData = new Employee__c();
        accId = ApexPages.CurrentPage().getParameters().get('AccountId');
   //     recordTypeValue = ApexPages.currentPage().getParameters().get('RecordType');
        caseData.AccountId = accId;
       // caseData.RecordTypeId = recordTypeValue;
    }
    
    Public void populateMemberDetails(){
    if(!String.isBlank(caseData.Member__c)){
    memberData = [Select ID, Description__c from Member__c where ID = :caseData.Member__c ];
    caseData.Description = memberData.Description__c ; 
    }
     else
        {
            memberData=null;
            caseData.Description = null;
        }
   
    }
    
     Public void populateEmployeeDetails(){
    if((!String.isBlank(caseData.Type__c) )){
    employeeData = [Select ID, Employee_Description__c, Type__c from Employee__c where Type__c = :caseData.Type__c ];
   
    caseData.Employee_Description__c = employeeData.Employee_Description__c ; 
    }
    
     else
        {
            employeeData.type__c =null;
            caseData.Employee_Description__c = null;
        }
   
    }
    
    
    Public pageReference customSave(){
        Try{
        
            Upsert caseData;
            Return new PageReference('/' +caseData.Id);
              }
        Catch(Exception e){
            ApexPages.addMessages(e);
            Return null;
        }
        
        }
    }

Error:
Visualforce ErrorHelp for this Page
System.QueryException: List has no rows for assignment to SObject
Error is in expression '{!populateEmployeeDetails}' in page testcase: Class.TestCase_Controller.populateEmployeeDetails: line 33, column 1
Class.TestCase_Controller.populateEmployeeDetails: line 33, column 1
Hi,
Please help me on writing test class for .addError for below trigger. I am getting 100% code coverage but test methods not are getting passed. 
Thanks in advance.

Trigger:
trigger OpportunityTrigger on Opportunity (before update) {
    for(Opportunity oppty : trigger.new) {
        if(trigger.oldMap.get(oppty.Id).StageName == 'Closed Won') {
            oppty.addError('Closed Opportunity cannot be updated');
        }
    }
}

Test class: 100 % code coverage
@isTest
public class test_OpportunityTrigger {
    static testMethod void testUpdate(){
        Opportunity opp = new Opportunity(Name = 'Test', StageName = 'Closed Won', CloseDate = System.Today().addMonths(1));
        insert opp;
        opp.Name = 'Test1';
        try{
        update opp;
        }
       catch (Exception e){

        System.assert(e.getMessage().contains('Can not add'));

}
    }
}
Hi,
I have created an object. Object Name: Text
Fieds:
1. Text Name(Standard field)
2. values (picklist field: values: 1, 2, 3)
3. Text 1 (Text field)
4. Text 2 (Text field)
5. Text 3 (Text field)

Now, I need a vf page. If I select picklist value as '1', then 'Text 1 ' field should be marked as required. If I select value '2', then 'Text 2 ' should be marked as required(red). Here we have to use reRender attribute and fields should be marked as required before saving.


<apex:page standardController="Text__c">
<apex:form>
<apex:pageBlock >
<apex:pageBlockSection id="thePageBlockSection">
<apex:inputField value="{!Text__c.Name}"/>
<apex:inputField value="{!Text__c.Text_values__c}" /> 
<apex:inputField  value="{!Text__c.Text_1__c}" required="{!if(Text__c.Text_values__c== '1'), true, false}"/>
<apex:inputField  value="{!Text__c.Text_2__c}" required="{!if(Text__c.Text_values__c== '2'), true, false}"/> 
<apex:inputField  value="{!Text__c.Text_3__c}" required="{!if(Text__c.Text_values__c== '3'), true, false}"/> 

</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

Thank You.
Hi,
I have to make one visualforce page in which one picklist field is there. If I select first value in picklist field one page will be open and if I select second value in picklist field then other page will open. 
How do i get this.. ?

Thanks
Abhilasha
How can i achive the following req:

i have Account and Plan objects with mamy to many relationship and Accountplan as a Junction Object

and  Account obj with status field Active and inactive
and Plan obj with status field Active and inactive

If Account Status field is inactive then change all Account related plans status to inactive only if plan related all accounts are inActive.

.......... Could you Please help me out in this req.

Could you please give me a snopshot of code here...


Thanks in Advance....................
Hi,
I have to make one visualforce page in which one picklist field is there. If I select first value in picklist field one page will be open and if I select second value in picklist field then other page will open. 
How do i get this.. ?

Thanks
Abhilasha
Hi,
My question is : If i checked the checkbox then both fields will appear and if the checkbox is unchecked then both field will not appear.User-added image