• Haagen
  • NEWBIE
  • 50 Points
  • Member since 2011

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 29
    Replies

Hi,

 

I am trying to create a Email Functionality on click a custom button. i.e. I have a button that runs javascript on click and it executes the Apex class.

 

Button is:

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

{!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/14.0/apex.js")}

var result=sforce.apex.execute( "EmailMe", "EmailFunction", {});
alert(result);

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

 

Apex Class is:

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

public with sharing class EmailMe {
    
    private String[] toAddresses;
    
    public EmailMe(){
        List<User> currentUser = [Select Email from User where Id =:UserInfo.getUserId()];
        String[] toAddresses = new String[] {currentUser[0].Email};
    }
    
    public String EmailFunction(){
        
             Messaging.reserveSingleEmailCapacity(4);
        
             Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                
        mail.setToAddresses(toAddresses);
        mail.setSubject('Test Mail');
        mail.setPlainTextBody('Your Case has been created for testing');
        
        Messaging.SendEmailResult[] res = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
        if(res[0].isSuccess()){
            return 'Email is sent';    
        }
        else{
            return res[0].getErrors()[0].getMessage();
        }            
    }
}

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

 

But i am recieving something like this error:

 

"{http:// soap.sforce.com/schemas/package/EmailMe}Emailfunction please check the WSDL for the service.."

 

Do you think I have to setup some connection or something??

I am using my DEV org.

 

Help!!

I'm creating a trigger in which I'd like to check some Opportunity details. I tried

 

for(Event e: trigger.new){
  if(e.What.CloseDate == ...){
    
  }
}

 but it gives Invalid field CloseDate for SObject Name error.

Is there a way to get these details? I don't want to use SOQL,

 

Thank you,

Viktor

 

Hi,

 

In our instance we have a couple of classes generated by wsdl2apex that "randomly" (I cannot see a pattern) throws a System.CalloutException with the message "Failed to get next element". I have googled a bit but couldn't find anything that I could think was related. The web services called logs all attempts but when I get this exception I can't see that the web services has been accessed at all. The web services are all build with .NET 3. 

 

I don't know what the best way to start troubleshoot this is. So I thought I should give the boards a try!

 

Any suggestions or ideas are welcome!

 

Thanks!

 

Martin

 

 

  • April 07, 2011
  • Like
  • 0

Hi,

 

I have a simple Site object which uses a Visualforce page, which uses an apex controller class. In this controller class, I put some debug statements (System.debug), but I am finding that the output is not being written to the log. I know for a fact that the code is being executed because other calculations in that class are executing.

 

Is there a reason why my debug statements are not printing just because I am calling the code from a Site? I have used System.debug in other areas where I just have a Visualforce page and an Apex class and the debug worked fine...

 

Thanks!

Hi,

 

I have a Custom Object Called "Visit" which has  two custom date fields , StartDate__c and EndDate__c.

 

I have a Soql Query which needs to compare whether visit record is withinthe date range.

My SOQL query returns an error saying "List has No rows of data".

 

example: i have a visit record which has a start date as 2011-05-10 and End Date as 2011-05-17.

 

Can anyone point me what i am doing wrong?

 

Apex class:

 

public class visit {
    visit__c todaysvisit;
    String displayvisit;
    Date today=Date.Today();
  
    
    Public visit(){
        
        System.Debug('Todays date is >>>'+today);
        todaysvisit=[Select Visit__c From Visit__c Where Visit_Start_Date__ >= today AND Visit_End_Date__c <= today Limit 1 ];
        displayvisit=todaysvisit.visit__c;
        
    }
    
    Public Tip__c gettodaysvisit(){
        return todaysvisit;
    }
    
    Public String getdisplayvisit(){
        return displayvisit;
    }
    
   
}

 

 

Thanks,

Sales4ce

 

Hi,

 

I have to launch other application from Account detail page, when a custom button clicked on. In the background i have to build the URL dynamically by including multi picklist values for a query string and each optional values separated by '|' operator. When i test the button click logic, the generated URL consist of encoded value for '|' operator which doesn't supported by the target application. Can anyone help me to build the URL as it is.

 

Regards,

SuBaa 

  • May 10, 2011
  • Like
  • 0

hi i have address custom object ,i am creating a vf page for address-->custom object address have record type billing,shipping,company in different sections separately in a custon vf page,on click a save button only first section i.e billing address is saving shipping and company address not saving can any one help me in conditiions to use.

 

my condition:

   public PageReference save() {

 

if(adresstype=billing)

{

address record type will save;

}

else

if(adresstype=shipping)

{

address record type will save;

}

else

if(adresstype=company)

{

address record type will save;

}

}

 

only address with billing is saving.

i want the three address to save in a button click.

 

Hi,

 

I am trying to create a Email Functionality on click a custom button. i.e. I have a button that runs javascript on click and it executes the Apex class.

 

Button is:

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

{!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/14.0/apex.js")}

var result=sforce.apex.execute( "EmailMe", "EmailFunction", {});
alert(result);

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

 

Apex Class is:

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

public with sharing class EmailMe {
    
    private String[] toAddresses;
    
    public EmailMe(){
        List<User> currentUser = [Select Email from User where Id =:UserInfo.getUserId()];
        String[] toAddresses = new String[] {currentUser[0].Email};
    }
    
    public String EmailFunction(){
        
             Messaging.reserveSingleEmailCapacity(4);
        
             Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                
        mail.setToAddresses(toAddresses);
        mail.setSubject('Test Mail');
        mail.setPlainTextBody('Your Case has been created for testing');
        
        Messaging.SendEmailResult[] res = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
        if(res[0].isSuccess()){
            return 'Email is sent';    
        }
        else{
            return res[0].getErrors()[0].getMessage();
        }            
    }
}

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

 

But i am recieving something like this error:

 

"{http:// soap.sforce.com/schemas/package/EmailMe}Emailfunction please check the WSDL for the service.."

 

Do you think I have to setup some connection or something??

I am using my DEV org.

 

Help!!

Dear Friends,

 

                 I am trying to test triggers in the Sandbox, I deployed Test Class but when I activate trigger to be tested by that Test Class, my test class fails. It is trowing error as per mentioned in trigger. 

E.g. My trigger checks wheather e-mail entered in Lead is already exist in the Lead or contact object. So that my trigger works fine but when I run test class, my test class failed.

 

What will be the possible cause of such failure of trigger?

 

Thanks & Regards,

Maddy

Hi,

 

Is there anything similar to mail.setToAddresses(str) [which sets the recipient's email addresses] to set the sender's address, like setFromAdresses(str) ?

 

I am sending email through Apex trigger.

 

for(Travel_Reimbursement__c tr : Trigger.New) {
        mail = new Messaging.SingleEmailMessage();
        toAddress = new String[] {ownerMap.get(tr.OwnerId).Manager.Email}; 
        mail.setToAddresses(toAddress);
        mail.setSenderDisplayName(ownerMap.get(tr.OwnerId).Name);
        //mail.fromAddress();  ??????       
        mail.setSubject('Request for approval of Travel Reimbursement-'+tr.CreatedDate.format('M/d/yyyy'));
        mail.setPlainTextBody('Test');
        mail.setHtmlBody('<h2>Travel Reimbursement</h2>');
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}

 Everything works fine. But when I check that email in my inbox, it shows different address(of admin).

 

 

Please suggest.

 

Hello,

 

I am developing on non profit salesforce instance and have a problem with setting up field level security. There is an field "DoNotCall" in general fields, however I need to set Visible flag for all profiles. Is it possible to do this with APEX and if so could You please describe me how to do that?

 

Any help would be appreciated.

Thank You Jan

  • April 13, 2011
  • Like
  • 0

Hi

i want to create a single method for multiple CustomObjects

 

So i want to pass the id of that object in method and want to run soql for that

 

for e.g.

puvlic static void myMethod(id objectId){

                ----Soql to retrieve record -------

 

}

 

how to retreive whole record for that id within method

 

Please Help

We have a custom object NRProducts__c that is made up of all of our products. We want to be able to import a file update (via import wizard) to update inventory levels. The import file will not be based on the Name record, but rather an external number (Model_Number__c). Our goal is that if a new Model_Number exist in the import file that a new record is inserted with the default name "NEWPRODUCT". Below is the trigger that was created, but when we run an import with a new Model Number and Name as null/blank we get an email saying the record already exist (see below)

trigger ProductTrigger on NRProducts__c (before update, before insert) {
for(NRProducts__c r : Trigger.new){
if(r.Name == null && r.Name.length() <= 0){
r.Name = 'NEWPRODUCT';
}
}
}


Email from SF-
Force.com Sandbox

Alert: All information in the import file was already in salesforce.com.

Result: No data was created or modified in salesforce.com.

If you encounter any problems or have any questions, please contact us by clicking Help & Training at the top right of any salesforce.com page and choosing the My Cases tab.

Thank you!

Customer Support
salesforce.com


Any ideas how to make this work?

  • April 12, 2011
  • Like
  • 0

I am writing this code

var answer=document.getElementById("{!$Component.Ans1}");

alert(answer);

 

 

but it returns the null value.

 

Can u please help me in this issue.

 

 

 

 

 

 

Hi.

 

I am looking to Clone Opportunities whilst keeping Contact Role in place. At the moment, when I clone an opportunity, it links to the Account, but not the contact. I need it to link to the Contact. I have asked this in Salesforce Ideas and also in Customer resources. I was told that in here I might get an answer.

I am using PE

 

Cheers in advance.

HI All

 

How can i transfer the data from PosTgre SQL to MySQL by using the java. Can u Pls help me

 

 

Thanks &Regards

Sahasra.

 

 

I'm creating a trigger in which I'd like to check some Opportunity details. I tried

 

for(Event e: trigger.new){
  if(e.What.CloseDate == ...){
    
  }
}

 but it gives Invalid field CloseDate for SObject Name error.

Is there a way to get these details? I don't want to use SOQL,

 

Thank you,

Viktor

 

Hi,

i am facing the problem on windows 7 platform machines.

The site performance slows down on windows 7 platform.

Does anyone know why is it so?