• Offshore Freelance Consultant
  • NEWBIE
  • 115 Points
  • Member since 2014

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 30
    Replies
hi! how can i group records shown in custom chart?
i created a custom chart in visalforce page.
it looks like this:
User-added image
this is from the list of records in Expense__c object
User-added image
i need the pie chart to show the largest part for Buses=P1000
how can i group these records?

here is my code:
VF:
<apex:page controller="ChartsCC" title="Pie Chart">
        <apex:chart height="350" width="450" data="{!pieData}">
            <apex:pieSeries dataField="data" labelField="name"/>
            <apex:legend position="bottom"/>
        </apex:chart>
</apex:page>

APEX CLASS:
public with sharing class ChartsCC {
    public List<PieChartData> getPieData() {
             List<PieChartData> data = new List<PieChartData>();
             for (Expense__c exp : [SELECT Type_of_Expense__c FROM Expense__c]) {
                      data.add(new PieChartData(exp.Type_of_Expense__c, 20));
             }       
             return data;
    }
    public class PieChartData {
        public String name { get; set; }
        public Decimal data { get; set; }
        public PieChartData(String name, Decimal data) {
                 this.name = name;
                 this.data = data;
        }
    }
}
  • February 19, 2014
  • Like
  • 0
I wanted to pick the attachment record from contact and send the attachment in an email. this is the requirement im getting null pointer exception. I checked in debuglogs seems everything is fine. The email should fire on the condition  ID_card_Status__c=='Designer'. Below is my trigger kindly help me asap.
trigger autonumberid on Contact (before insert, before update) {
public string var1='';
public id[] attachmentid=new id[]{};


list<RecordType>ALLRT1=[SELECT DeveloperName,Id,SobjectType FROM RecordType
                       where SobjectType ='Contact' AND DeveloperName='Primary_Member'];
                      
list<RecordType>ALLRT2=[SELECT DeveloperName,Id,SobjectType FROM RecordType
                       where SobjectType ='Contact' AND DeveloperName='Student_Member'];
                      
list<RecordType>ALLRT3=[SELECT DeveloperName,Id,SobjectType FROM RecordType
                       where SobjectType ='Contact' AND DeveloperName='Business_Member'];

list<RecordType>ALLRT4=[SELECT DeveloperName,Id,SobjectType FROM RecordType
                       where SobjectType ='Contact' AND DeveloperName='Pillar_Member'];

list<RecordType>ALLRT5=[SELECT DeveloperName,Id,SobjectType FROM RecordType
                       where SobjectType ='Contact' AND DeveloperName='Life_Member'];
                      
list<RecordType>ALLRT6=[SELECT DeveloperName,Id,SobjectType FROM RecordType
                       where SobjectType ='Contact' AND DeveloperName='Patron_Member'];

list<contact>priList=[select id,Contact_Id__c,Contact_Record_Id__c,RecordTypeId  from contact
                     where Contact_Record_Id__c!=null];
                    
Decimal d1=priList.size();
for(contact c1:trigger.new){
string recordtypeid=c1.recordtypeid;
    if(recordtypeid.contains(ALLRT1[0].id)){
        c1.Contact_Record_Id__c='TN/CHE/PRI-000'+d1++;
    }
    if(recordtypeid.contains(ALLRT2[0].id)){
        c1.Contact_Record_Id__c='TN/CHE/STU-000'+d1++;
    }
    if(recordtypeid.contains(ALLRT3[0].id)){
        c1.Contact_Record_Id__c='TN/CHE/BUS-ME-000'+d1++;
    }
    if(recordtypeid.contains(ALLRT4[0].id)){
        c1.Contact_Record_Id__c='TN/CHE/PIL-000'+d1++;
    }
    if(recordtypeid.contains(ALLRT5[0].id)){
        c1.Contact_Record_Id__c='TN/CHE/LIF-000'+d1++;
    }
    if(recordtypeid.contains(ALLRT6[0].id)){
        c1.Contact_Record_Id__c='TN/CHE/PAT-000'+d1++;
    }
    if(trigger.isupdate){
    if(c1.ID_card_Status__c=='Designer'){
    if(trigger.isupdate){
     Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
      Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
  
     attachment file=[select id,parentid,body from attachment where parentid=:c1.id AND Name LIKE '%photo%' Limit 1];
     Blob b =file.body ;
      efa.setBody(b);
     String[] emailAddrnew1 = new String[] {'nchristopher@gtr.net'};
    
            attachmentid.add(file.id);
            system.debug('***************'+file.id);
            system.debug('bbbbbbbbbbb'+b);
    
     mail.setToAddresses(emailAddrnew1);
     system.debug('emailAddrnew1'+emailAddrnew1);
      system.debug('eeeeeeeeeeeeeeeeeeeeeeeeeeee'+efa);
     mail.setSubject('New card print request'); 
     mail.setPlainTextBody('print this new id card'); 
     mail.setHtmlBody('This is to notify that the Owner of lead: https://ap1.salesforce.com/ <b>'); 
     mail.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
     Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); 
   
}}}
}
}

