• Himanshu Maheshwari
  • NEWBIE
  • 85 Points
  • Member since 2014
  • Software Engineer
  • Compro Technologies


  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 18
    Replies
Hello,

I am trying to make a gauge chart in a VF component.  There is one custom object that I want to summarize by record owner, so that logged in users should only see their own result.  I have hobbled together several samples I have found in documentation, but I am stuck on the concept of AggregateResult being an object.  I can't seem to retrieve the single decimal number that I need for each user.

Controller so far:
public class GaugeController {
    public String userId {get;set;}
    public String userName {get;set;}

    public GaugeController(ApexPages.StandardController controller){
        userId = UserInfo.getUserId();
        userName = UserInfo.getName();
    }

    public List<gaugeData> getData() {
          Integer thisYear = date.Today().year();

          AggregateResult groupedResults = [select SUM(Total_Hours_Out__c)sumhrs from Absence__c where Owner.Id =: userId and CALENDAR_YEAR(Start_Date__c) =: thisYear];
          Decimal TotalHours = (decimal)groupedResults.get('sumhrs');
          //for (AggregateResult ar : groupedResults) {
          //    TotalHours += ar.get('sumhrs');
          //    }
          
          List<gaugeData> data = new List<gaugeData>();
          data.add(new gaugeData(userName, TotalHours));
          return data;
          }
    public class gaugeData {
        public String name {get;set;}
        public Decimal hours {get;set;}
        
        public gaugeData(String name, Decimal data) {
            this.name = name;
            this.hours = data;
        }
    }
}
And VF page so far:
<apex:page standardController="User" sidebar="false" showHeader="false" extensions="GaugeController">
    <apex:chart name="TimeOff" height="300" width="300" animate="true" data="{!data}">
        <apex:axis type="Gauge" position="gauge" title="Time Off Hours Remaining This Year" minimum="0" maximum="100" steps="8"/>
        <apex:gaugeSeries dataField="hours" donut="50" colorSet="#0099ff,#ff0066"/>
    </apex:chart>
    
</apex:page>
I'm not a regular coder, so I would appreciate any help.

Thanks!
How can I make the values of field CreatedBy.Name appear in bold, in following code?

<apex:pageBlockTable value="{!Case.CaseComments}" var="c">
            <apex:column width="28%" headerValue="Date" value="{!c.createddate} ({!c.CreatedBy.Name})" />
</apex:pageBlockTable>
I want to rename my custom domain name now it has been deployed.

My requirement is that on click of a custom button in contract object  an email needs to be generated.
 The button is not embedded in the visual force but is present at the contract header.When user goes to the contract Tab and clicks any valid contract the "Email" button comes next standard "Edit" "Delete" and clone buttons as expected for the specific contract.Have been succesfull till here.A dummy email gets triggered.

The next part of the requirement is retrieve the current contract number and pass it in the email subject .
I used SOQL to retrieve the current id but I'm getting null value "List has no rows for assignment to SObject 
An unexpected error has occurred. Your development organization has been notified.".
This indicates my SOQL query has not retrieved any value for the current id.wanted to now where I have gone wrong.
Any advice on the syntax and code to be used would be of great help.

Indiacted below is my entire apex class code below :
// below is the email triggerring apex class
public class emailsend_class{

string email_body {get {return 'this is contractemail'; } set;}
string email_subject {get;set;}

public String currentRecordId {get;set;}
public String parameterValue {get;set;}

 public Contract con{get;set;}


list<string> emails = new list<string>{'pritesh.curicad@fci.com'};

//  Below method code will retrieve the current record 

public emailsend_class(){
currentRecordId  = ApexPages.CurrentPage().getparameters().get('id');
 con = [select ContractNumber from Contract where id =: currentRecordId ];

}

 
  public Contract getContract(){
    return con; }
  
public PageReference send() {

  Messaging.singleEmailmessage email = new Messaging.singleEmailmessage();
   email.setSubject(email_subject);
   email.setPlainTextBody(email_body);
   email.setToAddresses (emails);
  Messaging.SendEmailResult[] r = Messaging.SendEmail( new Messaging.singleEmailmessage[] {email} ); 
   
   return null;
   
    }

}

