• Thiruchuri Adityan
  • NEWBIE
  • 140 Points
  • Member since 2014

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 36
    Replies

<apex:page controller="V2Controller" tabStyle="Contact">
<apex:form >
<apex:sectionHeader subtitle="New Contact" title="Contact Edit" description="Contacts not associated with accounts are private and cannot be viewed by other users or included in reports." help="https://help.salesforce.com/articleView?err=1&id=contacts_overview.htm&siteLang=en_US&ty...>
<apex:pageBlock title="Edit Contact" >
   <apex:pageBlockSection title="Contact Information" columns="2" onkeydown="1" collapsible="false">
       <apex:outputField value="{!contact.ownerid} "/>
       <apex:inputField value="{!contact.Phone}"/>
      
    <apex:pageBlockSectionItem >
        <apex:outputlabel value="First Name"/>
            <apex:outputpanel >
            <apex:inputfield value="{!Contact.Salutation}"/>
            &nbsp;
            <apex:inputfield value="{!Contact.FirstName}"/>
        </apex:outputpanel>
   </apex:pageBlockSectionItem>
       <apex:inputField value="{!contact.homephone}" />
       <apex:inputField value="{!contact.LastName}" required="true"/>
       <apex:inputField value="{!contact.MobilePhone}"/>
       <apex:inputField value="{!contact.Accountid}"/>
        <apex:inputField value="{!contact.otherphone}"/>
        <apex:inputField value="{!contact.Title}"/>
        <apex:inputField value="{!contact.fax}"/>
        <apex:inputField value="{!contact.Department}"/>
        <apex:inputField value="{!contact.Email}"/>
        <apex:inputField value="{!contact.Birthdate}"/>
       <apex:inputField value="{!contact.Assistantname}"/>
       <apex:inputField value="{!Contact.ReportsToId}"/>
       <apex:inputField value="{!contact.AssistantPhone}"/>
       <apex:inputField value="{!contact.LeadSource}"/>
      
      
      
      
   </apex:pageBlockSection>
   <apex:pageBlockSection columns="2" title="Address Information" collapsible="false">
       <apex:inputField value="{!contact.MailingStreet}"/>
       <apex:inputField value="{!contact.otherStreet}"/>
        
       <apex:inputField value="{!contact.MailingCity}"/>
       <apex:inputField value="{!contact.otherCity}"/>
      
       <apex:inputField value="{!contact.MailingState}"/>
       <apex:inputField value="{!contact.otherState}"/>
      
       <apex:inputField value="{!contact.MailingPostalCode}"/>
       <apex:inputField value="{!contact.otherPostalCode}"/>
      
       <apex:inputField value="{!contact.MailingCountry}"/>
       <apex:inputField value="{!contact.OtherCountry}"/>
      
      
   </apex:pageBlockSection>
  
  
   <apex:pageBlockSection title=" Additional Information" collapsible="false">
      
       <apex:inputField value="{!contact.Languages__c}"/>
       <apex:inputField value="{!contact.Level__c}"/>
  
   </apex:pageBlockSection>
  
     <apex:pageBlockSection title=" Description Information" collapsible="false" >
      
       <apex:inputTextarea value="{!contact.Description}" rows="7" cols="90"/>
   </apex:pageBlockSection>
   <apex:pageBlockButtons >
       <apex:commandButton value="Save" Action="{!save}"/>  
       <apex:commandButton value="Save & New" Action="{!SaveAndNew}"/>
       <apex:commandButton value="Cancel" Action="{!cancel}" immediate="true"/> 
   </apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>

My Controller class

public class V2Controller
{
    
  public Account acc=new account();
  public Contact contact{get;set;}
  
            public V2Controller()
            {
                acc=[select id,Billingcity,BillingStreet,BillingState,BillingCountry,BillingPostalCode,ShippingStreet,
                            ShippingCity,Shippingstate,ShippingPostalCode,Shippingcountry from account where id=:apexpages.currentpage().getparameters().get('id')];
                            
                    contact=new Contact();
                    contact.Mailingcity=acc.Billingcity;
                    contact.MailingStreet=acc.BillingStreet;
                    contact.MailingState=acc.BillingState;
                    contact.MailingPostalCode = acc.BillingPostalCode;
                    contact.Mailingcountry=acc.BillingCountry;
                    
                    contact.otherStreet = acc.ShippingStreet;
                    contact.otherCity= acc.ShippingCity;
                    contact.otherstate = acc.Shippingstate ;
                    contact.otherPostalCode = acc.ShippingPostalCode;
                    contact.othercountry = acc.Shippingcountry;  
                    contact.accountid=acc.id;
            }
            
