• Sonali Bhardwaj
  • SMARTIE
  • 509 Points
  • Member since 2011

  • Chatter
    Feed
  • 19
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 85
    Replies

Hi,

 

I am trying to write the  Trigger code when the status of the case is changed and any other changes in fields with conditional loops for changing the Mail subject.

 

The issue was on trigger that send the same mail subject when i changed the status or changed the iother fields in the case.

 

The following is my code,

trigger caseUpdationMailNotification on Case ( after update) {
    contact relatedCaseContact;
    CaseComment Cscmnt;
    for(case Cases :trigger.new){
    relatedCaseContact = [SELECT Email FROM Contact WHERE Id = :Cases.ContactId];
      Messaging.reserveSingleEmailCapacity(1);
               //Fetch the related case contact.
       Messaging.SingleEmailMessage CaseNotificationmail = new Messaging.SingleEmailMessage();  
       CaseNotificationmail.setToAddresses(new List<String> { relatedCaseContact.Email });
       CaseNotificationmail.setReplyTo('ambigaraman@gmail.com');
       CaseNotificationmail.setSenderDisplayName('Salesforce Support');            
      
	  If(Cases.Status =='Working'){      
       CaseNotificationmail.setSubject(' Case Status updation : ' +'Changed to working. '+'Case Number:' + Cases.CaseNumber);
       CaseNotificationmail.setPlainTextBody('Your case Status: ' + Cases.CaseNumber +'To view your case <a href=https://na1.salesforce.com/'+Cases.Id);}
       
  If(Cases.Status =='Escalated'){          
   
    CaseNotificationmail.setSubject(' Case Status updation : ' +'Changed to Escalated. '+ 'Case Number:' +Cases.CaseNumber);
    CaseNotificationmail.setPlainTextBody('Your case Status: ' + Cases.CaseNumber +' has been updated.'+'To view your case <a href=https://na1.salesforce.com/'+Cases.Id);
    }   
    
 If(Cases.Status =='closed'){           
    
    CaseNotificationmail.setSubject(' Case Status updation : ' +'Changed to closed. '+ 'Case Number:' +Cases.CaseNumber);
    CaseNotificationmail.setPlainTextBody('Your case Status:' + Cases.CaseNumber +' has been updated.'+'To view your case <a href=https://na1.salesforce.com/'+Cases.Id);
    }     
else{  
    CaseNotificationmail.setSubject(' Case  updation : ' + 'Case Number:'+ Cases.CaseNumber);
    CaseNotificationmail.setPlainTextBody('Your case : ' + ' has been updated.'+'To view your case <a href=https://na1.salesforce.com/'+Cases.Id);
    } 
	
	
    Messaging.sendEmail(new Messaging.SingleEmailMessage[] { CaseNotificationmail });
 }
}

 If i use 'elseif', It again send the email with subject for status changed,

 

Can anyone help me to write the trigger that send the mail that send when we change the status only. or there is only changes in other fields(not in status) of the case?

 

Thanks & Regards.,

Ambiga

 

Hi,

 

We usually use map in triggers and classes. Can someone help me to understand in which object we should use map?

 

Suppose: I have 2 objects:

 object1

object2

Based upon crtain condition of objecct1, the certain field of object2 changes.

So,  in which object should we use map?

 

Please help.

Hi guys,

I need help to update a custom field. I have two custom objects A and B with mater details relationship and both have education progress field. Every time When a new record is added to object B , i want to insert objects B’s (education progress fields) value into Object A’s education progress field and it will concatenate values with comma. Object A have one-to-many relationship with Object B.


Please suggest best way to achieve this.

Thanks in advance.

Regards,

In the past few weeks I have put together a number of visualforce chart based pages with dynamic controls and everything, all with no problem. Suddenly one won't render the actual chart. After hours of trying to debug the controller, I slowly paired everything back until I am now pretty sure the problem in in my visualforce code.

 

But I can't see the mistake.

 

Anyone able to keep me out of the big white house with padded walls?

 

Visualforce 
===============================
<apex:page controller="TEST_TableLine_ActivitySummary" >
    <apex:form > 
    <apex:pageBlock title="Test">
    <!-- The Chart -->
    <apex:pageBlockSection >
    Begin
    <apex:chart height="800"  width="1200"  data="{!teDat}" id="actCh">
        <apex:legend position="right"/>
        <apex:axis type="Numeric" position="left" fields="rowAnum, rowBnum" title="Meetings Calls"/>
        <apex:axis type="Category" position="bottom" fields="pLab" title="Date" >
            <apex:chartLabel rotate="315"/>
        </apex:axis>
        <apex:lineSeries title="Jo" axis="left" xField="pLab" yField="rowAnum" strokeColor="#190710" strokeWidth="2" markerFill="#190710" markerType="cross" markerSize="4"/>
        <apex:lineSeries title="not Jo" axis="left" xField="pLab" yField="rowBnum" strokeColor="#BBAACC" strokeWidth="2" markerFill="#BBAACC" markerType="cross" markerSize="4" />
    </apex:chart>
    End
    <apex:dataTable value="{!teDat}" var="a" >
        <apex:column headerValue="Period" value="{!a.pLab}"/>
        <apex:column headerValue="NumA" value="{!a.rowAnum}"/>
        <apex:column headerValue="NumB" value="{!a.rowBnum}"/>
    </apex:dataTable>
    </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>  
