• SRK
  • SMARTIE
  • 920 Points
  • Member since 2010

  • Chatter
    Feed
  • 26
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 490
    Replies
Not Able to edit Dynamic Dashboards as i has switched to Lightning UI
please suggest me if any one knows how can i achieve this requirement.

I want to check name case insensitive.
find below my code.
Public void UpdateStageNameSample(List<Opportunity> oppList){       
        List<Opportunity> optyList = new List<Opportunity>();
        String s = 'valued client';       
        for(Opportunity opp: oppList){
            if(opp.Name.contains(s.toUpperCase())){                
                opp.StageName = 'Sample';                           
            }
        }       
    }
  • November 25, 2015
  • Like
  • 0
Hi all,

How to get the selected day dates in the a given date range. For eg: i am selecting the date range from nov 1st to nov 30th. In this date range i want to get the monday date's i.e nov 2nd, nov 9th, etc.

Also i want to check a condition in soql like createddate day is equal to monday .

Kindly help me in this.

Regards,
Abinaya.

 
Hello,

I am integrating Google maps with Salesforce using below link
http://www.bulkified.com/How+to+use+the+Google+Maps+API+in+Salesforce.com

This above example gives a VF page to calculate.

I have below Objects:
ObjectA__C
CustomField__1
CustomField__2
CustomField__3

When Address is entered in CustomField__1 and CustomField__2, I want to calcuate the distance and time and fill it automatically in CustomField__3.

thanks for suggestion !
 
/-- Below is my Visual force page coding.

<apex:page Controller="CreateAccount" >

<head>
  <meta charset="utf-8"/>
  <title>jQuery UI Datepicker - Default functionality</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"/>
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css"/>

  <script>
  $(function() {
    $( "#datepicker" ).datepicker();
  });
  </script>
</head>
<body>
 

 
</body>

<apex:stylesheet value="http://www.pageresource.com/wallpapers/wallpaper/latest-google-hd.jpg"/>
 <apex:form id="form">
 <div align="center" draggable="false" >
 <apex:image url="http://googlezone.ru/wp-content/uploads/2014/11/101020141429292562322.jpg" width="120" height="50"/>
 </div>
 <apex:pageBlock title="Create your Google Account" mode="edit"  id="pgblock"> 
 <apex:pageBlockSection >
 
 Firstname <apex:inputtext value="{!Firstname}"/>
 Lastname <apex:inputtext value="{!Lastname}"/>
 Username <apex:inputtext value="{!Username}"/>
 Password <apex:inputtext value="{!Password}"/>
 Retypepassword <apex:inputtext value="{!Retypepassword}"/>
 MobilePhone <apex:inputtext value="{!MobilePhone}"/>
 Email <apex:inputtext value="{!Email}"/>
 DateOfBirth <input type="text"  id="datepicker"/>
 </apex:pageBlockSection>
 <apex:commandButton action="{!saveRecord}" style="float:centre" styleClass="button" value="Save" id="recordID"  />
 </apex:pageBlock>
 </apex:form>
</apex:page>


Apex Class

public with sharing class CreateAccount {

    public PageReference saveRecord() {
       
 GoogleBlog__c blog = new GoogleBlog__c();
    blog.FirstName__c= Firstname;
    blog.Lastname__c= Lastname;
    blog.Password__c= Password;
    blog.RetypePassword__c= Retypepassword;
    blog.Username__c= Username;
    blog.MobilePhone__c= MobilePhone;
    blog.Email__c= Email;
    Date.valueOf(DateOfBirth);
    insert blog;
    system.debug('!!!!!!!!!!' + blog);
  return null;
  
    }

    public String getContact() {
        return null;
    }


Public string Firstname {get;set;}
Public string Lastname {get;set;}
Public string Username {get;set;}
Public string Password {get;set;}
Public string Retypepassword {get;set;}
Public string MobilePhone {get;set;}
Public string Email {get;set;}
Public string DateOfBirth {get;set;}
}

When i try to save a Recod it throws me error like this, Can anyone suggest me what is the mistake in thisERROR
Hi All,