            public PageReference save()
             {
                insert contact;
                 //   ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM,'Record Created Successfully.Thank you!'));
                    PageReference pg = new PageReference('/'+acc.Id);
                    pg.setRedirect(true);
                    return pg;        
                }
          
            public pagereference cancel()
            {
                    PageReference pg = new PageReference('/'+acc.Id);
                    pg.setRedirect(true);
                    return pg;
              }
              
               public Pagereference SaveAndNew()
            {
                   insert contact;
                   return null;
              }

}


// i am trying  to create visualforce page which populate the value of account address field here values are populated byt my save and new button is not working fine please suggest 
Thanks in advance
sanjay
Hi All. I am trying to promote an Apex trigger, an Apex class, and an Apex test class. All work in sandbox environment, but when I try to validate during promotion to production, I get "Attempt to de-reference a null object" error, which points to the last line of code in the Apex class, which contains only the closing bracket. This was copied from a similar set of classes on another object, which is in production with no issues.

Here is the trigger:
trigger Contract_Triggers on Contract (after update) { //only runs after update

    set<id> ContractIds = new set<id>();

    if(trigger.isafter){
        if(trigger.isupdate){
            for(Contract c:trigger.new){
                if(c.Copy_Approval_Comments__c == true){
                    ContractIds.add(c.id);
                }
            }
        }
    }
    
    //calls @future class to ensure order of operation.
    if(ContractIds.size() > 0) {
        Contract_Approval_Comment_Handler.updateContractComment(ContractIds);
    }
        
}


Here is the Apex class:
public class Contract_Approval_Comment_Handler {
    @future
    public static void updateContractComment(set<id> cList){

        List<Contract> Contracts = [Select c.Id, c.Copy_Approval_Comments__c, c.Approval_Comments__c, (Select ActorId, Comments, CreatedDate From ProcessSteps order by CreatedDate) 
                             From 
                                 Contract c
                             where 
                                 c.Copy_Approval_Comments__c = True AND 
                                 c.id IN: cList];
            
        List<Contract> ContractsToUpdate = new List<Contract>(); //stores records to be updated
        
        //creates map of users that are active and non portal users 
        Map<ID, User> uMap = new Map<ID, User>([SELECT Id, Name FROM User WHERE IsActive =: true]);
        system.debug('User Map >>>>> ' + uMap);
        
        System.debug('******************************************** Contract = ' + Contracts);
        System.debug('******************************************** Size of Contract = ' + Contracts.size());
        
        if (Contracts.size()>0){
            for(Contract con: Contracts){
                if(con.ProcessSteps.size() >0){  
                    con.Approval_Comments__c = '';
                    for (ProcessInstanceHistory ps : con.ProcessSteps){
                        if (ps.Comments != null){
                            string username = uMap.get(ps.ActorId).name;   
                            con.Approval_Comments__c += '\n' + username + ': ' + ps.Comments;          
                             System.debug('*********************************************** Comments copied:' + ps.comments);
                         }
                     }
                     con.Copy_Approval_Comments__c =false;
                     ContractsToUpdate.add(con);
                 }
             }
        }
        
        if( ContractsToUpdate.size()> 0 ){
        
            Database.SaveResult[] srList = Database.update(ContractsToUpdate, false);
        
            // Iterate through each returned result
            for (Database.SaveResult sr : srList) {
                if (sr.isSuccess()) {
                    // Operation was successful, so get the ID of the record that was processed
                    System.debug('Successfully updated record ID: ' + sr.getId());
                } else {
                    // Operation failed, so get all errors                
                    for(Database.Error err : sr.getErrors()) {
                        System.debug('The following error has occurred.');                    
                        System.debug(err.getStatusCode() + ': ' + err.getMessage());
                    }
                }
            }
        }
    }    
}

And here is the test class:
@isTest(SeeAllData=True)
public class Contract_Approval_Comment_HandlerTest {
  static testMethod void run()

