• Sushil Kaushik
  • NEWBIE
  • 55 Points
  • Member since 2014

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


Hi ,
I have tried this one in demo version.
I have posted my code when i clicked the checkbob  corresponding row  is in editable mode .
But the issue is it showing same records repetedly
Can you suggest me...


<apex:page StandardController="Contact" extensions="RowEditingcontroller">

  <apex:pageMessages />

    <apex:form id="theForm">
        <apex:pageBlock Title="ALL CONTACTS FOR ROW EIDTING" id="pb">
         
           <apex:commandButton value="Save" action="{!tosave}" id="saveButton"  />

           <apex:outputPanel >

        

              <apex:pageBlockTable value="{!Contacts}" var="c" cellpadding="2" border="1"  rowClasses="odd,even" styleClass="tableClass" id="opp_table">
                
                  <apex:column headerValue="Edit" >
                     <apex:inputcheckbox value="{!c.selected}">
                       <apex:actionSupport event="onclick" action="{!getSelected}"  rerender="pb" />
                     </apex:inputcheckbox>&nbsp;
                  </apex:column>
                   <apex:column headerValue="Contact name" >
                 
                    <b><apex:outputField rendered="{!IF(c.selected==true,false,true)}" value="{!c.con.Name}"/> </b>  
                       <apex:inputfield rendered="{!IF(c.selected==true,true,false)}" value="{!c.con.Name}"/>
                      </apex:column>
                 <apex:column headerValue="Contact No" >
                    <apex:outputfield rendered="{!IF(c.selected==true,false,true)}" value="{!c.con.MobilePhone}" />
                   <apex:inputfield rendered="{!IF(c.selected==true,true,false)}" value="{!c.con.MobilePhone}" />
                 </apex:column>
                 <apex:column headerValue="Email">
                   <apex:outputField rendered="{!IF(c.selected==true,false,true)}" value="{!c.con.Email}"/>
                    <apex:inputField rendered="{!IF(c.selected==true,true,false)}" value="{!c.con.Email}"/>
                 </apex:column>
               <apex:inlineEditSupport event="ondblClick"  showOnEdit="saveButton"/>
              

         </apex:pageBlockTable>

      </apex:outputPanel>

     </apex:pageBlock>
  </apex:form>

  </apex:page>


---------------------------------------------controller------------------------------------
public class RowEditingcontroller {

     //All property....

     public Contact contact{get;set;}
     public Id Id{get;set;}
     List<contactwrapper> contactList = new List<contactwrapper>();
     List<Contact> selectedContacts = new List<Contact>();

     //constructor....

     public RowEditingcontroller(ApexPages.StandardController controller) {
  
      

      }

     //displaying contact pageBlock table....
    
     public  List<contactwrapper> getContacts() {
  
        for(Contact c: [select Id,Name,Account.Name,MobilePhone,Email from Contact order by createdDate desc limit 1  ])
   
              contactList.add(new contactwrapper(c));
              return contactList;
          }

       //all selected contacts...for edit...     
     public PageReference getSelected() {
  
         selectedContacts.clear();
         for(contactwrapper conwrapper: contactList)
            if(conwrapper.selected == true)
     
            selectedContacts.add(conwrapper.con);
     
            return null;
        }
      
      
     public List<Contact> GetSelectedContacts(){
  
        if(selectedContacts.size()>0)
        return selectedContacts;
        else
       // ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Please select at least one Contact.'));
        return null;
    }
   
    //saving edited value...
 
      public PageReference tosave() {
      if(selectedContacts.size()>0){
    
        update selectedContacts;
        PageReference RowEditing=new PageReference('/apex/RowEditing');
        RowEditing.setRedirect(true);
        return RowEditing;
        }
        else{
        ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Please select at least one Contact.'));
         return null;
        }
     
       }
  
    //wrapper class...
  
    public class contactwrapper
    {
        public Contact con{get; set;}
        public Boolean selected {get; set;}
        public contactwrapper(Contact c)
        {
            con = c;
            selected = false;
        }
    }
}
Hello All,