I have a scenario like, I need to check the owner.division as a condition in my SOQL for a cusotm object query.  But for a custom object you cannot use the owner.division field in querying the value.

But, by using map, I can retreive all the user records and check the condition from there while looping the list of custom object records as follows, 

Map<id,User> ulist = new Map<id,User>([Select id,name,division from user]);

List<CustomObject__c> customList = [Select id,name, ownerid from CustomObject__c Where <my condition here>];

for(CustomObject__c c : customList)
{
       if(ulist.get(c.ownerid).division == 'xxxx')    //This is possible
       {
              //my logic goes here
        }
}

But, I want to check the condition of this division in the query itself. Becuase would like to filter out the records in the query. Is this possible?
Please help.

Thanks in advance!
 

Hey there,

 

I am attempting to deploy a very important Apex Trigger to production. In sandbox the trigger has a test coverage of 100% and works perfectly. However, upon deploying it failed because of two old tests.

 

This is the error:

 

TESTdestiny_Product_bIbU.myUnitTest() Class 18   Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: FIELD_FILTER_VALIDATION_EXCEPTION, Value does not exist or does not match filter criteria.: [Destiny_Product__c]", Failure Stack Trace: "Class.TESThelper.__sfdc_testDestiny00: line 18, column 1 Class.TESTdestiny_Product_bIbU.myUnitTest: ... TESTdestiny_Service_bIbU.myUnitTest() Class 18  

Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []", Failure Stack Trace: "Class.TESThelper2.__sfdc_testDestiny01: line 18, column 1 Class.TESTdestiny_Service_bIbU.myUnitTest: line 25, column 1"

 

 

 

What can I do?

 

Thankyou

please any one tell the process of moving app sandbox to producction?  and how to create sandbox and production and change sets ?

I am trying to update Parent and child object using Nest Query but child records are not getting saved.

 

Public List<Account> getAccount(){
list<Account> acc = [select Id, Name,Country, (select Id, FirstName,LastName,Email from contact) from account where Id=: a.Id];
return acc;
}

 

<apex:repeat var="a" value="{!Account}">
    <apex:outputText value="{!a.Name}"/>
      <apex:repeat var="c" value="{!a.Contacts}">
        <apex:inputfield value="{!c.FirstName}">
        <apex:inputfield value="{!c.LastName}">
        <apex:inputfield value="{!c.Email}">
      </apex:repeat>
<apex:repeat>

 

  • March 29, 2013
  • Like
  • 0

i am calling a batch class from finish method of another batch class and facing the above error

my finish method code is public class BatchPublicCampaignsToGoogle implements Database.Batchable, Database.Stateful, Database.AllowsCallouts {

public void finish(Database.BatchableContext BC){

        if(newBatch == true)
        {           CalendarSettings__c c= [Select Id, Name, CalendarId__c,CalendarQuery__c,FieldToDisplay__c from CalendarSettings__c WHERE Name = 'Internal marketing Calendar' LIMIT 1] ;
       BatchPublicCampaign bjob = new BatchPublicCampaign();
                Database.executeBatch(bjob);

        }
    }

} but i was facing error Database.executeBatch cannot be called from a batch or future method.

after finishing Batch request i am trying to call it(i have to call it for two times) again.so i call it.

How to get rid of error.i know we can call a batch class from finish method of a Batch Class but why i am getting this error ??

 

Hi All,
My requirement is to restrict users to save EVENTS thats being created for ACCOUNTS based on the below criteria.

 

If the START DATE of the Event is greater than TODAY ,"YOR_Activity_Status__c" cannot be set to "Completed" and the DESCRIPTION field cannot be NULL.

 

Below is the Events trigger thats being written to achieve this:

 

I am getting this error message while saving:

 

Please help me to solve this and correct if I am wrong.

 

Error: Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger myTrigger caused an unexpected exception, contact your administrator: myTrigger: execution of AfterInsert caused by: System.FinalException: Record is read-only: Trigger.myTrigger: line 3, column 1

 

***************************************************************