The visualforce page has only the below basic code

<apex:page controller="emailsend_class" action="{!send}">
  
 
</apex:page>
Hi


  @future
    public static void addLeadShares(Set<String> leadUserIds){
      List<ErrorLog__c> errLogs = new List<ErrorLog__c>();
      List<LeadShare> leadShares = new List<LeadShare>();
      for(String leadUsrStr : leadUserIds){
        
        String leadId = leadUsrStr.split('_')[0];
        String userId = leadUsrStr.split('_')[1];
        LeadShare ld = new LeadShare(LeadId = leadId, UserOrGroupId = userId, LeadAccessLevel = 'Read');
        leadShares.add(ld);
        
      }
      Database.SaveResult[] inRes = Database.insert(leadShares);
      // fetch LeadShare Id, then fetch LeadId from Map and add error to that lead, to stop the lead 
    // from further processing.
      for(Integer i=0;i<inRes.size();i++){
      if(!inRes[i].isSuccess()){
        errLogs.add(Utils.getErrorLogObj('Class : LeadTAHelper', 'LeadTAHelper : Error in LeadShare Insertion' + inRes[i].getErrors()[0].getMessage(), 'High'));
      }
    }
    insert errLogs;
    }

Thanks.
Hi all

I have a issue on my goal which is making problem .I have two object(Account and Object__c) both are in realtionship
In account object i have a picklist field with value(NEW and OLD).for example i have created a record in account object with picklist value NEW.
my rerquirment is when i will be create record on Object__c ,after creation of record the picklist value on Account object automatically changed to OLD.How it is possible.anybody have idea?
Hi All

I have two objects
  • Courses__C
  • Contact 
Many exisiting Students can sign up to course a 
and one student can be connected to multiple courses.

Using the lookup relationship field only does one to one and then you have to create contacts rather than just picking and choosing the individual courses.

How can this be determined guys?

Please help out

Regards
I'm working with incoming leads from vendors via email.  I'm trying to have the lead associated with the correct campaign name, but am getting the error "Compile Error: Initial term of field expression must be a concrete SObject: List<String> at line 33 column 28."  I have made the line in question bold and italics.
                       