Requirement  : While creating Event record, when user clicks on SAVE(standard) button, need to show a confirmation box to user only if a checkbox is checked on Event. And once user confirms it, an email need to be fired to manager of that user and save the record.

Can we do this using overiding salesforce SAVE with custom button(execute javascript) ?

Thanks,
Prafull
Please Guide me Only use controller as soon as possible.
I have one Error for Illegal assignment from Decimal to Integer at line 178 column 13

List<Integer> total = new List<Integer>();

table in that SR.No(Serial No) ,Number of villages reached,Govt Schools,Pvt Schools,Other Schools,Avg other schools in the Pratham intervention areas  columns.
Example:                  this are Column
SRNO.   (Number of villages reached)   (Govt Schools )    (Pvt Schools)  (Other Schools)    (Avg other schools in the Pratham intervention areas)
1                             4                                               1                               2                   3                               3+2+1/4=1.5

I want 1.5 values in last column name is Other Schools  Avg other schools in the Pratham intervention areas.
but my out put comes 1  in integer .

please guide me.

My code is this:


public with sharing class ctrl_RI14_other_school_trends {

public List<SelectOption> lstNational {get;set;}
  public List<SelectOption> lstPhase {get;set;}
  //public List<SelectOption> lstDonor = new List<SelectOption>();


  public List<RI_School_Report_Cards__c> lstSchool = new List<RI_School_Report_Cards__c>();
  public List<Report> lstwrap1Sub {get;set;}
  public String strState {get;set;}
  public String strBlocks {get;set;}
  public String strNational {get;set;}
  public String strSchool {get;set;}
  public String strPhase {get;set;}
// public String strDonor {get;set;}
  
  public ctrl_RI14_other_school_trends()
{
    strState = '';
     strBlocks = '';
     strNational = '' ;
     strSchool = '';
     strPhase = '';
// strDonor = '';

    lstPhase = new List<SelectOption>();
    lstPhase.add(new SelectOption('', '- - None - -'));
    Schema.DescribeFieldResult F = RI_School_Report_Cards__c.BCI_CP_P_NO__c.getDescribe();
    for (Schema.PicklistEntry temp : F.getPicklistValues())
     {
      lstPhase.add(new SelectOption(temp.getValue(), temp.getLabel()));
}
    lstNational = new List<SelectOption>();
    lstNational.add(new SelectOption('', '- - None - -'));
    F = RI_School_List__c.National__c.getDescribe();
    for (Schema.PicklistEntry temp : F.getPicklistValues())
    {
      lstNational.add(new SelectOption(temp.getValue(), temp.getLabel()));
    }
  

      lstwrap1Sub = new List<Report>();
  
}

public List<SelectOption> getAttStates() {
    List<SelectOption>lstSchoolStates = new List<SelectOption>();
    AggregateResult []ar = [Select School_List__r.State__c State from RI_School_Report_Cards__c where Submission_No__c != null AND School_List__r.National__c =: strNational GROUP BY School_List__r.State__c];
    lstSchoolStates .add(new SelectOption('','-None-'));
    for(AggregateResult temp: ar) {
      lstSchoolStates.add(new SelectOption(String.valueOf(temp.get('State')),String.valueOf(temp.get('State'))));
    }
    return lstSchoolStates ;
  }

  public List<SelectOption> getAttBlocks() {
    List<SelectOption> lstSchoolBlocks = new List<SelectOption>();
    AggregateResult []ar = [Select School_List__r.block__c block from RI_School_Report_Cards__c where Submission_No__c != null AND School_List__r.state__c =: strState AND School_List__r.National__c =: strNational GROUP BY School_List__r.block__c ];
    lstSchoolBlocks.add(new SelectOption('','-None-'));
    for(AggregateResult temp: ar) {
      lstSchoolBlocks.add(new SelectOption(String.valueOf(temp.get('block')),String.valueOf(temp.get('block'))));
    }
    return lstSchoolBlocks;
  }

public List<SelectOption> getAttSchool() {
    List<SelectOption> lstSchools = new List<SelectOption>();
    List<RI_School_Report_Cards__c> lst = [Select School_List__r.Name, school_list__c, school_list__r.School__c from RI_School_Report_Cards__c where Submission_No__c != null AND Submit_Camp_4__c = true AND School_List__r.state__c =: strState AND School_List__r.National__c =: strNational AND school_list__r.block__c =: strBlocks];
    lstSchools.add(new SelectOption('','-None-'));
    for(RI_School_Report_Cards__c temp: lst) {
      lstSchools.add(new SelectOption(temp.school_list__c, temp.school_list__r.school__c + ' : ' + temp.school_list__r.Name));
    }
    return lstSchools;
  }

public pagereference loadReport()
{
    lstwrap1Sub.clear();
    String query = 'SELECT COUNT(School_List__r.Village__c) reached,SUM(MI_TL_Gov_SL__c) GOV_SL, SUM(MI_TL_Pvt_SL__c) PVT_SL, SUM(MI_TL_Other_SL__c) Other_SL';

    
      if (strState == '' || strState == null)
    {
      query += ', School_List__r.State__c grouper';    
    }
  
    else if(strBlocks == '' || strBlocks == null)
    {
      query += ', School_List__r.block__c grouper';
    }
    else
       {
     if(strSchool == '' || strSchool == null)
     {
     query += ', School_List__r.block__c grouper';
     }
     else
     {
     query += ', School_List__r.Name grouper';
     }
     }

query += ' FROM RI_School_Report_Cards__c WHERE School_List__r.National__c =: strNational AND Submission_No__c != null ';
  
  if (strState != '' && strState != null) {
       query += ' AND school_list__r.state__c =: strState';    
     }
  
  if(strBlocks != '' && strBlocks != null) {
      query += ' AND school_list__r.block__c =: strBlocks';
    }
  
   if(strSchool != '' && strSchool != null) {
    query += ' AND school_list__c =: strSchool';
    }

   if(strPhase != '' && strPhase != null) {
     query += ' AND BCI_CP_P_NO__c =: strPhase';
    }

    if (strState == '' || strState == null) {
      query += ' GROUP BY School_List__r.State__c';
      }
     else if (strBlocks == '' || strBlocks == null)
     {
      query += ' GROUP BY School_List__r.block__c';
         }
         else
       {
       if(strSchool == '' || strSchool == null)
       {query += ' GROUP BY School_List__r.block__c';}
       else
       {query += ' GROUP BY School_List__r.Name ';}
      
        }
     

     AggregateResult []ar = Database.query(query);
    Map <String, Integer> reach = new Map<String, Integer>();
    Map <String, Integer> GOV = new Map<String, Integer>();
    Map <String, Integer> PVT = new Map<String, Integer>();
     Map <String, Integer> Other = new Map<String, Integer>();
  
      for (AggregateResult temp : ar)
      {
      if(Integer.valueOf(temp.get('reached')) !=0)
      {
      reach.put(String.valueOf(temp.get('grouper')), Integer.valueOf(temp.get('reached')));
      }
      GOV.put(String.valueOf(temp.get('grouper')), Integer.valueOf(temp.get('GOV_SL')));
      PVT.put(String.valueOf(temp.get('grouper')), Integer.valueOf(temp.get('PVT_SL')));
      Other.put(String.valueOf(temp.get('grouper')), Integer.valueOf(temp.get('Other_SL')));
    }

  Integer i = 1;
    for(AggregateResult temp : ar)
     {
         lstwrap1Sub.add(new Report(i, String.valueOf(temp.get('grouper')), reach.get(String.valueOf(temp.get('grouper'))), GOV.get(String.valueOf(temp.get('grouper'))), PVT.get(String.valueOf(temp.get('grouper'))),Other.get(String.valueOf(temp.get('grouper'))),
      ((GOV.get(String.valueOf(temp.get('grouper')))+ PVT.get(String.valueOf(temp.get('grouper')))+ Other.get(String.valueOf(temp.get('grouper'))) )/reach.get(String.valueOf(temp.get('grouper'))))  ));
       i++;
    }

     List<Integer> total = new List<Integer>();
    total.add(0);
    total.add(0);
    total.add(0);
    total.add(0);
    total.add(0);
    if (strBlocks == '' || strBlocks == null) {
     for(Report temp : lstwrap1Sub)
     {
      total[0] += temp.reached;
      total[1] += temp.GOV_SL;
      total[2] += temp.PVT_SL;
      total[3] += temp.Other_SL;
      total[4] += temp.avg;
   
    }
  
       lstwrap1Sub.add(new Report(null, 'Total', total[0], total[1], total[2], total[3], total[4]));
       }
    return null;
}

class Report
{
public Integer reached {get;set;}
public String grouper {get;set;}
public Integer sr_no {get;set;}
public Integer GOV_SL{get;set;}
public Integer PVT_SL{get;set;}
public Integer Other_SL{get;set;}
public Integer avg {get;set;}  
   
public Report(Integer sr_no,String grouper,Integer reached,Integer GOVSL,Integer PVTSL,Integer other,Integer avg_gpo )
{
    
      this.grouper = grouper;
      this.sr_no = sr_no;
      this.reached = reached == null ? 0 : reached;
      this.GOV_SL = GOVSL == null ? 0 : GOVSL;
      this.PVT_SL = PVTSL== null ? 0 : PVTSL;
      this.Other_SL = other== null ? 0 : other;
      this.avg  = avg_gpo == null ? 0 :avg_gpo;

   
}
}
}
Hi Everyone,