trigger myeventvalidation on Event (after insert,after update) {
Set<Id> accIds = new Set<Id> ();
List<Account> lstAcc;
for(Event e: Trigger.new) {
if(e.StartDateTime > System.today() && e.YOR_Activity_Status__c == 'Completed' && e.Description ==NULL) {
e.addError('Not Possible');
}
}


lstAcc = [Select Id from Account where ID IN: accIds];

for(Event e: Trigger.new) {
if(Trigger.isInsert) {
for(Account a: lstAcc) {
if(e.StartDateTime > System.today() && e.YOR_Activity_Status__c == 'Completed' && e.Description ==NULL) {
e.addError('Not Possible');
}
}
}


else if(Trigger.isUpdate) {
if(e.StartDateTime > System.today() && e.YOR_Activity_Status__c == 'Completed' && e.Description ==NULL) {
for(Account a: lstAcc) {
if(a.Id == e.WhatId) {
e.addError('Not Possible');
}
}
}
}
}

update lstAcc;
}

***************************************************************

  • March 26, 2013
  • Like
  • 0

I am using exact target to send emails to contacts , leads , campaigns, reports. But whenever I send an email to a lead or to a report (of leads or contacts) it fails with the following error message " (UpdateSyncStatus) Job failed after repeated subscriber sync attempts or sync timeout, job 8254 ".

 

Please help.

 

Thanks

Hi ,

I need to Clone a Record and once i clone i need the new record to have all fields carried and input the record Id from which it is cloned  ??

 

 

Please help me out with this very Urgent need

Hi,

 

I found this type of method in the Cook book area that helps remove script statements as I understand; however, I wanted to make sure that I understand the key in this type of code.

 

I wrote the looping version (not shown) and adding the MyCustomKey to the map as the key value but in the code below I thought if I put that field first in the SELECT statement it would pick that field but instead it looks like it automatically chooses the ID!  Is that a correct statement and if so is ther a work around to force it to select the key I want or do I have to stay with the loop method to get the results I want.

 

...

...

String DynamicQuery = 'SELECT MyCustomKey__c, Name, Id FROM Opportunity ' + WhereClause;
Map<String, Opportunity> OppsMap = new Map<String, Opportunity>((List<Opportunity>)Database.query(DynamicQuery));

...

...

 

 

when i press the save&new button on that time ,the popup page is not refreshed......and how to save that record and refresh with new page.....Any Examples......

 

 

 

Thanks

=============

venkatSforce89

My code is hittting governor limits incase of multiple records update or insert.

Please help me to reduce number of script statements in this code,

 

Sometimes eventhoug we are not updating anything regarding to account, this trigger is calling,

we have rollup summary fields for this filed from another object is that the reason?

