• Dirk Gronert
  • NEWBIE
  • 185 Points
  • Member since 2012

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

I am trying to write a simple Apex class to send out an email to one of our administrators with a list of the "Peer To Peer" objects that have not been fully approved. I am planning on scheduling this class to run by implementing the Schedulable interface. My problem is that I am not able to get the methods of the SingleEmailMessage class to accept any parameters! The PeerToPeerHoldReportBuilder class simply provides the content for the email, so I am pretty sure the problem resides in the code below where I am actually creating the email:

 

Also, when I say that the method won't accept parameters, I mean that I cannot save my class if I call .setToAddresses(toAddresses), or .setHtmlBody(body), or .setSubject(subject). This is mind boggling for me! The error I am receiving states" Unexpected character, expected ')' "

 

public with sharing class PeerToPeerHoldReportBuilder
{
PeerToPeerHoldReporter reporter = new PeerToPeerHoldReporter();
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
String subject = 'Peer to Peer Report';
String body = reporter.ParseValues();
String[] toAddresses = new String[] {'lryan@enterasys.com'};

email.setToAddresses(toAddresses);
email.setHtmlBody(body);

email.setSubject(subject);
List<Messaging.SendEmailResult> result = Messaging.sendEmail(new Messaging.Email[] { email } ,false);

}

 

 

 

Any help would be appreciated, this is the third time I have picked this task back up and each time I cannot continue working with it because the issues with the email classes methods not accepting parameters.

 

For some reason this list in my constructor is showing up as null.

 

Here is a partial code snippit with some info modified to focus on the problem.

 

public class PlacementPreferenceFormController {

	public LIST<Partner_Research__c> temp_prl;
	public LIST<Partner_Research__c> prl {get; set;}
	
	public PlacementPreferenceFormController(){
		
		// Display list of potential placements
		temp_prl = [select id,State__c,City__c,Organization_Type__c,Organization_Name__r.Name 
		from Partner_Research__c
		Where Organization_Name__c IN 
			(Select AccountId From Opportunity 
			Where TBR_Partner_Year__c = 'TBR Partner 2011' AND StageName = 'Position Ready for Matching')
			Order by Organization_Type__c];

		// Remove Duplicates
		
		string allIds = '';
		string stringCompare = '';
		for (Partner_Research__c s : temp_prl) {
			stringCompare = s.Id;			
		  	if (!allIds.contains(stringCompare)){
		    	system.debug('******************************');
		    	system.debug(!allIds.contains(stringCompare));
		    	system.debug('******************************');
		    	system.debug(s);
		    	system.debug(prl);		    	
		    	prl.add(s);
		    	allIds = allIds + ',' + s.Id;
		  	}
		}		

	}

 I get an error in the line prl.add(s); When I debut the prl object I get null back instead of an empty (or populated) list.

 

Any idea why the prl object is null and how I can correct this. Perhaps its a problem of scope?

Hi All!,

   I am trying to solve this below problem, Can any one experienced with this, help me out...

My Object Is: ContentVersion

My Filed Is : Content_Type__c (multi picklist)

 

Functionality is passing "type"  as URL parameter, so that It will retrieve the records bases on "type".

 

I am trying to verify that my query is picking up content that has been tagged in two or more "Types" It seems like I may need to change my query to be "contains" rather than equals.

 

Can I write "Contains" or "Includes" in SOQL Like in 2nd Screen shot. I tried, it got executed but while seeing the output Error comes like : Unexpected Contains (For Contains), Invalilid "Announcemnts" (Product 'Announcements' is one of the Content_Type__c.). It throws error here while using Includes.

 

String query = 'Select Id, Title, LastModifiedDate, Content_Type__c, ContentDocumentId,Description,ContentSize From ContentVersion ';

                 
                 if(type != null && type != '') {
                    
                       query  += ' where Content_Type__c = \''+type+'\''; 
                    
                    
                 }
//Set<String> multiSelectValues = new Set<String>();
             //multiSelectValues.addAll(ContentVersion.Content_Type__c.split(';'));
             //if(multiSelectValues.contains('Product Announcements')){
                 //query  += ' where Content_Type__c = \''+type+'\'';                     
                 //query  += ' where Content_Type__c Includes (:'+' \''+type+'\')';
                 //query  += ' where Content_Type__c contains(:%+type+%)';
             //}