I have this trigger where I'd like it to fire before insert, before update. We have 3 emails fields from the NPSP that we'd like the trigger to fire against so that if a new contact is being created, its email address is ran against any possible email within our system so it does not create that record if it finds a match. The 3 fields we have are npe01__HomeEmail__c, npe01__WorkEmail__c, and npe01__AlternateEmail__c. The trigger is working so that if a value is populated within the email field (which happens automatically based on the preferred email selected), and it finds a match, it will throw the error. However, the new email address entered seems to not be running against the email addresses that aren't selected as "preferred". Any ideas how to fix this?

Here is the code:

trigger DupEmail on Contact(before insert, before update) {
  for (Contact myContact: Trigger.new) {

List<Contact> dupes = [SELECT Id FROM Contact WHERE

     (Id != :myContact.Id AND
     Email != null AND
     (Email = :myContact.npe01__WorkEmail__c OR
     Email = :myContact.npe01__AlternateEmail__c OR
     Email = :myContact.npe01__HomeEmail__c))

     ]  
     ;
if (dupes.size() > 0) { String errorMessage = 'Duplicate contact found! '; errorMessage += 'Duplicate record URL = ' + 'https://cs16.salesforce.com' + '/' + dupes[0].Id;
myContact.addError(errorMessage);
} }
  }