rigger Behr_InsertAccountTeamMember_US on Account (after insert,after update) {
 List<AccountTeamMember> lstAcTeam = new List<AccountTeamMember>();

List<UserRole> lstrole=new List<Userrole>();
map<ID,set<ID>> usermap=new map<ID,set<ID>>();
map<Id,Id> maprole=new map<Id,Id>();
map<Id,Id> accmap=new map<Id,Id>();
map<Id,Id> mapownerrole=new map<Id,Id>();
List<User> ownerrolelst=new List<User>();
set<ID> setOwner=new set<Id>();
List<User> userList=new List<User>();
lstrole=[select id,ParentRoleId from UserRole];
set<ID> Parentlst=new set<ID>();
map<Id,Id> userproId=new Map<Id,Id>();
set<Id> TeamMember=new Set<Id>();
List<AccountShare> lstAccShare =new List<AccountShare>();
List<AccountShare> lstUpdateAccShare = new List<AccountShare>();

set<Id> accid=new set<Id>();

for(UserRole ur:lstrole){
maprole.put(ur.id,ur.ParentRoleId);

}
Profile p=[select Id from Profile where name='Standard User Level 2'];
//Profile p=[select Id from Profile where name='System Administrator'];

userList=[select id ,Userroleid,ProfileId from user where IsActive=true ];
for(User u1:userList){
userproId.put(u1.id,u1.ProfileId);
if(usermap.get(u1.userroleid)!=null){

usermap.get(u1.userroleId).add(u1.id);

}
else{
set<Id> setuid=new set<ID>();
setuid.add(u1.id);
usermap.put(u1.userroleid,setuid);

}
}

for(Account acc:trigger.new){
    accmap.put(acc.id,acc.ownerid);
    setOwner.add(acc.OwnerId);
    accid.add(acc.id);
}

ownerrolelst=[select id ,userroleid from user where id in:setOwner ];
Userrole adminrole1=[select id from Userrole where Name='System Administrator'];
system.debug('OOOO'+adminrole1.id);
Userrole chinarole=[select id from Userrole where Name='China Users'];
Userrole ITDEVrole=[select id from Userrole where Name='IT DEV'];
Userrole ProMktgadmin=[select id from Userrole where Name='Pro Mktg Administrator'];
Userrole ProMktguser=[select id from Userrole where Name='Pro Marketing User'];
 Userrole ProSalesSVP=[select id from Userrole where Name='Pro Sales SVP'];
for(User u:ownerrolelst){
mapownerrole.put(u.id,u.UserRoleId);

}
for(Id acccid:accmap.keyset()){
if((Trigger.isInsert ||(Trigger.isupdate && Trigger.newmap.get(acccid).Ownerid!=Trigger.oldmap.get(acccid).OwnerId))&& userproId.get(accmap.get(acccid))==p.id){
//Parentlst.add(mapownerrole.get(accmap.get(acccid)));
id role=mapownerrole.get(accmap.get(acccid));
Id ParentRoleNext=maprole.get(mapownerrole.get(accmap.get(acccid)));
system.debug('PPPPPPPPPPPPPPPP'+role);

if( role!=adminrole1.id && role!=chinarole.id && role!=ITDEVrole.id && role!=ProMktgadmin.id && role!=ProMktguser.id){

while(ParentRoleNext!=ProSalesSVP.id    ){
system.debug('within if block');
if(maprole.containskey(ParentRoleNext))
system.debug('PPPPPPPPPPPPPPPP'+role);
Parentlst.add(ParentRoleNext);
system.debug('IIIIIIII'+Parentlst);
ParentRoleNext=maprole.get(ParentRoleNext);
}
system.debug('@@@@@@'+Parentlst);
for(Id pid: Parentlst){
for(id uid1:usermap.get(pid)){
AccountTeamMember tm = new AccountTeamMember();
                tm.UserId =uid1;
                tm.AccountId = acccid;
                tm.TeamMemberRole = 'Sales Manager';

lstAcTeam.add(tm);
TeamMember.add(uid1);
}

}

}
AccountTeamMember tm1 = new AccountTeamMember();
                tm1.UserId =accmap.get(acccid);
                tm1.AccountId = acccid;
                tm1.TeamMemberRole = 'Sales Rep';
                lstAcTeam.add(tm1);
  // TeamMember.add(accmap.get(acccid));             
}
}
if(lstAcTeam.size()>0){
insert lstAcTeam;


 lstAccShare = [Select Id, AccountId, OpportunityAccessLevel, AccountAccessLevel,ContactAccessLevel, UserOrGroupId ,
                        CaseAccessLevel From AccountShare where AccountId IN: accid
                          AND UserOrGroupId IN: TeamMember] ;


         }       

 for (AccountShare ash:lstAccShare )
            {
            ash.AccountAccessLevel='Edit';
            ash.ContactAccessLevel='Edit';
            ash.OpportunityAccessLevel='Edit';
            ash.CaseAccessLevel ='Edit';
            
            lstUpdateAccShare.add(ash);
            } 
         update lstUpdateAccShare;

                        

}

 

hi

 

Please tell me that How to hide the custom field on button click  on VF Page.

Hi all,

 

I have a requirement where we have data in mysql database and apex should be coded in such a way that it  gets data from mysql and display on visualforce page. I donot have any idea on how to integrate Salesforce with mysql database. 

 

Please help.

 

Thanks,

Pragati

 

Hi All,

 