  {  List<Contract> Contracts = [Select c.Id, c.Copy_Approval_Comments__c From Contract c where c.Status = 'Activated' and c.Multiple_Trailers_at_this_location__c = False limit 100];
            
        List<Contract> ContractsToUpdate = new List<Contract>(); //stores records to be updated
        set<id> ContractIds = new set<id>();
             
        if (Contracts.size()>0){
            for(Contract con: Contracts){
                    con.Copy_Approval_Comments__c = True;
                    ContractsToUpdate.add(con);
                    ContractIDs.add(con.Id);
                }
             }
      
       if( ContractsToUpdate.size()> 0 ){
            Database.SaveResult[] srList = Database.update(ContractsToUpdate);
         }
   
   
       Test.startTest();     
            Contract_Approval_Comment_Handler.UpdateContractComment(ContractIds);    
       Test.stopTest();   
  }  
}
Any help will be greatly appreciated.

Thanks,
Stave A.
 
Hello,

Is there way to overide "edit" view (creation and update) and also detail view for object "case" ?
if yes, what are the steps ?

Ideally i want it only for certain profiles but i wil look at this usecase later

thanks for suggestion 
  • January 30, 2017
  • Like
  • 0
How to show a report in a visualforce page without using iframe and apex:canvas.  ?? Any ideas ??
Hai I have created a custom button for a standard page.  And I have written code for that button such that it should open an iframe modal dialog.  Now I want to close that dialog throught the button present in the child page.  I cant use any parent page methods as parent page is a Standard Salesforce Opportunity View page.  

 
Hi,
I have a custom VF  page, where I am displaying a list of record of a particular entity. Generally, if user double clicks on a column, he/she is able to edit only that particular column data(achieved through inline edit)... I want to avail an Edit button for the rows and on click of that, user should able to edit all the column data. How to achieve the same?
Hi,
I have a custom VF  page, where I am displaying a list of record of a particular entity. Generally, if user double clicks on a column, he/she is able to edit only that particular column data(achieved through inline edit)... I want to avail an Edit button for the rows and on click of that, user should able to edit all the column data. How to achieve the same?

I have two fields Opportunity(Lookup) and Products (Picklist).  On selection of opportunity i had written one soql query such that it retrieves only the products associated with opportunity.  But it is not working.

<apex:actionRegion >
                        <apex:inputField value="{!lineitem.OpportunityId}" >
                        <apex:actionsupport event="onChange" action="{!getprods}" reRender="thePanel"/>
</apex:actionRegion>
<apex:selectList value="{!lineitem.custom__c}" size="1" id="thePanel">
                            <apex:selectOptions value="{!prods}">
                        </apex:selectOptions>
                        </apex:selectList>

and my controller is 

public List<selectOption> getprods()
     {
            List<selectOption> options = new List<selectOption>();
            opp = [select PriceBook2Id from Opportunity where Id=:lineitem.OpportunityId];
            System.debug('sample'+opp);
            for (PriceBookEntry product : [SELECT Name from PriceBookEntry where PriceBook2Id=:opp.PriceBook2Id])
            {
                options.add(new selectOption(product.Name, product.Name));
            }
                return options;
  }

For an existing product it is working.  But for a newly created record the page is not even opening and throwing an error "List has no rows for assignment to SObject"

I have two fields Opportunity(Lookup) and Product(Picklist).  On selection of Opportunity the Product field is to be rerender i.e., basing on the input of opportunity only products assigned to that opportunity should only be shown..
Hi All,