Thank you!


Hi ,
I have tried this one in demo version.
I have posted my code when i clicked the checkbob  corresponding row  is in editable mode .
But the issue is it showing same records repetedly
Can you suggest me...


<apex:page StandardController="Contact" extensions="RowEditingcontroller">

  <apex:pageMessages />

    <apex:form id="theForm">
        <apex:pageBlock Title="ALL CONTACTS FOR ROW EIDTING" id="pb">
         
           <apex:commandButton value="Save" action="{!tosave}" id="saveButton"  />

           <apex:outputPanel >

        

              <apex:pageBlockTable value="{!Contacts}" var="c" cellpadding="2" border="1"  rowClasses="odd,even" styleClass="tableClass" id="opp_table">
                
                  <apex:column headerValue="Edit" >
                     <apex:inputcheckbox value="{!c.selected}">
                       <apex:actionSupport event="onclick" action="{!getSelected}"  rerender="pb" />
                     </apex:inputcheckbox>&nbsp;
                  </apex:column>
                   <apex:column headerValue="Contact name" >
                 
                    <b><apex:outputField rendered="{!IF(c.selected==true,false,true)}" value="{!c.con.Name}"/> </b>  
                       <apex:inputfield rendered="{!IF(c.selected==true,true,false)}" value="{!c.con.Name}"/>
                      </apex:column>
                 <apex:column headerValue="Contact No" >
                    <apex:outputfield rendered="{!IF(c.selected==true,false,true)}" value="{!c.con.MobilePhone}" />
                   <apex:inputfield rendered="{!IF(c.selected==true,true,false)}" value="{!c.con.MobilePhone}" />
                 </apex:column>
                 <apex:column headerValue="Email">
                   <apex:outputField rendered="{!IF(c.selected==true,false,true)}" value="{!c.con.Email}"/>
                    <apex:inputField rendered="{!IF(c.selected==true,true,false)}" value="{!c.con.Email}"/>
                 </apex:column>
               <apex:inlineEditSupport event="ondblClick"  showOnEdit="saveButton"/>
              

         </apex:pageBlockTable>

      </apex:outputPanel>

     </apex:pageBlock>
  </apex:form>

  </apex:page>