</apex:page>

Even here, the "Begin", "End" and the dataTable are things I added back in just to see if the render (they do). If I remove them, all I get is the page title. The table also shows the data is correct.

 

In case it helps, although I am pretty certain the error is not here, this is my test controller:

 

Controller 
===============================
public with sharing class TEST_TableLine_ActivitySummary {

    public List<ActivityGraph> teDat;
    
    //Constructor
    public TEST_TableLine_ActivitySummary() {
     
    }
    
    // -- The Activity Graph
    public List<ActivityGraph> getteDat() {
        
       List<ActivityGraph> activityFinalGraph = new List<ActivityGraph>();
        
        activityFinalGraph.add(new ActivityGraph('Day 1'));
        activityFinalGraph[0].addUserMeetings(0,5);
        activityFinalGraph[0].addUserMeetings(1,9);
        activityFinalGraph.add(new ActivityGraph('Day 2'));
        activityFinalGraph[1].addUserMeetings(0,8);
        activityFinalGraph[1].addUserMeetings(1,3);
        

System.debug('aFG: '+activityFinalGraph);
        return activityFinalGraph;
    }

    
    public class ActivityGraph
    {
        //STRUCT   -- Going to assume no team will ever have more than 13 people
        public String pLab { get; set; }
        public Integer rowAnum { get; set; } 
        public Integer rowBnum { get; set; } 

        //Constructors
        public ActivityGraph(String pl) 
        {
                   pLab = pl;
                rowAnum = 0;
                rowBnum = 0;
        }
        
        //Utility Methods
        public void addUserMeetings(Integer row, Integer nMtg) 
        {
            if(row == 0)  rowAnum = nMtg;
            if(row == 1)  rowBnum = nMtg;
        }
    }
}

Again the System.debug call shows that the data being returned is correct.

 

What is wrong with my chart? I am assuming it is staring me in the face but it is alluding me.

 

Regards

MellowRen

Hi

 

I have what I thought would be a simple thing but can’t work out how, or if, Visualforce charts can do it.

 

I have a set of data derived in Apex code which has:

 

  1. User Name
  2. Category
  3. Number (in category)

… and would like to graph it as such (using X, Y, Z to represent colour bars):

 

  5                             Legend
N 4   XY         Z              User X
u 3   XY         Z      Y       User Y
m 2   XYZ       YZ     XY       User Z
  1   XYZ      XYZ     XYZ
      Good     Bad     Ugly
           Category

The problem I have is that both the number of users and number of categories is not fixed (they are determined in the controller's Apex code). I can ensure every User has a value for every category (even if it is 0) so that is not a problem. In the sparse examples in the docs, I can only see how to do it when the number of categories is indetermined. They show data structures as such:

 

graph data {

    user_x

    user_y

    user_z

    category_label

    number

}

 

But since I don't know how many users I'll have (nor their names) until the code has run, I am not sure how to put the data nor the visualforce code together. I tried experimenting with things like:

 

<apex:chart height="300" width="700" data="{!activityGraph}" id="actChart">
    <apex:legend position="right"/>
    <apex:axis type="Numeric" position="left" fields="numberM" title="# Ms"/>
    <apex:axis type="Category" position="bottom" fields="catLabel" />
    <apex:barSeries title="{!activityGraph[0].userName}" axis="left" xField="catLabel" yField="{!activityGraph[0].numberM}" orientation="vertical"/>
</apex:chart>

…with the hope of embedding the barSeries into a <apex:repeat> loop. But that doesn't work.

 

I am really hoping that I am missing something simple here. Anyone got any ideas?

 

Regards

MellowRen

<apex:page standardController="Application__c" extensions="app">
    <h1>Application Form</h1>
   
    <apex:form >
        <apex:pageMessages id="error"/>
        <apex:pageBlock >
        <apex:pageBlockSection title="Information">
       
        <apex:inputText value="{!Application__c.Name}"/>
        <apex:inputText value="{!Application__c.Candidate_Name__c}"/>
        <apex:inputText value="{!Application__c.Age__c}"/>
        <apex:inputText value="{!Application__c.Address__c}"/>
        <apex:inputText value="{!Application__c.Contact_Number__c}"/>
        </apex:pageBlockSection>
         <apex:commandButton value="Review" />


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

    </apex:page>

Hi to all,

 

I have made some code changes in 2 apex classes, when i deploying these two apex classes, it throughs an error like this

: Average Test Coverage across all Apex classes and Triggers is 69%, atleast 75% test coverage is required.

 

when i run those 2 test classes, its test coverage is 84% and 86%.

 

I have deployd with change sets and also i try with Eclipse, getting the same error.

 

Please help me on this error, colud you please suggest any ideas or suggestons it will be greatly apriciated.

 

 

Thanking You in Advance. 

Hi,

 

Can I know how to refresh the entire Visual force or Part of the page when a component is modified(i.e. when a command link action is performed by the component).

 

Thanks & Regards

Hii evryone i already asked this  question but i didnt got any answer from anybody...again i have serious issue with this topic.....if anyone understands please  tell me your solution.....i will  breifly  clearly explain my task understand step by step...

 

 

 

1)When we click Home  and scroll down we  have  "My Task" when we click new and we create  Task.  when we click new we ll see  fields , in that we   have   'Subject' , and  'Comments'  fields also. let it put aside.

 