 Can I write my SOQL with either "Contains" or "Includes". ?

 

  • February 24, 2012
  • Like
  • 0

Hi,

 

I am new to salesforce. I am developing an application for iOS. I have used zkSforce framework to communicate with salesforce and partially done my job. Now I have found SalesforcemobileSDK-iOS in the portal. 

1. Should I use this SDK?

2. Shall I continue with existing zkSforce framework?

3. What are the benefits of SDK?

 

--

Mathi

I have a number of employees in my company who are not Salesforce users, but who have Chatter accounts. I need to associate a particular Chatter user with each instance of a custom object, but I'm not able to pull the list of Chatter users (i.e., People, I believe) as a look-up. I only get currently active SF licence users. Does anyone know how I can pull this info out and use it in a picklist?

 

Thanks!

Hi,

       I need to allow the user to add only two attachments in the record. How can i achieve this?

       Can we achieve by using validation?

Plz Guide me!

 

Thanks

vinoth

  • February 21, 2012
  • Like
  • 0

I have a Visualforce page that displays a number of records in a data table with a checkbox in each row. As can be seen in the code below

 

<apex:page controller="ProgramSupportList">
    <apex:pageBlock >
      <apex:form >  
        <apex:pageBlockTable value="{!ProgramSupportItems}" var="psi">
            <apex:column >
                <apex:facet name="header">
                    Select
                </apex:facet>
                <apex:inputCheckbox value="{!psi.id}" />
            </apex:column>        
            <apex:column value="{!psi.id}"/>
            <apex:column value="{!psi.Status__c}"/>
            <apex:column value="{!psi.Date__c}"/>
            <apex:column value="{!psi.Hours__c}"/>
            <apex:column value="{!psi.Program__r.Executive_Coach__c}"/>            
        </apex:pageBlockTable>
        <apex:commandButton action="{!ProcessSupportItems}" value="Invoice Selected Items" />
      </apex:form> 
    </apex:pageBlock>
</apex:page>

 

What I don't know is how to set up the ProcessSupportItems method to grab those values and pass them to a static method.

 

Here is my controller code 

 

public class ProgramSupportList {

    public PageReference ProcessSupportItems() {
         List<Program_Support__c> ml = setCon.getSelected();
         System.Debug('************1');
         System.Debug(ml);
         System.Debug('************2');       
        return null;
    }

    
  // ApexPages.StandardSetController must be instantiated 
    
  // for standard list controllers 
    
    public ApexPages.StandardSetController setCon {
        get {            
            if(setCon == null) {                
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
                       [Select Id,Status__c,Program__r.Executive_Coach__c,Date__c, Hours__c From Program_Support__c
                        where Program__r.Executive_Coach__c = '003V0000001y6nC' 
                        AND Status__c != 'Invoiced'
                       ]));
            }
            return setCon;
        }
        set;
    }

    // Initialize setCon and return a list of records 
    
    public List<Program_Support__c> getProgramSupportItems() {
         return (List<Program_Support__c>) setCon.getRecords();
    }
}

 

I have noticed that the button does not seem to be calling the method as I don't see any of my debug statements. So that may be the issue.

 

NOTE: I eventually did resolve the problem using the wrapper based solution. One thing that was causing a problem for me was also this line of code:

 

<apex:inputCheckbox value="{!psi.id}" />

While it did not generate an error it would not allow any command buttons to properly call the APEX methods. Turns out its not a good idea to bind a checkbox to a read only field as I did in this case :) .I fixed this using code similar to what was presented below in the solution by incorporating the wrapper and binding the checkbox to a boolean field.