Can anyone help me with validating if the DateTime field value is within the next 5 minutes in the salesforce formula field?
DateTime is a custom field.
global class GetPickValuesExitWH implements vlocity_cmt.VlocityOpenInterface2 {
 Object wareHouseName ='';
 Object wareHouseIdTask=''; 
    
global Object invokeMethod(String methodName, Map < String, Object > inputMap, Map < String, Object > outMap,Map < String, Object > options)
{
       
if (String.isNotBlank(methodName) && methodName.equalsIgnoreCase('GetPicklistValueExitWH'))
{
set<String> pickListValuesList= new set<String>();
Schema.DescribeFieldResult fieldResult = Order.Tet_Exit_Warehouse__c.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
for( Schema.PicklistEntry pickListVal : ple)
{
pickListValuesList.add(pickListVal.getLabel());    
}
    outmap.put('PicklistValues',pickListValuesList);
    return pickListValuesList;
   
   
}

if (String.isNotBlank(methodName) && methodName.equalsIgnoreCase('GetPicklistValueForPacking'))
{   String wareHouseId = (string)inputMap.get('WareHouseId');
    String wareHouseNameTask = (string)inputMap.get('WareHouseName');
    
    List<Map<String,String>> values = new List<Map<String,String>>();
    for(Schema.PicklistEntry e : Order.Tet_Exit_Warehouse__c.getDescribe().getPicklistValues()) {
           String value = e.getValue();
           String label = e.getLabel();
           if(value == wareHouseId )
           {
            wareHouseName = (Object)label ;
            break;
           }
        if(label== wareHouseNameTask)
        {
            wareHouseIdTask=(Object)value;
            break;
        }
        }
 
   outMap.put('wareHouseName', wareHouseName);
   outMap.put('wareHouseId', wareHouseIdTask);
    }

    return null;
}
}
I want a default list of tasks to show up when a project is created, depending on the project type (different tasks for different types of projects). I tried to use process builder to create the records, which would work fine except we want 30+ tasks and because of the limits on processes it wouldn't let me create more than 9 before it would give me error messages. I don't know how to work around that and I don't have the knowledge to write the coding for Apex triggers (I've tried but the trailhead lessons do not give detail on how exactly to write the code). Is there some other way to do this? I feel like I have exhausted all my options and I don't know what to do next. It's an important thing the company wants to implement and I don't know how to make it happen. Please help! 
public with sharing class HIV_ContactTriggerHandler{
public static void onBeforeInsert(List<Contact> lstContactNew,Boolean isInsert, Boolean isUpdate){
        try{
            Id hivAdminId ;
            hivAdminId = HIV_ApexSharing.getHIVAdminUserId();
            List<string> lstAcccntIds=new List<String>();
            List<String> lstRoles=new List<String>{Label.HIVProfilePTM,Label.HIVProfilePM,Label.HIV_OrganizationLead};
            for(Contact oContact : lstContactNew)
            {
                if(isInsert)
                {
                       if(lstRoles.contains(oContact.HIV_Role__c))
                    {
                        oContact.OwnerId=hivAdminId;
                    }
                }
            }
            
        }catch(Exception ex){
               Map<String, Object> mapErrorInfo = ERR_BaseErrorHandler.formatException(HIV_ApexSharing.class.getName(), 'Critical', ex, 'Error to add group member in Public group.');
            String sErrorInfoUpd = JSON.serialize(mapErrorInfo);
            ERR_ApplicationErrorHandler.createErrorLogRecord(sErrorInfoUpd);
        }
        
    }
}

<apex:page controller="V2Controller" tabStyle="Contact">
<apex:form >
<apex:sectionHeader subtitle="New Contact" title="Contact Edit" description="Contacts not associated with accounts are private and cannot be viewed by other users or included in reports." help="https://help.salesforce.com/articleView?err=1&id=contacts_overview.htm&siteLang=en_US&ty...>
<apex:pageBlock title="Edit Contact" >
   <apex:pageBlockSection title="Contact Information" columns="2" onkeydown="1" collapsible="false">
       <apex:outputField value="{!contact.ownerid} "/>
       <apex:inputField value="{!contact.Phone}"/>
      
    <apex:pageBlockSectionItem >
        <apex:outputlabel value="First Name"/>
            <apex:outputpanel >
            <apex:inputfield value="{!Contact.Salutation}"/>
            &nbsp;
            <apex:inputfield value="{!Contact.FirstName}"/>
        </apex:outputpanel>
   </apex:pageBlockSectionItem>
       <apex:inputField value="{!contact.homephone}" />
       <apex:inputField value="{!contact.LastName}" required="true"/>
       <apex:inputField value="{!contact.MobilePhone}"/>
       <apex:inputField value="{!contact.Accountid}"/>
        <apex:inputField value="{!contact.otherphone}"/>
        <apex:inputField value="{!contact.Title}"/>
        <apex:inputField value="{!contact.fax}"/>
        <apex:inputField value="{!contact.Department}"/>
        <apex:inputField value="{!contact.Email}"/>
        <apex:inputField value="{!contact.Birthdate}"/>
       <apex:inputField value="{!contact.Assistantname}"/>
       <apex:inputField value="{!Contact.ReportsToId}"/>
       <apex:inputField value="{!contact.AssistantPhone}"/>
       <apex:inputField value="{!contact.LeadSource}"/>
      
      
      
      
   </apex:pageBlockSection>
   <apex:pageBlockSection columns="2" title="Address Information" collapsible="false">
       <apex:inputField value="{!contact.MailingStreet}"/>
       <apex:inputField value="{!contact.otherStreet}"/>
        
       <apex:inputField value="{!contact.MailingCity}"/>
       <apex:inputField value="{!contact.otherCity}"/>
      
       <apex:inputField value="{!contact.MailingState}"/>
       <apex:inputField value="{!contact.otherState}"/>
      
       <apex:inputField value="{!contact.MailingPostalCode}"/>
       <apex:inputField value="{!contact.otherPostalCode}"/>
      
       <apex:inputField value="{!contact.MailingCountry}"/>
       <apex:inputField value="{!contact.OtherCountry}"/>
      
      
   </apex:pageBlockSection>
  
  
   <apex:pageBlockSection title=" Additional Information" collapsible="false">
      
       <apex:inputField value="{!contact.Languages__c}"/>
       <apex:inputField value="{!contact.Level__c}"/>
  
   </apex:pageBlockSection>
  
     <apex:pageBlockSection title=" Description Information" collapsible="false" >
      
       <apex:inputTextarea value="{!contact.Description}" rows="7" cols="90"/>
   </apex:pageBlockSection>
   <apex:pageBlockButtons >
       <apex:commandButton value="Save" Action="{!save}"/>  
       <apex:commandButton value="Save & New" Action="{!SaveAndNew}"/>
       <apex:commandButton value="Cancel" Action="{!cancel}" immediate="true"/> 
   </apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>