2) click contacts , when we open any  existed contact  record  in below we will found  "Activity History"block in that we have  "send an email button"...

 

so  now  when i  click "send an email" button  the email page will opened with appropriate contact....and  we will fill details like  cc,BCC, Subject,Body  in the  email page. and we click  'send'  button to send email.

 

Now  the Requirement  is  when i click the  send button , a  new Task should need to create automatically (In first step it is manually)  and  Task  subject  is  populated by  email subject and  Task  comments  is  populated by  email Body.

 

How  should write  trigger for this...

 

i  found that  there are  no  email  fields are existed like  emails (subject , body ,cc , BCC  because it is standard and designed by salesforce.) so how should i know the fields apis name. but we have Task fields  like  subject,comments in Customize ---> Activities--> Task feilds.

 

can we  write trigger  between 2  objects. (because contacts email data need to save on Task.they are two diff objs)...

How could i write a test class for a controller with out  its constructor class??

 

example 1)public class convertToCLA {
List<Contact> contacts;
List<Lead> leads;
List<Account> accounts;

public void convertType(Integer phoneNumber) {
List<List<sObject>> results = [FIND '4155557000'
IN Phone FIELDS
RETURNING Contact(Id, Phone, FirstName, LastName),
Lead(Id, Phone, FirstName, LastName), Account(Id, Phone, Name)];
sObject[] records = ((List<sObject>)results[0]);

if (!records.isEmpty()) {
for (Integer i = 0; i < records.size(); i++) {
sObject record = records[i];
if (record.getSObjectType() == Contact.sObjectType) {
contacts.add((Contact) record);
} else if (record.getSObjectType() == Lead.sObjectType){
leads.add((Lead) record);
} else if (record.getSObjectType() == Account.sObjectType) {
accounts.add((Account) record);
}
}
}
}
}

 

 

2)public with sharing class CustomPaginationExt {
public List<Account> accounts{get;set;}
public Integer pageSize{get;set;}
public Integer noOfPages{get;set;}
public Integer pageNumber{get;set;}
private String baseQuery = 'select name, industry, annualRevenue from Account order by name';
private Integer totalNoOfRecs;

public CustomPaginationExt(ApexPages.StandardController controller) {
pageSize = 2;
totalNoOfRecs = [select count() from Account limit 50000];
getInitialAccountSet();
}

public PageReference getInitialAccountSet()
{
pageNumber = 0;
noOfPages = totalNoOfRecs/pageSize;

if (Math.mod(totalNoOfRecs, pageSize) > 0)
noOfPages++;

try{
accounts = Database.query(baseQuery + ' limit '+pageSize);
}
catch(Exception e){
ApexPages.addMessages(e);
}
return null;
}

public PageReference next(){
pageNumber++;

queryAccounts();
return null;
}
public PageReference previous(){
pageNumber--;
if (pageNumber < 0)
return null;

queryAccounts();
return null;
}

private void queryAccounts()
{
Integer offset = pageNumber * pageSize;
String query = baseQuery + ' limit '+pageSize +' offset '+ offset;
System.debug('Query is'+query);
try{
accounts = Database.query(query);
}
catch(Exception e){
ApexPages.addMessages(e);
}
}
}

hi i need help

Below is my code:

VF page:

<apex:page sidebar="false" showHeader="false" controller="communityCon1234" cache="true" contentType="text/csv#Error.csv" language="en-US">