hi guys,

 

Can u please help me in this trigger.

this trigger is inserting duplicate records in updation call and insertion is failed.

please help me in changing code.

i feel map is the gud choice in this trigger

 

trigger doc on federal__c(after insert)

 

Set<Id> sobjectSetOfIds = new Set<Id>();
List<federal__c> flist = new List<federal__c>();
 for(federal__c fs:trigger.new) {
    if(fs.Opportunity__c!=null)
     sobjectSetOfIds.add(fs.Opportunity__c);    
       flist.add(fs);
 }
 list<Conditions__c> comlist = [select id,opportunity__c,Contact__c,Federal__c from Conditions__c where opportunity__c =:sobjectSetOfIds];
 list<Conditions__c> updatedcomlist = new list<Conditions__c>();
 for(Federal__c fss :flist) {
    for(Conditions__c cm: comlist) {     
            cm.federal__c=fss.id;         
            updatedcomlist.add(cm);
        }
    }
    upsert updatedcomlist;
}

 

Thanks

$f

 

  • August 12, 2012
  • Like
  • 0

Has anyone experiences in setting up chatter plus user?

I'm facing the choice of using chatter plus licence or service cloud portal user.

I preferred Chatter plus but not sure whether chatter plus users can view  visualforce pages, for I don't see any access rights setup in normal Chatter user's profile.

Anyone can help me ?

Hi,

 

 I am trying to get the content from a VF page and store it as an attachment. So i am doing below:

 

PageReference pg = new PageReference('/apex/myDoc?oppId=' + oppId);

pg.setRedirect(true);

 

Attachment att = new Attachment();

att.Body = pg.getContent(); <--- Here i get java.net.SocketException: Connection reset but it is intermittent and not reproducible.

 

Any idea why is this happening?

 

Thanks for the help!!

 

 

I have built a trigger that is called when a contact/lead is updated. This trigger calls a @future method with a callout when a specific field (Email_Issue__c) starts off populated and is then saved to null.

One of our clients has a night batch upload that does an upsert on all its contacts and even though the Email_issue__c is not one of the fields being updated in the batch somehow the callout is going through. When looking through the bulk data load jobs we see the error CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY:itracmedia.InvalidEmailContactTrigger: System.LimitException: itracmedia:Too many future calls: 11:-- for about 100 of 5000 records it processes.

Can someone please explain why this might be happening and what i can do to fix this issue.

 

Trigger

trigger InvalidEmailContactTrigger on Contact (before update)
{
    private String emailissue {get; set;}
    if(Trigger.isBefore)
    {
        emailissue = null;
        for(Contact contact : trigger.old)
        { 
            emailissue = contact.itracmedia__Email_Issue__c;
        }
        
        for(Contact contact : trigger.new)
        {            
            if(contact.itracmedia__Email_Issue__c == null && emailissue != null)
            {  
                if(contact.lastName == 'ApexRunTestIssue'){
                    EmailIssueRemover.test();
                } else {      
                    EmailIssueRemover.removeEmailIssue(contact.id, emailissue, contact.itracmedia__session_id__c, contact.itracmedia__server_url__c);
                }
            } 
        }
    }
}

 

Apex Class:

public class EmailIssueRemover {

  // Static variable that assumes a test is not running
  public static boolean isApexTest = false;
    
  //Future annotation to mark the method as async.
  @Future(callout=true)
  public static void removeEmailIssue(String id, String issue, String sessionid, String serverurl) {

     String server = EncodingUtil.urlEncode(serverurl,'UTF-8');
     String session = EncodingUtil.urlEncode(sessionid,'UTF-8');
   
     Http h = new Http();
     HttpRequest req = buildWebServiceRequest(id, EncodingUtil.urlEncode(issue,'UTF-8'), session, server);
     if(!isApexTest){
       HttpResponse res = invokeWebService(h, req);   
     } 
  }
    