I am new to writing code in APEX. I have an Object 'UnProc' with 10 fields and it is 'POPULATED'. I have two more objects ('Account and Contact') with 5 fields each and these Objects have to be populated. I have to write an APEX code using the batch apex and scheduler so that i can create new records for 'Account' and 'Contact' takin the records which are already there in the 'UnProc'. After the Account and Contact fields get populated with the UnProc records. The UnProc record has to be deleted.

I have already read the batch apex and scheduler related docs on saleforce.com and have understood and created the class for them. But i am stuck at the implementation of my application. Pseoudo code or some lines of code can be useful.

hi
 
I have created a new Email Template of type Custom or Visualforce or Text.
 
The following case has been assigned to you.
Company: {!Account.Name}
Contact Name: {!Contact.Name}
Case #: {!Case.CaseNumber}
Subject: {!Case.Subject}
Description: {!Case.Description} 
 
I have written an apex class for calling this email template and sending an email.
 
I am sending an email to the User.
 
But i dont know how to pass values to Merge fields (mentioned above) in that email template from an apex class. 
 
How can I pass values to merge fields in Email template? Please help me out.
Thanks,
JBabu.
  • May 30, 2012
  • Like
  • 0
Hi All 

I am trying to add user role as GroupMember  to a group 

Now i have problem that GroupMember have only two fields GroupId // which will take the group id and UserOrGroupId = // which will only take user id or a group id, but it is not taking role id

and as have check that when we insert role as GroupMember throw cofiguration, salesforce create a saprate group and populate RelatedId with the role id and then insert this new group in GroupMember 

exmaple if there is a Group G1 and we want to add a role R1 , what salesforce will do is it create a saparate Group (let call G2) and in G2 salesforce pupulate RelatedId with the role id and type =role and then add this group G2 as group member to G1 (in that case in group mebmber Groupid will be poulated with G1 and UserOrGroupId populated with G2 id)

Now problem is that RelatedId , is not writable throw apex code so i am not able to understand how to insert a Role as a group member using apex
  • January 07, 2016
  • Like
  • 0
Hi All 

I am trying to add user role as GroupMember  to a group 

Now i have problem that GroupMember have only two fields GroupId // which will take the group id and UserOrGroupId = // which will only take user id or a group id, but it is not taking role id

and as have check that when we insert role as GroupMember throw cofiguration, salesforce create a saprate group and populate RelatedId with the role id and then insert this new group in GroupMember 

exmaple if there is a Group G1 and we want to add a role R1 , what salesforce will do is it create a saparate Group (let call G2) and in G2 salesforce pupulate RelatedId with the role id and type =role and then add this group G2 as group member to G1 (in that case in group mebmber Groupid will be poulated with G1 and UserOrGroupId populated with G2 id)

Now problem is that RelatedId , is not writable throw apex code so i am not able to understand how to insert a Role as a group member using apex
  • January 07, 2016
  • Like
  • 0

just a quick question

If  i am developing a Offline Hybrid application in that case i belive we cannot use VF pages

I think i need to write HTML5 Page

 

As it's a offline application so if internaet is not aviable i belive users are not able to access the VF Pages

 

Please provide your valueable thoughts

  • June 10, 2013
  • Like
  • 0

Hi I have SAP Team but those gays don;t know how to generate WSDL from SAP
Can any once provide me a sample WSDL which can be consume in salesforce

OR can Provide the Step to generate WSDl from SAP system

 

it will be really grate help

  • April 12, 2013
  • Like
  • 0
Hi ,

Can we stop the opportunity owner change for open opportunities when an account owner is changed,please advice on this ..

Regards,
Kiran
Hi, 

I am struck for writing test class for below requirement.........Actaually i am schedule class from custom button