HI 

I want to show dependent picklist on vf page and the value of controlling field I am setting on constructor of controller.
So my controlling picklist should be hidden and dependent picklist should be shown on vf page.
I have two picklist on object srobject__c
controller  organisation  picklist = abc,xyz
dependent picklist  : department  -- abc ={123,234.456}
xyz = 678,789,901



My code is :
public class sample{
public srobject__c newser {get;set}
public sample(){
}
newsr = new srobject__c();
            newsr.organization__c = 'abc';    //value of controlling picklist

}

===============page================
<apex:page  controller="sample">

<apex:inputField value="{!srvar.department__c}" />
</apex:page>
=================

please suggest me the code , your help would be appriciated.
Regards,
Sameer Tyagi

Hi,

I have years of experience in Administration and Visual Force/Apex development of complex salesforce.com orgs.

I am available for remote consulting, please write to UsefulDeveloper@gmail.com.

Regards
Hi,

I am trying to overide the standard save button on opportunity object with a popup message when the following condition is met 

opportunity stage ="closed lost" 

please let me know hw to proceed on this 

help me with the code

Thanks
Is it possiblie to retrieve the image dynamically from a record? For example, in a regular visualforce page we can use apex:image and you can set the value based on the image file that was uploaded.

Currently, in my object i have a field where it holds the URL for the uploaded image. I'm able to use apex:image in a regular Visualforce page, but I cant seem to figure out a way to dynamically display the image based on the URL from the record.

Is this even possible?
Hi,
I have one requirement. We have to move to salesforce one from salesforce classic. So what objects will the partner be able to access.
I tried searching but couldn't find. My partners should be ablet o access lead and opportunity using salesforce one. Is it possible ?
I have a public site setup, but I've started getting random reports of users seeing the authorization required page.  I have all inserts/updates wrapped in try catch statements, but I haven't been able to replicate the problem to see the error in a debug log.

Is there a better way to catch random errors like this?  Maybe if the user hits the authorization required page, email everything to me or something?

I'm a beginner with APEX so forgive my ignorance.
  • March 05, 2014
  • Like
  • 0
user has create edit and delete option to the object owd is public read and write but user cant able to delete record in the object which created by other user with same role but diffrent profiles can any body suggest
hi! how can i group records shown in custom chart?
i created a custom chart in visalforce page.
it looks like this:
User-added image
this is from the list of records in Expense__c object
User-added image
i need the pie chart to show the largest part for Buses=P1000
how can i group these records?

here is my code:
VF:
<apex:page controller="ChartsCC" title="Pie Chart">
        <apex:chart height="350" width="450" data="{!pieData}">
            <apex:pieSeries dataField="data" labelField="name"/>
            <apex:legend position="bottom"/>
        </apex:chart>
</apex:page>

APEX CLASS:
public with sharing class ChartsCC {
    public List<PieChartData> getPieData() {
             List<PieChartData> data = new List<PieChartData>();
             for (Expense__c exp : [SELECT Type_of_Expense__c FROM Expense__c]) {
                      data.add(new PieChartData(exp.Type_of_Expense__c, 20));
             }       
             return data;
    }
    public class PieChartData {
        public String name { get; set; }
        public Decimal data { get; set; }
        public PieChartData(String name, Decimal data) {
                 this.name = name;
                 this.data = data;
        }
    }
}
  • February 19, 2014
  • Like
  • 0
For the life of me I can't seem to get this working. I've written a custom extension class and a basic visualforce page to display a chart. As a normal controller with a hardcoded Account Id it works fine and the chart displays. When I try and convert it into a controller extension and add it to an account page I keep getting 'Content cannot be displayed: Attempt to de-reference a null object' errors.