---------------------------------------------controller------------------------------------
public class RowEditingcontroller {

     //All property....

     public Contact contact{get;set;}
     public Id Id{get;set;}
     List<contactwrapper> contactList = new List<contactwrapper>();
     List<Contact> selectedContacts = new List<Contact>();

     //constructor....

     public RowEditingcontroller(ApexPages.StandardController controller) {
  
      

      }

     //displaying contact pageBlock table....
    
     public  List<contactwrapper> getContacts() {
  
        for(Contact c: [select Id,Name,Account.Name,MobilePhone,Email from Contact order by createdDate desc limit 1  ])
   
              contactList.add(new contactwrapper(c));
              return contactList;
          }

       //all selected contacts...for edit...     
     public PageReference getSelected() {
  
         selectedContacts.clear();
         for(contactwrapper conwrapper: contactList)
            if(conwrapper.selected == true)
     
            selectedContacts.add(conwrapper.con);
     
            return null;
        }
      
      
     public List<Contact> GetSelectedContacts(){
  
        if(selectedContacts.size()>0)
        return selectedContacts;
        else
       // ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Please select at least one Contact.'));
        return null;
    }
   
    //saving edited value...
 
      public PageReference tosave() {
      if(selectedContacts.size()>0){
    
        update selectedContacts;
        PageReference RowEditing=new PageReference('/apex/RowEditing');
        RowEditing.setRedirect(true);
        return RowEditing;
        }
        else{
        ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Please select at least one Contact.'));
         return null;
        }
     
       }
  
    //wrapper class...
  
    public class contactwrapper
    {
        public Contact con{get; set;}
        public Boolean selected {get; set;}
        public contactwrapper(Contact c)
        {
            con = c;
            selected = false;
        }
    }
}
Hi,

I am new to salsforce.I want to display the Campaign Members through VisualForce Page.I have wrriten the below code.I am getting the error as Unknown Property value.

Can anyone please help

VF page

<apex:page controller="callCampaignController">
    <apex:sectionHeader title="My Call List"></apex:sectionHeader>
    <apex:form >
        <apex:pageBlock title="">
          <!-- To show page level messages -->
          <apex:pageMessages ></apex:pageMessages>      
                   
            <apex:pageBlockTable value="{!CampaignMembers}" var="cm">
                               <apex:column value="{!cm.LeadId}"/>
               </apex:pageBlockTable>
        </apex:pageBlock>
             
    </apex:form>  
</apex:page>

Controller

public with sharing class callCampaignController {

       private List<CampaignMember> CampaignMembers;

    public List<CampaignMember> getCampaignMembers()
    {
       return CampaignMembers;
     
    }  
         
     }
Hi I am trying to implement this to show case history through GenericHistoryComponent and GenericHistoryComponentController at my visualforce page through below metion syntex :

<apex:tab label="Case Histories" name="GenericHistoryComponent">
         <c:GenericHistoryComponent recordLimits="50" myObjects="{!Case.Id}"/>