Here is my code
global class class_name{
  
 
  
    WebService static String Method_name()
    
    {
      
            Datetime currentTime = datetime.now();  
            Datetime newTime = currentTime.addSeconds(20);  
            // build cron expression  
            String sch= String.valueOf(newtime.second()) +' ' + String.valueOf(newtime.minute()) + ' ' + String.valueOf(newTime.hour()) + ' ' + String.valueOf(newTime.day()) + ' ' + String.valueOf(newTime.month()) + ' ? ' +  String.valueOf(newTime.year());  
            ScheduleClass_Name scheduleObject = new ScheduleClass_Name();  
           Id sId = system.schedule('schdclass'+newtime , sch, scheduleObject ); 
            
            return sId ;
       
             
    }
   
   }

So far i covered 0 percent .............Pls help me out.........

Adv Thnx
Siv
 
  • January 25, 2016
  • Like
  • 0
Hi,
can some one tell me about this exception and  where to add null check:
my errors are:classname.methodname1: line 78,column 1
                    classname.methodname2: line 78,column 1 
                    classname.methodname3: line 78,column 1
                    Trigger:TriggerNAme:line no,column no

where i need to add null check in the class methods or in trigger.
Hi all,
i have created a trigger on account object and i need to insert a record into another custom object<
sales__c> based on whether the account field email has changed to a new value from old value.
This is my code. which is not working.can someone let me know where i m going wrong??
trigger CreateSalesAccount on Account  (after update) {


    List<Sales__c> createSales = new List <Sales__c> ();
    for (Account acc : trigger.new) {
       Account  oldAccount = Trigger.oldMap.get(acc.Id);
       String oldEmail = oldAccount.emailaddress__c ;
       String newEmail = acc.emailaddress__c;
    
		if (oldEmail != newEmail) {
               createSales.add(
                    new Sales__c (  Type = 'presales',Error_Message__c  = 'error',Status__c  = 'success'));
            }                             
    }
    try {
        insert createSales;
    }
    catch (Exception Ex){
        system.debug(Ex);
    }
}

 
Hi folks ,

   My requirement is that i would like to know users acess on records ...Means weather he have read/create/Edit on which records and that records belonds which record type ..

Example
    I have 100 users with combination of  role and profile ...
am admin when  i login into one user  there is 10 objects   and each object have have 10 recordTypies  ,,and each Recor type have 1000+ records ..Now I would like to know which record he can edit ,create , or view ...so i need to capture that perticulor record Id..
  Could youum please please help out in task

How to achive this 

Thankful in advance
Regards
Naresh 
Not Able to edit Dynamic Dashboards as i has switched to Lightning UI
I am wanting to email selected attachment from the Notes and Attachment Section on an Opportunity. I have created a VF page and Apex Class, but I am having problems with the Wrapper Class. It does not email at all.

Apex Class
public class email_class{
    
    Public string ToAddresses {get;set;}
    Public string CCAddresses {get;set;}
    Public string opportunityId {get;set;}
    Public string subject {get;set;}
    public string email_body {get;set;}
    public string emailTo {get;set;}
    public string emailCC {get;set;}
    
    public class Attachmentwrapper
        {
            public Attachment acc{get; set;}
            public Boolean selected {get; set;}
            public Attachmentwrapper(Attachment a)
            {
                acc = a;
            }
        }
    
               
    public email_class(ApexPages.StandardController controller) {
        opportunityId = ApexPages.currentPage().getParameters().get('id');
    }
    
     List<Attachmentwrapper> AttachmentList = new List<Attachmentwrapper>();
     List<Attachment> selectedAttachments = new List<Attachment>();
       
        public List<Attachmentwrapper> getAttachments()
        {
        for (Attachment a : [select Name, Body, BodyLength from Attachment where ParentId = :opportunityId])
        {      
            AttachmentList.add(new Attachmentwrapper(a));
             }
            return AttachmentList;
        }
    
    Public PageReference send(){
       
    
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); // set the to address
        mail.setToAddresses(new String[] {emailTo});
        string [] ccaddress;
            if(emailCC != null && emailCC.trim() != ''){
            ccaddress = emailCC.split(',',0);
            mail.setCcAddresses(ccaddress);
            }
        mail.setSubject(subject);
        mail.setBccSender(false);
        mail.setUseSignature(false);
        mail.setPlainTextBody(email_body);
        mail.setWhatId(opportunityId);// Set email file attachments 