global class CreateLeadFromEmail implements Messaging.InboundEmailHandler {
    global Messaging.InboundEmailResult HandleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope env) {
        
        // Create an InboundEmailResult object for returning the result of the  
        // Apex Email Service 
        String campaignName;
       
        Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
        String convertToPlainText= '';
        // Add the email plain text into the local variable  
        convertToPlainText = email.plainTextBody;
        System.debug('Email Content: ' + convertToPlainText);   
        //check if the incoming email Lead has an email address
        if(email.plainTextBody != ''){
            String[] emailBody = email.plainTextBody.split('\n', 0);
            System.Debug(emailBody);
            String LeadEmail = emailBody[6].substringAfter(': ').trim();            
            if(String.isNotBlank(LeadEmail)){
                Integer leadCount = [select count() from Lead where Email =: LeadEmail];
                List<Lead> leadList = [SELECT Id,status FROM Lead WHERE Email = : LeadEmail];
                System.debug('Lead count from the existing Lead with the requested emailId -'+ leadCount);
                //if (leadList.size() == 0 || leadList.size() > 1) {
                    try{
                        //Create new Lead as it does not exist
                        Lead createNewLead = new Lead();
                        //Set the Lead object values from the email body
                        createNewLead = CreateOrUpdateLead(createNewLead, emailBody);
                        System.debug('Before Lead insert');
                        insert createNewLead;    
                        System.debug('After Lead insert');
                        system.debug('Inserted Lead Id = '+ createNewLead.Id);
                        //Add the Lead to the correct campaign
                        if(emailBody.subject = 'Life Insurance Lead'){
                            campaignName = 'The Lead Guys';         
                        }
                        else if (emailBody.subject == 'New Webform Lead Notification'){
                            campaignName = 'Get Seen Media';
                        }
                            
                        Campaign campaignId = [Select id from Campaign where name =: campaignName]; 
                        CampaignMember leadCampaignMember = new CampaignMember(campaignid = campaignId.id, leadid = createNewLead.Id);
                        insert leadCampaignMember;
                        System.debug('New Lead record: ' + createNewLead );   
                    }
Hi,

I created a custom button that should redirect to different apex page based on the record type.
Example: If record type = a then it should redirect to "abc" page otherwise "xyz" page

But when i click on the button i get illiegal token error.
{!REQUIRESCRIPT("/soap/ajax/23.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/23.0/apex.js")} 

var rtype;

if({!Account.RecordTypeId} == "012G0000000nKI7")
{
rtype = "/apex/Newcase?";
}
else 
{
    rtype = "/apex/oldcase?";

}

window.top.location.href = rtype ;

Please help.
Hi Guys,

I have a custom with Javascript as below. I want to add this button to salesforce1 but because salesforce1 doesn't support custom button i am unable to do that. After investigation, I found out we can do this using publisher actions. Can anyone give an idea how to proceed on this? I have posted the code here for your reference.

Thanks,
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")} 

var crecord = []; 

var l = new sforce.SObject("Lead"); 

var c = new sforce.SObject("sf4twitter__Twitter_Conversation__c"); 

c.id = "{!sf4twitter__Twitter_Conversation__c.Id}"; 

var cm = new sforce.SObject("CampaignMember"); 


l.lastName = "{!sf4twitter__Twitter_Conversation__c.sf4twitter__Author_Real_Name__c}"; 

l.Facebook_Private_Message__c = "{!sf4twitter__Twitter_Conversation__c.sf4twitter__Message__c}"; 



l.RecordTypeId = "01290000001An45"; 

l.Database_name__c = "Facebook"; 

l.leadsource = "Facebook"; 

l.Company = "Facebook"; 

l.Assigned_to_caller__c = "Jordan Meates"; 

l.OwnerId = "00590000001B9wH"; 

var result = sforce.connection.create([l]); 

cm.CampaignId = "70190000000reFr"; 

cm.leadid = result[0].id; 

var result2 = sforce.connection.create([cm]); 

var NewlID = result[0].id; 

c.sf4twitter__Lead__c = NewlID; 

c.RecordTypeId = "01290000000ubYI"; 

crecord.push(c); 

result3 = sforce.connection.update(crecord); 



if(result[0].getBoolean("success")){ 
window.location = "/" + result[0].id ; 
}else{ 
alert('Could not create record '+result); 
}

 
  • February 15, 2016
  • Like
  • 0
Users cannot submit incident survey because the submit button is disabled. The questions of the survey and options to each answer are showed correctly, the issues is with the button in the end to submit the survey. Could you please help me to solve this issue?
Hi everyone,

I am trying to copy across the name of a custom child master relatioship object to a field on the opportunity, this is the code I currently have and the logs are saying its running succesfully but it isn't making any changes to the field in the opportunity:
 
trigger PullContactNum on Contract2__c (after insert, after update) {
    set<ID> opportunityids = new set<ID>();
    for(integer i=0; i < Trigger.size; i++){
	Contract2__c newContract = Trigger.new[i];
	if(Trigger.isInsert && newContract.Name != null)
	{opportunityids.add(newContract.Opportunity__c);}
    }
        



	if(opportunityids.isEmpty()){
		return;		
	}


List<Contract2__c> allContracts = [SELECT id, Name, Opportunity__c FROM Contract2__c WHERE Opportunity__c IN :opportunityids];
Map<Id, List<Contract2__C>> oppToContractMap = new Map <id,list<Contract2__c>>();
    for(Contract2__c contractCon : allContracts){
        list<Contract2__c> oppContract = oppToContractMap.get(contractCon.Opportunity__c);
        if(oppContract == null){
            oppContract = new List<Contract2__c>();
            oppToContractMap.put(contractCon.Opportunity__c,oppContract);
        }
        oppContract.add(contractCon);
    }    

Map<Id,Opportunity> conMap = new Map<Id,Opportunity>([SELECT id FROM Opportunity WHERE id IN :opportunityids]);
    for (Id conID : conMap.keySet()){
        List<Contract2__c> contracts = oppToContractMap.get(conId);
        String JobNum = '';
        if(contracts != null){
            for(Contract2__c contract: contracts){
            	JobNum += contract.Name;
                JobNum += ', ';
        	}
        }
        conMap.get(conID).Contract_Name__c = JobNum;
    }

	update conMap.values();

}

Thanks!
3 opps in 1 account if close win 1 opp how do i close lose other 2 opps?
Hello,

I am trying to make a gauge chart in a VF component.  There is one custom object that I want to summarize by record owner, so that logged in users should only see their own result.  I have hobbled together several samples I have found in documentation, but I am stuck on the concept of AggregateResult being an object.  I can't seem to retrieve the single decimal number that I need for each user.

Controller so far:
public class GaugeController {
    public String userId {get;set;}
    public String userName {get;set;}

    public GaugeController(ApexPages.StandardController controller){
        userId = UserInfo.getUserId();
        userName = UserInfo.getName();
    }

    public List<gaugeData> getData() {
          Integer thisYear = date.Today().year();

          AggregateResult groupedResults = [select SUM(Total_Hours_Out__c)sumhrs from Absence__c where Owner.Id =: userId and CALENDAR_YEAR(Start_Date__c) =: thisYear];
          Decimal TotalHours = (decimal)groupedResults.get('sumhrs');
          //for (AggregateResult ar : groupedResults) {
          //    TotalHours += ar.get('sumhrs');
          //    }
          
          List<gaugeData> data = new List<gaugeData>();
          data.add(new gaugeData(userName, TotalHours));
          return data;
          }
    public class gaugeData {
        public String name {get;set;}
        public Decimal hours {get;set;}
        
        public gaugeData(String name, Decimal data) {
            this.name = name;
            this.hours = data;
        }
    }
}
And VF page so far:
<apex:page standardController="User" sidebar="false" showHeader="false" extensions="GaugeController">
    <apex:chart name="TimeOff" height="300" width="300" animate="true" data="{!data}">
        <apex:axis type="Gauge" position="gauge" title="Time Off Hours Remaining This Year" minimum="0" maximum="100" steps="8"/>
        <apex:gaugeSeries dataField="hours" donut="50" colorSet="#0099ff,#ff0066"/>
    </apex:chart>
    
</apex:page>
I'm not a regular coder, so I would appreciate any help.

Thanks!
if suppose i had created Two fields on main page 1)Enter an Area   2)Find the Restaurents.

Now we clickon Enter an area Some values are Shown,click on That Value,,,,
After we go for click on  Find the restaurents .....To display the restaurents page.


pls tel me
How can I make the values of field CreatedBy.Name appear in bold, in following code?

<apex:pageBlockTable value="{!Case.CaseComments}" var="c">
            <apex:column width="28%" headerValue="Date" value="{!c.createddate} ({!c.CreatedBy.Name})" />
</apex:pageBlockTable>

Hello All,

 

I attempted to follow all of the directions outlined in Getting Started with the Force.com Toolkit for Facebook, Version 3.0 (Installed from GitHub). 

 

I receive an "Invalid redirect_uri: Given URL is not allowed by the Application configuration." error when I attempt to navigate directly to the FacebookSamplePage.  Type of error is an OAuthException.  The error code is 191.

 

However, I receive an is "under construction" page when I navigate directly to the site.

 

Has anyone seen this error and been able to resolve it successfully?

 

I've confirmed my site settings, remote site settings, Facebook Apps record, Facebook App configuration, and system admin profile. 

 

I did notice some of the setup screen captures in the instructions were slightly different than the current Facebook App Setup and Facebook App Salesforce record.

 

Thank you in advance for your assistance.

  • August 24, 2012
  • Like
  • 0