My Controller class

public class V2Controller
{
    
  public Account acc=new account();
  public Contact contact{get;set;}
  
            public V2Controller()
            {
                acc=[select id,Billingcity,BillingStreet,BillingState,BillingCountry,BillingPostalCode,ShippingStreet,
                            ShippingCity,Shippingstate,ShippingPostalCode,Shippingcountry from account where id=:apexpages.currentpage().getparameters().get('id')];
                            
                    contact=new Contact();
                    contact.Mailingcity=acc.Billingcity;
                    contact.MailingStreet=acc.BillingStreet;
                    contact.MailingState=acc.BillingState;
                    contact.MailingPostalCode = acc.BillingPostalCode;
                    contact.Mailingcountry=acc.BillingCountry;
                    
                    contact.otherStreet = acc.ShippingStreet;
                    contact.otherCity= acc.ShippingCity;
                    contact.otherstate = acc.Shippingstate ;
                    contact.otherPostalCode = acc.ShippingPostalCode;
                    contact.othercountry = acc.Shippingcountry;  
                    contact.accountid=acc.id;
            }
            
            public PageReference save()
             {
                insert contact;
                 //   ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM,'Record Created Successfully.Thank you!'));
                    PageReference pg = new PageReference('/'+acc.Id);
                    pg.setRedirect(true);
                    return pg;        
                }
          
            public pagereference cancel()
            {
                    PageReference pg = new PageReference('/'+acc.Id);
                    pg.setRedirect(true);
                    return pg;
              }
              
               public Pagereference SaveAndNew()
            {
                   insert contact;
                   return null;
              }

}


// i am trying  to create visualforce page which populate the value of account address field here values are populated byt my save and new button is not working fine please suggest 
Thanks in advance
sanjay
Hi All. I am trying to promote an Apex trigger, an Apex class, and an Apex test class. All work in sandbox environment, but when I try to validate during promotion to production, I get "Attempt to de-reference a null object" error, which points to the last line of code in the Apex class, which contains only the closing bracket. This was copied from a similar set of classes on another object, which is in production with no issues.

Here is the trigger:
trigger Contract_Triggers on Contract (after update) { //only runs after update

    set<id> ContractIds = new set<id>();

    if(trigger.isafter){
        if(trigger.isupdate){
            for(Contract c:trigger.new){
                if(c.Copy_Approval_Comments__c == true){
                    ContractIds.add(c.id);
                }
            }
        }
    }
    
    //calls @future class to ensure order of operation.
    if(ContractIds.size() > 0) {
        Contract_Approval_Comment_Handler.updateContractComment(ContractIds);
    }
        
}