        //selectedAttachments.clear();
        for(Attachmentwrapper accwrapper : AttachmentList){
        if(accwrapper.selected == true){
        List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
        for (Attachment a : [select Id, Name, Body, BodyLength from Attachment where ParentId = :opportunityID]){
        Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
        efa.setFileName(a.Name);
        efa.setBody(a.Body);
        fileAttachments.add(efa);
        }
        mail.setFileAttachments(fileAttachments);
       
         selectedAttachments.add(accwrapper.acc);
         Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
         return null;
         }
}       
       /* public List<Attachment> GetSelectedAttachments()
        {
            if(selectedAttachments.size()>0)
            return selectedAttachments;
            else
            return null;
        }  */  
             
        PageReference pageRef = new PageReference('/' + opportunityId);
        pageRef.setRedirect(true);
        return pageRef;
    }
}

VF page
<apex:page standardController="Opportunity" extensions="email_class">
    <apex:form >
           
        <apex:pageBlock title="Email Details">
        
            <apex:pageBlock title="Reciepient">
                <b>TO: </b><br/><apex:inputText value="{!emailTo}"/><p/>
                <b>CC: </b><br/><apex:inputText value="{!emailCC}"/><br/>
                <br/>
                <b>Subject: </b><br/><apex:inputText value="{!subject}" maxlength="200"/><br/>
                <br/>
                <b>Body: </b><br/><apex:inputTextArea value="{!email_body}" rows="10" cols="100"/>
            </apex:pageBlock>          
                    
        <apex:pageBlock title="Attachments">
        <apex:pageBlockTable value="{!opportunity.Attachments}" var="wrap">
            <apex:column headerValue="Select">
            <apex:inputCheckbox value="{!opportunity.IsChecked__c}"/>
            </apex:column>
       <apex:column value="{!wrap.createddate}"/>
       <apex:column value="{!wrap.name}"/>
       <apex:column value="{!wrap.description}"/>
       </apex:pageBlockTable><p/>
       </apex:pageblock>
                
       <apex:commandButton value="Send Email" action="{!send}"/>
       <apex:commandButton value="Canel" action="{!cancel}"/>
            
       </apex:pageBlock>
                           
    </apex:form>    
</apex:page>

 
trigger BusinessName on Account( after insert, after update) {
Id AccBid = staticUtil.getRecordTypeId('Account', 'Business');
Id AccCid = staticUtil.getRecordTypeId('Account', 'Corporate');
Id ConBid = staticUtil.getRecordTypeId('Contact', 'Business');
Id ConCid = staticUtil.getRecordTypeId('Contact', 'Corporate');
if (trigger.isAfter && (trigger.isInsert || trigger.isUpdate) && CheckRecursive.runOnce() ) {
list < contact > cont = new list < contact > ();
set < Id > AccId = new set < Id > ();
for (Account ac: trigger.new) {
if (ac.RecordTypeId == AccBid || ac.RecordTypeId == AccCid) {
AccId.add(ac.Id);
}
}
list < contact > updatecontact = new list < contact > ();
list < Account > acnt = [select id, name, business_privacy_flag__c, Corporate_company_name__C, business_name__c, RecordTypeId, (select id, name, lastname, Business_name1__c, contact_Type__c, RecordTypeId, Business_Privacy_Flag__c from contacts) from account where(id In: AccId) and(RecordTypeId = : AccBid or RecordTypeId = : AccCid)];

if (!acnt.isEmpty()) {
for (Account a: acnt) {
if (a.contacts != null) {
for (Contact co: a.contacts)

if (a.Business_Privacy_Flag__c == true && (a.RecordTypeId == AccBid || a.RecordTypeId == AccCid) ) {
co.Business_Name1__c = '';
updatecontact.add(co);

} else if (a.Business_Privacy_Flag__c == false && co.Business_Privacy_Flag__c==false && a.RecordTypeId == AccBid ) {
co.Business_Name1__c = a.Business_Name__c;
updatecontact.add(co);

} else if (a.Business_Privacy_Flag__c == false && co.Business_Privacy_Flag__c== false && a.RecordTypeId == AccCid) {
co.Business_Name1__c = a.Corporate_Company_Name__c;

updatecontact.add(co);


}

}

}
if (updatecontact != null && updatecontact.size() > 0) {
if (!StaticUtil.isContactCallUpdate) {
update updatecontact;
staticutil.isContactCallUpdate=true;
}
}
}

}

}