</apex:tab>

Once I clicked on a particular case I got a Visualforce error msg "Cannot convert the value of '{!myObject}' to the expected type".

if use below mention attrubute syntex in GenericHistoryComponent code

<apex:attribute name="myObjects" type="SObject" description="Object we wish to view the history of" required="true" assignTo="{!myObject}" />
<apex:attribute name="recordLimits" description="Number of lines of history to display" type="Integer" required="false" assignTo="{!recordLimit}" />

Please help
Hello All,

Requirement  : While creating Event record, when user clicks on SAVE(standard) button, need to show a confirmation box to user only if a checkbox is checked on Event. And once user confirms it, an email need to be fired to manager of that user and save the record.

Can we do this using overiding salesforce SAVE with custom button(execute javascript) ?

Thanks,
Prafull
Hello,

I am facing an issue to reRender apex:include through a commandLink, below is the part of the code

<apex:page id="mainVisualforcePg" controller="xyzController" id="vfPg1">

<apex:include pageName="menuBarVisualforcePg" id="VfPg2"/>

<apex:pageMessages id="error"/>
<apex:commandLink action="{!addToCart}" reRender="VfPg2">Add to Cart</apex:commandLink>

</apex:page>

when click on the "Add to Cart" link it try to reRender 'menuBarVisualforcePg", but after reRender the 'menuBarVisualforcePg" will disappera

So i tried putting the apex:include in apex:outputPanel - same issues

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

then i tried this
<apex:page id="mainVisualforcePg" controller="xyzController" id="vfPg1">
<script type="text/javascript">
       function reloadPage()
      {
              location.reload();
       }
</script>
<apex:include pageName="menuBarVisualforcePg" id="VfPg2"/>

<apex:pageMessages id="error"/>
<apex:commandLink action="{!addToCart}" reRender="VfPg2" oncomplete="reloadPage()">Add to Cart</apex:commandLink>

</apex:page>

This works but i do some validation in controller if commandLink action "addToCart" faills - i display error messages but  oncomplete="reloadPage()" will not show the disaplyed message

I am not able to come up with a solution to resolve this issue - any help is greatly appricated

Thanks
Nithin
I made owd setting to private and have checked all profiles that no user have view all , Modifiall permissions at profile level.

But still users are able to view the Records.

I observed that it was because of "Manual sharing"  or else   "Associated record owner or sharing"

How to remove all these users from this manual sharing. see the below imags

User-added image


Below is the users who have  able to see the records because of manual sharing. How to revert them not to view. ?

User-added image
Hello Everyone,
I am an APEX newbie trying to create a trigger that posts when an Opp is won. I have no other requirements besides that the when an Opportunity is updated to the won stage, it posts a pedesigned message to a specific Chatter Group. I took the code from another post (https://developer.salesforce.com/forums/ForumsMain?id=906F00000009AFJIA2) and tried to modify it to do just that but I am running into a problem in the IDE at the "for" line, with the error stating "Save error: Loop must iterate over collection type: Boolen". I tried to add an else statement to break and exit the loop but that gave me a bracket error. Am I totally off base here? Should I pulling a list first for the function to iterate over? Any help would be much appreciated! Thanks!

trigger ChatterPostWonOpp on Opportunity (after update) {

String status;
String OppAccName;
String OppOwnerName;

FeedItem post = new FeedItem();
  
    for(Opportunity o : Trigger.isupdate) {
                if(o.IsWon == true ) //This will be executed on new record insertion when Opp is won
                    for (Opportunity oppty : [SELECT Account.Name, Owner.Name FROM Opportunity])
                     {
                        OppAccName = oppty.Account.Name;
                        OppOwnerName = oppty.Owner.Name;
                      }  
                
                    status = OppOwnerName + ' just won ' + OppAccName + ' for ' + o.Amount + '!';

                    post.ParentId = '0F9g00000008b7c';
                    post.Title = o.Name;
                    post.Body = status;
                  
                    insert post;
          }
    }