Visualforce Page
<apex:page standardController="Account" extensions="BudgetController2"> 
  <apex:pageBlock title="Budget Test"> 
 
    <apex:chart height="400" width="500" data="{!ChartData}">
          <apex:legend position="right"/>
          <apex:axis type="Numeric" position="left" fields="data1,data2"
                 title="Value" grid="true"/>
          <apex:axis type="Category" position="bottom" fields="name"
                 title="Month"/>
          <apex:barSeries orientation="vertical" axis="left"
                 xField="name" yField="data1" title="Budget"/>
          <apex:lineSeries axis="left" xField="name" yField="data2"
                 markerType="circle" markerSize="4" markerFill="#8E35EF" title="Targett"/>
    </apex:chart>

  </apex:pageBlock> 
</apex:page>

Custom Controller Extension
public with sharing class BudgetController2 {

    private Account acct;

    public BudgetController2(ApexPages.StandardController controller) {

        acct = (Account)controller.getRecord();

    }

    public list<AggregateResult> lstBud = [SELECT SUM(Jan__c)Jan, SUM(Feb__c)Feb, SUM(Mar__c)Mar FROM Account WHERE Id = :acct.id];
    public list<AggregateResult> lstTar = [SELECT SUM(Jan_target__c)Jan, SUM(Feb_target__c)Feb, SUM(Mar_target__c)Mar FROM Account WHERE Id = :acct.id];
    public list<list<AggregateResult>> lstAll = new list<list<AggregateResult>>{lstBud, lstTar};
   
    public List<Data> getChartData() {
        List<Data> data = new List<Data>();
        data.add(new Data('Jan', (decimal)lstAll[0][0].get('Jan'), (decimal)lstAll[1][0].get('Jan')));
        data.add(new Data('Feb', (decimal)lstAll[0][0].get('Feb'), (decimal)lstAll[1][0].get('Feb')));
        data.add(new Data('Mar', (decimal)lstAll[0][0].get('Mar'), (decimal)lstAll[1][0].get('Mar')));
        system.debug(data);
        return data;
    }   

    public class Data {
        public String name { get; set; }
        public Decimal data1 { get; set; }
        public Decimal data2 { get; set; }
        public Data(String name, Decimal data1, Decimal data2) {
            this.name = name;
            this.data1 = data1;
            this.data2 = data2;

        }
    }
   

}


The debug logs show that the code stops as soo as it trys to run the constructor. I've tried pretty much every code combination I can find online, although i'm pretty sure it will be a glaringly obvious error!

Any help appreciated.