For this trigger i cant able to get more code coverage. Only 58 % showing.
Please provide solutions .,its high priority.
hai Guys,
i am writing the test class.In my test class i cover all the line except 2 lines.
Apex class calss
------------------------------------
public class Create_Controller {

    private Employee_Information__c emp;
    private ApexPages.standardcontroller cont;
    public Create_Controller(ApexPages.StandardController controller) 
    {
      cont = controller;
      this.emp = (Employee_Information__c)controller.getRecord();  
    }
    
    public pagereference save()
    {
    
          try
          {
             insert emp;
             return new pagereference('/apex/List_Vf_Page');
          
          }
          catch(Exception e)
          {
          
              ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,e.getmessage()));
              return null;
          
          }
    
    
        return null;
    
    }

Test class class
---------------------------------------------
@isTest(seealldata=true)
public class Create_Controller_Test
{
     public static testmethod void testinsert()
     {
     
        Employee_Information__c ei = new Employee_Information__c();
        ei.First_Name__c = 'Naveen';
        ei.Middle_Name__c = 'Ashok';
        ei.Last_Name__c = 'Sirivella';
        ei.Date_of_Birth__c = Date.Today();
        ei.Father_Husband_Name__c = 'Lakshmi Pathi';
        ei.Marital_Status__c = 'Single';
        
        insert ei;
        
        Test.startTest();
        
         pagereference pg = page.Create_vf_page;
         test.setcurrentpage(pg);
         
         Apexpages.StandardController sc = new Apexpages.StandardController(ei);
         
          Create_Controller cc = new  Create_Controller(sc);
         
         cc.save();
        
        
        Test.stopTest();
     
     
     
     }
 


}

but following lines are not cover
User-added image

the above lines are not covered 
please help me
 
please suggest me if any one knows how can i achieve this requirement.

I want to check name case insensitive.
find below my code.
Public void UpdateStageNameSample(List<Opportunity> oppList){       
        List<Opportunity> optyList = new List<Opportunity>();
        String s = 'valued client';       
        for(Opportunity opp: oppList){
            if(opp.Name.contains(s.toUpperCase())){                
                opp.StageName = 'Sample';                           
            }
        }       
    }
  • November 25, 2015
  • Like
  • 0

I wish to show the status and comments of an approval process in a VF Page.

How should I proceed with it?

Hi Guys,
facing a wierd issue I just completed a deployment to a sandbox and completed the run all tests it validated sucesfully and deployment went fine as well post which I went to the UI and did a run all tests to check the coverage and Suprise Suprise one of the test classes is failing (too many SOQL) my question is how is it that this class did not fail when I did my validation and deployment but it started failing post deployment any help here is appreciated
Hi,

I am using an apex trigger to create events that are based on the campaign start date. So when the campaign start date changes, i want to update the events and only when the start date changes. 

What is the best way to check if the start date field value changed? I am having difficulty finding a good way to compare the date fields prior and current values. 
  • November 24, 2015
  • Like
  • 0
Hi, I'm new to VF , I tried to align commandbutton to the left side of the pageblock by using  dir property even though it is not working .
Can any one suggest me how to resolve this issue

FYI:
<apex:page id="pg">
 <apex:form id="fm">
        <apex:pageBlock title="Contact Details" dir="LTR">
            <apex:pageBlockButtons location="top" dir ="LTR" >
                 <apex:commandButton/>
</apex:pageBlockButtons >
</apex:pageblock>
</apex:form>
</apex:page>
Hi everyone,

Does anyone know the different badges that can be achieved by contributing to this forum (newbie, smartie, etc) and how many points match each level?

Regards,
Fred