  public static HttpRequest buildWebServiceRequest(String id, String issue, String sessionid, String serverurl){

    //Build HTTP Request object
    HttpRequest req = new HttpRequest();
    req.setEndpoint('https://www.**.com/removeEmailIssue?sessionid=' + sessionid + '&serverurl='+ serverurl + '&type='+issue+'&id='+id);
    req.setMethod('GET');
    return req;
  }
  
  public static HttpResponse invokeWebService(Http h, HttpRequest req){
     HttpResponse res = h.send(req);
     return res;
  }
  
  // Wrapper method for "main" that we will call in the Test Class
  public static void test(){
    isApexTest = true;
    removeEmailIssue('test','test','test','test');
  }
}

 


I have the below apex trigger in place but it doesn't see me to be refreshing the filed when the data changes. Can anyone help me  figure out what I need to add to make sure  that operation happens. Something needs to be missing.

 

trigger updateContract on Opportunity (before Update) {

set<id> contIds = new set<id>();
list<contract> listcon = new list<contract>();
set<id> oppIds = new set<id>();
Double InitialSum ;

For(Opportunity o :trigger.new)
{
contIds.add(o.contract__c);
oppIds.add(o.id);
}

Map<id,contract> MapofCons = new Map<id,contract>([select id, name,Total_Opportunity_Amount__c from contract where id in :contIds]);
Map<id, opportunity> MapOfOpps = new Map<id,opportunity>([select id,name, amount from opportunity where id in :oppIds]);
For(opportunity o: trigger.new)
{


If( MapofCons.get(o.contract__c).Total_Opportunity_Amount__c ==null)
InitialSum = 0 ;
else
InitialSum = MapofCons.get(o.contract__c).Total_Opportunity_Amount__c;

If((MapOfOpps.get(o.id).amount==null)&& (o.amount!=null))
{ MapofCons.get(o.contract__c).Total_Opportunity_Amount__c = InitialSum + o.amount;
Listcon.add(MapofCons.get(o.contract__c));
}
else If((MapOfOpps.get(o.id).amount!=null)&& (o.amount==null))
{ MapofCons.get(o.contract__c).Total_Opportunity_Amount__c = InitialSum ;
Listcon.add(MapofCons.get(o.contract__c));
}
else
{
if(mapofOpps.get(o.id).amount != o.amount)
{ MapofCons.get(o.contract__c).Total_Opportunity_Amount__c = InitialSum + o.amount- mapofOpps.get(o.id).amount ;
Listcon.add(MapofCons.get(o.contract__c));
}
}
}
update Listcon;

}

 

Can anybody help me. I want to add pagination in <apex: list view>  component  as we have in standard list view .We have only next previous in <apex: list view>  component.But how to get the page summary and all???please help

  • March 08, 2012
  • Like
  • 0

Hi developer heroes,

 

I'd love to pick your brain with the following scenario.

 

Standard Object-Master: Opportunity

Custom Object-Child: Produkt_Ressourcen_Forecast__c

Visualforce Page: ProductResourceForecast

Controller Extension: extForecastProducts

 

What I try to accomplish is an "Edit all" VS page for the custom object. When I click on "Edit all" the following error pops up:

 

Error: Id value 006L0000002BRTw is not valid for the Produkt_Ressourcen_Forecast__c standard controller 

 

The interesting part is, when checking the Id mentioned above it matches the Oppty Id the custom object belongs to.

 

I skimmed the boards already but I wasn't able to get this one fixed myself. Since it is day3 of VF for me, help is much appreciated!

 

--------------------------------

 

The Controller Extension:


public class extForecastProducts{
private final Produkt_Ressourcen_Forecast__c ForecastProducts;

List<Produkt_Ressourcen_Forecast__c> lstForecastProducts;

Opportunity ForecastProductsNew;

public extForecastProducts(ApexPages.StandardController controller) {
this.ForecastProducts= (Produkt_Ressourcen_Forecast__c)controller.getRecord();


// get Oppty Id from custom object where current id matches


Id Opps= [Select OpportunityID__c FROM Produkt_Ressourcen_Forecast__c 
where Id =: ApexPages.currentPage().getParameters().get('id')].OpportunityID__c;
lstForecastProducts = (List<Produkt_Ressourcen_Forecast__c>)[ 

// get fields of custom object


Select Id,
Contact__c, 
Cost__c, Cost_Type__c, 
Forecast_Product__c,
ID__c,
Forecast_Quantity__c,
Forecast_Unit__c, 
Leistung_erbracht__c, 
Mitarbeiter_Rolle__c,
Opportunity_Line_Item_Id__c,
Opportunity_TS_BETA__c,
Product__c,
Product_Code__c,
Profitability__c,
Quantity__c,
Sales_Price__c,
SFDC_Lizenz_Preis__c,
Subunternehmen__c,
To__c,
Total_Cost__c,
Total_Margin__c,
Total_Price__c,
Unit__c, 
OpportunityID__c 

From Produkt_Ressourcen_Forecast__c
where OpportunityID__c =: Opps]; 
ForecastProductsNew = [Select Id, Name From Opportunity Where Id =: Opps];
}
public List<Produkt_Ressourcen_Forecast__c> getlstForecastProducts(){
return lstForecastProducts;
}
public Opportunity getForecastProductsNew(){
return ForecastProductsNew;
}

public PageReference save() {
update lstForecastProducts;
return (new ApexPages.StandardController(ForecastProductsNew)).view();

}

 

The VS Page:

 

<apex:page standardController="Produkt_Ressourcen_Forecast__c" tabStyle="Opportunity" sidebar="false" extensions="extForecastProducts">
<apex:form >
<apex:pageBlock >
<apex:pageMessages />

<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!Save}"/>
<apex:commandButton action="{!Cancel}" value="Cancel"/>
</apex:pageBlockButtons>

<apex:pageBlockTable value="{!lstForecastProducts}" var="prod" id="prod_table">
<apex:column value="{!prod.Name}"/>
<apex:column headerValue="Opportunity">
<apex:inputField value="{!prod.Opportunity_TS_BETA__c}"/>
</apex:column> 
<apex:column headerValue="Forecast Product">
<apex:inputField value="{!prod.Forecast_Product__c}"/>
</apex:column> 
<apex:column headerValue="Leistung erbracht">
<apex:inputField value="{!prod.Leistung_erbracht__c}"/>
</apex:column>
<apex:column headerValue="Mitarbeiter Rolle">
<apex:inputField value="{!prod.Mitarbeiter_Rolle__c}"/>
</apex:column>
<apex:column headerValue="From">
<apex:inputField value="{!prod.From__c}"/>
</apex:column> 
<apex:column headerValue="To">
<apex:inputField value="{!prod.To__c}"/>
</apex:column> 
<apex:column headerValue="Forecast Quantity">
<apex:inputField value="{!prod.Forecast_Quantity__c}"/>
</apex:column> 
<apex:column headerValue="Forecast Unit">
<apex:inputField value="{!prod.Forecast_Unit__c}"/>
</apex:column> 
<apex:column headerValue="Kontakt">
<apex:inputField value="{!prod.Contact__c}"/>
</apex:column> 
<apex:column headerValue="Subunternehmen">
<apex:inputField value="{!prod.Subunternehmen__c}"/>
</apex:column> 

</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

 

THX

I am trying to write a simple Apex class to send out an email to one of our administrators with a list of the "Peer To Peer" objects that have not been fully approved. I am planning on scheduling this class to run by implementing the Schedulable interface. My problem is that I am not able to get the methods of the SingleEmailMessage class to accept any parameters! The PeerToPeerHoldReportBuilder class simply provides the content for the email, so I am pretty sure the problem resides in the code below where I am actually creating the email:

 