I wanted to pick the attachment record from contact and send the attachment in an email. this is the requirement im getting null pointer exception. I checked in debuglogs seems everything is fine. The email should fire on the condition  ID_card_Status__c=='Designer'. Below is my trigger kindly help me asap.
trigger autonumberid on Contact (before insert, before update) {
public string var1='';
public id[] attachmentid=new id[]{};


list<RecordType>ALLRT1=[SELECT DeveloperName,Id,SobjectType FROM RecordType
                       where SobjectType ='Contact' AND DeveloperName='Primary_Member'];
                      
list<RecordType>ALLRT2=[SELECT DeveloperName,Id,SobjectType FROM RecordType
                       where SobjectType ='Contact' AND DeveloperName='Student_Member'];
                      
list<RecordType>ALLRT3=[SELECT DeveloperName,Id,SobjectType FROM RecordType
                       where SobjectType ='Contact' AND DeveloperName='Business_Member'];

list<RecordType>ALLRT4=[SELECT DeveloperName,Id,SobjectType FROM RecordType
                       where SobjectType ='Contact' AND DeveloperName='Pillar_Member'];

list<RecordType>ALLRT5=[SELECT DeveloperName,Id,SobjectType FROM RecordType
                       where SobjectType ='Contact' AND DeveloperName='Life_Member'];
                      
list<RecordType>ALLRT6=[SELECT DeveloperName,Id,SobjectType FROM RecordType
                       where SobjectType ='Contact' AND DeveloperName='Patron_Member'];

list<contact>priList=[select id,Contact_Id__c,Contact_Record_Id__c,RecordTypeId  from contact
                     where Contact_Record_Id__c!=null];
                    
Decimal d1=priList.size();
for(contact c1:trigger.new){
string recordtypeid=c1.recordtypeid;
    if(recordtypeid.contains(ALLRT1[0].id)){
        c1.Contact_Record_Id__c='TN/CHE/PRI-000'+d1++;
    }
    if(recordtypeid.contains(ALLRT2[0].id)){
        c1.Contact_Record_Id__c='TN/CHE/STU-000'+d1++;
    }
    if(recordtypeid.contains(ALLRT3[0].id)){
        c1.Contact_Record_Id__c='TN/CHE/BUS-ME-000'+d1++;
    }
    if(recordtypeid.contains(ALLRT4[0].id)){
        c1.Contact_Record_Id__c='TN/CHE/PIL-000'+d1++;
    }
    if(recordtypeid.contains(ALLRT5[0].id)){
        c1.Contact_Record_Id__c='TN/CHE/LIF-000'+d1++;
    }
    if(recordtypeid.contains(ALLRT6[0].id)){
        c1.Contact_Record_Id__c='TN/CHE/PAT-000'+d1++;
    }
    if(trigger.isupdate){
    if(c1.ID_card_Status__c=='Designer'){
    if(trigger.isupdate){
     Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
      Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
  
     attachment file=[select id,parentid,body from attachment where parentid=:c1.id AND Name LIKE '%photo%' Limit 1];
     Blob b =file.body ;
      efa.setBody(b);
     String[] emailAddrnew1 = new String[] {'nchristopher@gtr.net'};
    
            attachmentid.add(file.id);
            system.debug('***************'+file.id);
            system.debug('bbbbbbbbbbb'+b);
    
     mail.setToAddresses(emailAddrnew1);
     system.debug('emailAddrnew1'+emailAddrnew1);
      system.debug('eeeeeeeeeeeeeeeeeeeeeeeeeeee'+efa);
     mail.setSubject('New card print request'); 
     mail.setPlainTextBody('print this new id card'); 
     mail.setHtmlBody('This is to notify that the Owner of lead: https://ap1.salesforce.com/ <b>'); 
     mail.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
     Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); 
   
}}}
}
}
I am setting the following variable to be reused in calculations
Below returns the error Error: Unknown property 'Cloud_Voice__cStandardController.monthly'
<apex:variable value="{!12}" var="term"/>
<apex:variable value="{!ROUND((Cloud_Voice__c.Total_Selected_Finance__c*(r.X12m__c/1000)/term),2)}" var="monthly"/>
<apex:variable value="{!monthly*term}" var="total"/>

Changing the term back to 12 works fine:
<apex:variable value="{!12}" var="term"/>
<apex:variable value="{!ROUND((Cloud_Voice__c.Total_Selected_Finance__c*(r.X12m__c/1000)/12),2)}" var="monthly"/>
<apex:variable value="{!monthly*term}" var="total"/>

Can't figure out why it does not work, any help?
  • February 19, 2014
  • Like
  • 0
Hi Folks,

Earlier we are utelising S-Controls in Salesforce.
What is the fullform for S-Controls. What does " S " Indicates.
I had mexico and south america leads in one queue.those leads should be routed to USA queue depends upon product id(ex product id:23).

appreciate your help advance
Hi Folks,

i implemented one VF Page for showing Data in XML format.Its showing very perfetly but when i click on Save button on this page,i need to save this Data in Attachments as an XML file.Any ideas....

VF Page:

<apex:page showHeader="false" controller="CLS_xmlGeneration" tabStyle="Reward__c" >
                <apex:outputText value="{!xmldata}" style="width:1000px;"/>
</apex:page>

Class :
public class CLS_xmlGeneration {

    public String xmldata { get; set; }
 
    public ID recid{get;set;}
 