Here is the Apex class:
public class Contract_Approval_Comment_Handler {
    @future
    public static void updateContractComment(set<id> cList){

        List<Contract> Contracts = [Select c.Id, c.Copy_Approval_Comments__c, c.Approval_Comments__c, (Select ActorId, Comments, CreatedDate From ProcessSteps order by CreatedDate) 
                             From 
                                 Contract c
                             where 
                                 c.Copy_Approval_Comments__c = True AND 
                                 c.id IN: cList];
            
        List<Contract> ContractsToUpdate = new List<Contract>(); //stores records to be updated
        
        //creates map of users that are active and non portal users 
        Map<ID, User> uMap = new Map<ID, User>([SELECT Id, Name FROM User WHERE IsActive =: true]);
        system.debug('User Map >>>>> ' + uMap);
        
        System.debug('******************************************** Contract = ' + Contracts);
        System.debug('******************************************** Size of Contract = ' + Contracts.size());
        
        if (Contracts.size()>0){
            for(Contract con: Contracts){
                if(con.ProcessSteps.size() >0){  
                    con.Approval_Comments__c = '';
                    for (ProcessInstanceHistory ps : con.ProcessSteps){
                        if (ps.Comments != null){
                            string username = uMap.get(ps.ActorId).name;   
                            con.Approval_Comments__c += '\n' + username + ': ' + ps.Comments;          
                             System.debug('*********************************************** Comments copied:' + ps.comments);
                         }
                     }
                     con.Copy_Approval_Comments__c =false;
                     ContractsToUpdate.add(con);
                 }
             }
        }
        
        if( ContractsToUpdate.size()> 0 ){
        
            Database.SaveResult[] srList = Database.update(ContractsToUpdate, false);
        
            // Iterate through each returned result
            for (Database.SaveResult sr : srList) {
                if (sr.isSuccess()) {
                    // Operation was successful, so get the ID of the record that was processed
                    System.debug('Successfully updated record ID: ' + sr.getId());
                } else {
                    // Operation failed, so get all errors                
                    for(Database.Error err : sr.getErrors()) {
                        System.debug('The following error has occurred.');                    
                        System.debug(err.getStatusCode() + ': ' + err.getMessage());
                    }
                }
            }
        }
    }    
}

And here is the test class:
@isTest(SeeAllData=True)
public class Contract_Approval_Comment_HandlerTest {
  static testMethod void run()

  {  List<Contract> Contracts = [Select c.Id, c.Copy_Approval_Comments__c From Contract c where c.Status = 'Activated' and c.Multiple_Trailers_at_this_location__c = False limit 100];
            
        List<Contract> ContractsToUpdate = new List<Contract>(); //stores records to be updated
        set<id> ContractIds = new set<id>();
             
        if (Contracts.size()>0){
            for(Contract con: Contracts){
                    con.Copy_Approval_Comments__c = True;
                    ContractsToUpdate.add(con);
                    ContractIDs.add(con.Id);
                }
             }
      
       if( ContractsToUpdate.size()> 0 ){
            Database.SaveResult[] srList = Database.update(ContractsToUpdate);
         }
   
   
       Test.startTest();     
            Contract_Approval_Comment_Handler.UpdateContractComment(ContractIds);    
       Test.stopTest();   
  }  
}
Any help will be greatly appreciated.

Thanks,
Stave A.
 