Also, when I say that the method won't accept parameters, I mean that I cannot save my class if I call .setToAddresses(toAddresses), or .setHtmlBody(body), or .setSubject(subject). This is mind boggling for me! The error I am receiving states" Unexpected character, expected ')' "

 

public with sharing class PeerToPeerHoldReportBuilder
{
PeerToPeerHoldReporter reporter = new PeerToPeerHoldReporter();
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
String subject = 'Peer to Peer Report';
String body = reporter.ParseValues();
String[] toAddresses = new String[] {'lryan@enterasys.com'};

email.setToAddresses(toAddresses);
email.setHtmlBody(body);

email.setSubject(subject);
List<Messaging.SendEmailResult> result = Messaging.sendEmail(new Messaging.Email[] { email } ,false);

}

 

 

 

Any help would be appreciated, this is the third time I have picked this task back up and each time I cannot continue working with it because the issues with the email classes methods not accepting parameters.

 

how can update the contact fields once opportuity added using trigger.

1. i created two fields in Opportunity object i.e Contract Length and Service Date

2. i  created two fields in Contact obejct. i.e Contract Length and Service Date.

 

Now  i fills the value in contaract length and Service Date field in Opportunity object. then automatically  update the Contract Length and Service Date fields in contact object . how can do this task . i am new in apex codeing .pls help me..................

  • February 25, 2012
  • Like
  • 0

Can anyone help me with this frustrating issue. I am developing an application where I want to relate a number of opportunities with a contract and have the abilitiy to total sum the opportunity amounts and count the opportunities against this contract. I can't believe this can't be done. Am I the first person that's tried to do something like this?

Hello! I need help. I wrote in Apex the following code and it gives me no error:

 

public pageReference doSearch2(){
if(searchtext != '' ){

list<list<sobject>> result = [Find :searchtext IN ALL FIELDS RETURNING accountr__c(id,Name, phone__c,Pertenece_a_GIE__c,creado_por__c,nombre_de_creado_por__c, accountnumber__c,ram__c, fax__c, website__c, type__c, numberofemployees__c , industry__c, annualrevenue__c, Description__c, Ejecutivo_Local_Colombia__c,
Ejecutivo_Local_costa_rica__c,Ejecutivo_Local_el_salvador__c,Ejecutivo_Local_estados_unidos__c,Ejecutivo_Local_guatemala__c,Ejecutivo_Local_honduras__c,Ejecutivo_Local_mexico__c,Ejecutivo_Local_nicaragua__c,Ejecutivo_Local_panama__c,Ejecutivo_Local_venezuela__c,Ejecutivo_Local_republica_dominicana__c
where creado_por__c in (select Ejecutivo_DP__c from usuarios_jn__c  where ejecutivo__c=:apexpages.currentpage().getparameters().get('id') )order by name )];
veraccount =((list<accountr__c>)result[0]);
}
return null;}

And when I actually test it in my page i receive the following message:
System.QueryException: unexpected token: '@'

 

Can somebody help me figure this one out? I couldn't find anything like this error on the discussion boards or anywhere else. I don't have anything resembling like an email to receive this type of message.

Please help me, it will be greatly appreciated

Hi,

 

I am new to salesforce. I am developing an application for iOS. I have used zkSforce framework to communicate with salesforce and partially done my job. Now I have found SalesforcemobileSDK-iOS in the portal. 

1. Should I use this SDK?

2. Shall I continue with existing zkSforce framework?

3. What are the benefits of SDK?

 

--

Mathi

Hello, sometime recently, it appears that the API has stopped allowing access to the RecordType entity. The error I'm seeing is:

 

"INVALID_TYPE: Name,Descripiton,IsActive from RecordType ^ ERROR at Row:1:Column:42 sObject type 'RecordType' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names."

 

Can anyone help me out here?

 

Thanks.

  • February 22, 2012
  • Like
  • 0