    public Reward__c rew{get;set;}
 

 
    Public CLS_xmlGeneration(){
        recid=ApexPages.CurrentPage().getParameters().get('Id');

        rew =new Reward__c();
        rew = [select id,name,Rward_Amount__c,Time_Based_Mgmnt__c,User__c from Reward__c where id=:recid];

        Dom.Document doc = new Dom.Document();
        XmlStreamWriter w = new XmlStreamWriter();
        w.writeStartDocument(null, '1.0');
       // w.writeStartElement(null, 'quotas', null);
    
              w.writeStartElement(null, 'Reward', null);
        
              w.writeStartElement(null, 'Id', null);
              w.writeCharacters(rew.id);
              w.writeEndElement();
    
              w.writeStartElement(null, 'Name', null);
              w.writeCharacters(rew.name);
              w.writeEndElement();

              w.writeStartElement(null, 'UserId', null);
              w.writeCharacters(rew.User__c);
              w.writeEndElement();

              w.writeStartElement(null, 'TimeId', null);
              w.writeCharacters(rew.Time_Based_Mgmnt__c);
              w.writeEndElement();
    
              w.writeStartElement(null, 'RewardAmount', null);
              w.writeCharacters(string.valueof(rew.Rward_Amount__c));
              w.writeEndElement();
    
              w.writeEndElement();
    
       //  w.writeEndElement();
        w.writeEndDocument();
       xmldata  = w.getXmlString();
          w.close();
       // doc.LoadXml(xmlOutput);
       // system.debug('XML is '+doc.toXmlString());
       // xmldata = doc.toXmlString();

    }
    public pagereference insrtattacmnt(){
         PageReference csvPage = Page.VF_XMLinsert_intoAttachment;
         csvPage.getParameters().put('Id', recid);
         Blob csvBlob = csvPage.getContent();
      
       //    dom.Document doc = new dom.Document();
       //    doc.load(csvPage.getContent().toString());
     
         Attachment attachment = new Attachment();
            attachment.Body = csvBlob ;
            attachment.Name = 'Rewardfile.xml';
            attachment.ParentId = rew.Id;
          insert attachment;

       
      return null;
    }
}
Hi all,

I have the following visualforce code (simplified a little for clarity):

<apex:page standardController="NCQ__c">
  <apex:tabPanel id="tabPanel" switchType="client" selectedTab="BusinessAssessmentTab">
    <apex:tab id="BusinessAssessmentTab" label="Business Assessment" name="BusinessAssessmentTab">
      <apex:form>
        <apex:pageBlock>
          <apex:pageBlockSection title="Business Type">
            <apex:inputField value="{!NCQ__c.Business_Type__c}">
              <apex:actionSupport event="onchange" rerender="McQuestions" immediate="true"/>
            </apex:inputField>
          </apex:pageBlockSection>
          <apex:pageBlockSection id="BusinessAssessmentBlock" title="Business Assessment">
            <apex:outputPanel id="GeneralQuestions">
              <apex:outputField value="{!NCQ__c.BA_1_Question__c}" rendered="true"/>
              <apex:inputField value="{!NCQ__c.BA_1_Answer__c}" style="width: 100%"/>
              <p/>
            </apex:outputPanel>
            <apex:outputPanel id="McQuestions">
              <apex:outputField value="{!NCQ__c.BA_MC_1_Question__c}" rendered="true"/>
              <apex:inputField value="{!NCQ__c.BA_MC_1_Answer__c}" style="width: 100%"/>
              <p/>
            </apex:outputPanel>
          </apex:pageBlock>
        </apex:form>
      </apex:tab>
    </apex:tabPanel>
  </apex:page>

I'd like to eventually hide or show the McQuestions panel based on the value of NCQ__c.Business_Type__c. Has a first step, I just had the McQuestions panel rerender on any change to Business_Type__c. For some reason, rerendering the panel causes the outputFields values to disappear from McQuestions. I have no clue what is going on! I'm hoping someone has some ideas? I've attached two images (before and after) to illustrate what is going on.

Please let me know if you need any further details!

-Chris 

User-added image
User-added image
I have created a assignment rule which assign lead to queue when lead status is 'open - not contacted' and when I create lead from saleforce then there is an optional checkbox (Assign using active assignment rule), when we select then it assign a lead to queue otherwise it does not and it is working fine in my case...but the problem is, whenever I create lead from sites (public sites) then it is not assigning to queue and the owner name of the lead is same as sites user.

so i would like to know how cna i assign lead to queue from sites ???

Hi,

 

We are putting our mostly static public website on vfpages (force.com) as a hosting solution.  We are doing this as it will fit nicely into our integration roadmap with our website and SFDC orders down the road.

 

One page of our website will be News & Events and we will update this every other week.  Have any of you out there built in objects to allow for ease of updating this content w/o having to go in and change code?  Background:  we are adding our html pages to vf pages for our website.  This will be continueally developed for dynamic product pages etc and eventually will tie into our customer portal and an online ordering solution, all custom dev solutions.  We do NOT feel CMS (site.com) is warranted at this time.

 

Any push in the right direction is apprecaited.

 

Cheers,

 

-JB