<apex:repeat value="{!HeaderXLS}" var="a">

<apex:outputText value="{!a}">
</apex:outputText>

</apex:repeat>
<br/>
<apex:repeat value="{!fileLine}" var="b">
<apex:outputText value="{!b}"></apex:outputText>

</apex:repeat>
<br/>
</apex:page>

 

Controller:

 

 public List<String> getHeaderXLS()
    {
      List<String> listString1 = new List<String>();
     listString1.add('phnnumber');
      listString1.add('name');
   
      return  listString1;
    }
    public List<String> getFileLine()
    { List<String> listString = new List<String>();
     listString.add('123456');
      listString.add('urvashi');
      return listString;
      
    }

 MY problem here is i wana display the values of listString and listString1 in different columns in excel file.

like

phnnumber    name

123456           urvashi

 

The the size of listString is not fixed.It varies depending upon the code.

How do i do this?
Please help.

And how do i insert<br/> tag in btwn vf page so that it doesnot come in the excel file.

hello,

Can anyone help

I m new to Salesforce please help.

I have a picklist with some values of fruits in it.

Example:

Apple Grapes Banana etc.

I have sorted these values alphabetically.

But now i want a default value to be added in picklist like example: '--Select value--'

Can i pass this value directly to the constructor to make it default to picklist?

Or should I add it first to the select list.

 

Please help

Thanks.

 

Hi,i build a multiple selectlist i want to show some items to be selected when the page renders initially  how to accomplish that any guidance ??

Hi,

 

I am new to Salesforce. Please help me in implementing following

 

In my Apex code, i have name of selected object in a Variable
I need a piece of code which returns name of the fields which are external ids in that selected object.

 

 

Accounts is a custom object.i have to retrieve the  account type on the basis of Name.
I am able to retrieve the id and i'm  getting  account type in debug. But, it isnt displayed in the VF page.
Please have a look at the code..

 

Given below is the code of Class and VF page

<apex:page controller="SearchByName">
 <apex:form >
  <apex:outputLabel style="font-weight:bold;" value="Search By Name" ></apex:outputLabel>
        <apex:inputText value="{!textData}"/> 
<apex:commandButton action="{!search}" value="Search" id="search" rerender="out, msgs" status="status"/>
 </apex:form>
 <!------Doesnt print the first name and account type------->
  <apex:pageBlock >
  <apex:pageBlockTable value="{!Accounts}" var="c" >
  <apex:column >
                <apex:facet name="header">First Name</apex:facet>
                <apex:outputField value="{!c.First_Name__c}" />
  </apex:column>
  <apex:column >
                <apex:facet name="header">Account Type</apex:facet>
                <apex:outputField value="{!c.Account_Type__c}" />
  </apex:column>

     
  </apex:pageBlockTable>
  </apex:pageBlock>
  
     <!------------- Getting the value of var "c"------------>
   <apex:outputPanel id="out">
        <apex:actionstatus id="status" startText="searching...">
            <apex:facet name="stop">
                <apex:outputPanel >
                    
                    <apex:dataList value="{!Accounts}" var="c">a:{!c}</apex:dataList>
                    
                </apex:outputPanel>
            </apex:facet>
        </apex:actionstatus>
    </apex:outputPanel>
 </apex:page>

 

public class SearchByName
{
 List<Account__c> Accounts;
private String textdata = null;

    public String getTextData() { return textdata; }
    
    public void setTextData(String data) { textdata = data; }
    
        
        
        public void search(){            
           
            Accounts = Database.query('SELECT First_Name__c,Account_Type__c  FROM Account__c where First_Name__c = :textdata');
            system.debug('Accounts>>>>'+Accounts);
       }    
        public List<Account__c> getAccounts() {
                
                return Accounts;
        }
        
       
}

 

I'm tring to optimize the code below.

I'm looking for a structure where i can put the picklist's values and after (with just a condition) i want check the condition for all the values in the structure.

if ((lead.Status.trim()=='Archived' || lead.Status.trim()=='False'||lead.Status.trim()=='Lead - Never'))

 

should be like this:

structure=['Archived','False','Lead - Never']; 
if ((lead.Status.trim()==structure))

 

I can not find anything, do you know how i can do this?

Thanks in advantage for any advice.

Br

HI All,

 

I m trying to dispaly a multipicklist as checkboxes in vf page but not succeeding.

 

How can I display the picklists in below showed style.

 

Name of the field : testpick__c

values : a, b, c, d, e

Object name: test__c

 

Expected Output:

                                A                     B                        C                       D                      E

 

Testpick                   X                      X                        X                      X                        X 

 

 

Thanks in advance..........