I am not able to cover the below lines in test class. please help.
Contact con = new contact();
          con.id= rel.From_Individual__c;
          con.firstname= rel.From_Individual__r.firstname;
          con.lastname= rel.From_Individual__r.lastname;
          con.email= rel.From_Individual__r.email;
          conListForAdvisor.add(con);
        }
        if(conListForAdvisor.size()>0){
          update relationListForAdvisor;
          update conListForAdvisor;
        }
        for(Event ev : newEvents){
            System.debug(ev);
          if(ev.eventName != null && ev.eventName != ''){
            cEvent = new Event__c();

            String parishRegion = getCRSRegion(University);
            cEvent.Name = ev.eventName;
            cEvent.Status__c = 'Completed';
            cEvent.Description__c = ev.eventDescription;
            if(ev.eventCheckAllThatApply != null) {
              cEvent.Check_all_that_apply_to_your_campus__c = 
              String.valueOf(ev.eventCheckAllThatApply).remove('(').remove(')').replace(',',';');
            }
            if(ev.eventNuberAttended != null && ev.eventNuberAttended != ''){
              cEvent.Number_Attended__c = Decimal.ValueOf(ev.eventNuberAttended);
            }
            if(ev.eventLetters != null && ev.eventLetters != ''){
              cEvent.If_you_hand_wrote_letters_please_list__c = Decimal.ValueOf(ev.eventLetters);
              /*if(Decimal.ValueOf(ev.eventLetters) > 0 ){
                cEvent.Action__c = 'EN - Directing a LETTER WRITING campaign';
              }*/
            }
            
            String evSelectedOptions = '';
            for(String s: ev.eventCheckAllThatApply) {
              evSelectedOptions += s + ' ';
            }
            //evSelectedOptions.addAll(ev.eventCheckAllThatApply);
            System.debug('>>>evSelectedOptions: ' + evSelectedOptions);

            if(evSelectedOptions.contains('Chapter meetings')) {
              cEvent.Action__c = 'ED - Coordinating a MEETING';
            }
            else if(evSelectedOptions.contains('Legislative Visit')) {
              cEvent.Action__c = 'EN - Facilitating a CONGRESSIONAL VISIT';
            }
            else {
              cEvent.Action__c = 'ED - Providing general OUTREACH';
            } 
            
            cEvent.Category__c = catagory;
            String campaignName = ''; // hold the program initiative to attach the event to
            cEvent.Parish_or_School__c = University;
            cEvent.Primary_Institution__c = University;
            

            cEvent.CRS_Region__c = 'Replicator; ' + parishRegion;
            if(ev.eventDate != null && ev.eventDate !=''){
              cEvent.Start_Date__c = date.ValueOf(ev.eventDate);
              cEvent.End_Date__c = date.ValueOf(ev.eventDate);
              cEvent.Event_Date_Time__c = cEvent.End_Date__c;
            }
            cEvent.Association_if_other__c = ''; // reset after the field has been used.            
            lstEvents.add(cEvent);
          }

        }
        if(lstEvents.size() > 0){

          insert lstEvents;
          for(Event__c events : lstEvents){
            eventIds.add(events.Id);
          }
          eventId = lstEvents[0].Id;
        }
Hi Experts,

I have requirment that is there is an Record type called Prospecting and i have custom clone button on the Prospecting record type record which is there in the Opportunity.

When ever i click on that Prospecting record type record a  new record has to create and it need to populate the parent record(original record which i cloned) that id needs to populate in field called 'Prospecting_Opportunity__c'.  i wrote code but its throwing validations rules of another record type can you guys help me pleaes.

1 ) Prospecting is record type which is there in the opportunity
2) created a button and assigned to the pagelayout

Apex class code:

global class customClone
{
    webservice static void cloneAccount(Id acctId) // you can pass parameters
    { 
    
       
      Opportunity acc = [SELECT ID, Name,recordtypeid FROM Opportunity WHERE Id = : acctId];
      
      //Id AccRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('200+').getRecordTypeId();
      Opportunity newacc=acc.clone(false); 
       newacc.Prospecting_Opportunity__c=acc.id;
       newacc.Name = acc.Name +'-'+'Cloned';
       
       insert newacc;
        
          
   
   }
      
    }

Button code:

{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")} 
var opptyId='{!Opportunity.Id}'; 
sforce.apex.execute("customClone","cloneAccount",{acctId: opptyId});

Thanks in advance
I have a lead assignment rule set in to notify my queue members when a lead comes in for their region. I want a second notification to go to the Queue members when the lead gets an new owner (user). Am i right in using Process Builder? The Process is failing can anyone see why?
User-added image
User-added imageUser-added imageUser-added image
Here is the failure message:
User-added image
Hi All,

     I need to use radio button in place of CheckBoxes. But when i try to change the VF tag It is not working.
// The Below code is working fine with no issue //
 <apex:column >
       <apex:inputCheckbox value="{!con.isSelected}" />
  </apex:column> 

///////This is the code which i am using for Radio button. Its showing the radio button but functionality is not working here in case of Radio ////

   <apex:column >                    
       <input type="radio" value= "{!con.isSelected}" />                                     
    </apex:column>

Kindly help me on this.
Hello,

Is there way to overide "edit" view (creation and update) and also detail view for object "case" ?
if yes, what are the steps ?

Ideally i want it only for certain profiles but i wil look at this usecase later

thanks for suggestion 
  • January 30, 2017
  • Like
  • 0
Hi All,
 Am not able to make my status Successful when run my Test Method...
PFB my screenShot
IUser-added image
Thanks & Regards,
Tapas
how to get selected value from the picklist using javascript from visualforce page