• Fra08
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 12
    Replies

Hi.

 

I create Apex Trigger and Class on Force.com IDE(Eclipse 3.5.2) and my project set to Production Organization.

Now, I want to delete from Apex Trigger and Class I created in past time, but I can't.

 

[can't delete message]

"Remote delete failed with the following message. Delete will be aborted.   <Apex Class Name>: null package.xml:null"

 

[Error Log]

■WARN

"(ProjectService.java:handleRetrieveResult:2068) - Nothing to save to project - retrieve result is empty"

■ERROR

"

(DeleteRefactorController.java:performRemoteDelete:274) - Remote delete failed with the following message.  Delete will be aborted.
  createWork: null

 

(DeleteRefactorController.java:performRemoteDelete:274) - Remote delete failed with the following message.  Delete will be aborted.  <Apex Class Name>k: null"

 

What's that phenomenon?

Why that phenomenon come up?

 

Please tell me that reason if you know.

And please tell me the solution if you will.

 

Thanks.

 

 

I can't seem to create an Event Button that populates a VF Email Template with event details using Professional Edition.

 

.  Here is the button.

 

"/_ui/core/email/author/EmailAuthor?p2_lkid={!Event.Who}&p3_lkid=&p4=&p5=&p24=&cancelURL=/{!Event.Id }&retURL=/{!Event.Id}&template_id=00XA0000000eyxo&recipient_type_id={!Event.Who}&related_to_id={!Event.Id}"

 

Putting the p3_lkid={!Event.Id} produces an error "Invalid parameter" due to the EmailAuthor doesn't seem to allow Events as a valid p3_lkid.

 

Here is the VF Email Template.

<messaging:emailTemplate subject="Appointment Confirmation" recipientType="Contact" relatedToType="Event">

<messaging:htmlEmailBody >
<p>Dear {!recipient.Name},
<br/>
<br/>
This is a reminder of an appointment that is scheduled.  Details are:
<br/>
<br/>
Appoinment: {!relatedTo.Subject}
<br/>
<apex:outputText value="Date: {0,date}">
<apex:param value="{!relatedTo.StartDateTime}"/>
</apex:outputText>
<br/>
<apex:outputText value="Time: {0,time,short}">
<apex:param value="{!relatedTo.StartDateTime}"/>
</apex:outputText>
<br/>
Company: {!relatedTo.What.Name}
</p>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

 

The template populates fine when using the Send Test and Verify Merge Fields, but not using the button.  Any ideas?

Thanks.

  • June 08, 2010
  • Like
  • 0

I think we've narrowed this down a bit. I am using Vista Business and Outlook 2007, both latest patch. I have salesforce outlook plugin 3.3.1.2 and can cause a crash on demand.

 

If I use the button send and add to salesforce, it will crash outlook. Here's the key. If I am saving a record for a contact that I have already sync'ed to salesforce, it will NOT crash. If I save an email and do not have an outlook contact established AND synced at least once, it will crash outlook.

 

Any ideas?

  • August 20, 2009
  • Like
  • 0

Hi I have created an application on a developer account  and am in the process of writing test methods for the classes that I have written. Which are not finished.

 

In the meantime Is it possible to move the  application to the Sandbox version of my enterprise salesforce account? or can I only move it to Sandbox once all test methods have been written?

 

If it is possible how can this be done in eclipse IDE?

 

Many thanks 

 

Angus

hi all, this is my first post, made in desperation after searching to try and find this solution already discussed but no luck so far.

 

my problem is the restrictions on the behaviour of the inbuilt send email button in only lookingup contacts or person accounts. - I need to use the 'send email' functionality from my custom object (in order to merge the custom object field data into the email template) to send emails to leads as well as accounts, and I don't want to convert these leads at this stage just so that I can send them this email (I intend to automate this email being send to new leads on creation in the future).

 

I understand that I need to use a custom 'send email' button in replacement of the standard one, and the code for this button should facilitate contacts/person account and leads both being permitted in the recipient lookup.

 

has anyone built this already and can help me out?

 

thanks

As discussed in Ideas (http://ideas.salesforce.com/article/show/69729) here's a solution we have used for clients to enable customisation of the Clone button on Opportunities. This can be used to selectively choose which fields to copy and set default values:

 

For full details and the code to clone opportunity Line Items please contact me directly. We will be re-writing this in VisualForce over the coming months to make it futureproof.

 

Steps to Implement - Admins only

1. Setup -> Customize -> Opportunity -> Buttons and Links

2. Create new custom button called Clone, behaviour is Execute Javascript, Display Type Detail Page Button.

3. Paste in the code below and edit to match your requirements.

4. Remember to add the new button to the Opportunity page layout(s) and hide the original Clone button.

4. Test!

 

// Copyright 2008 BrightGen Ltd - All Rights Reserved try{ {!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")} // ** EDIT THIS QUERY TO LIST THE FIELDS YOU WANT TO COPY ** var result = sforce.connection.query("Select o.Type, o.StageName, o.Product_Type__c, o.Planned_Opportunity__c, o.MarketSector__c, o.CampaignId, o.Business_Unit__c, o.Amount, o.AccountId From Opportunity o WHERE o.Id = '{!Opportunity.Id}'"); var newOpp = result.getArray("records"); // Reset the Opp Id and reset fields to default values newOpp[0].Id = ''; newOpp[0].Name = "Clone {!Opportunity.Name}"; // ** EDIT THESE FIELDS TO SET DEFAULT ANY VALUES ** newOpp[0].StageName = "1. Prospecting"; newOpp[0].CloseDate = new Date(2099, 0, 1); var saveResult = sforce.connection.create(newOpp); if (saveResult[0].getBoolean("success")) { newOpp[0].id = saveResult[0].id; alert("Opportunity cloned without line items"); } else { alert("Failed to create clone: " + saveResult[0]); } // Refresh the page to display the new oppportunity window.location = newOpp[0].id; } catch (err) { alert (err.description ); }

 

 
Message Edited by bg_richard on 02-05-2009 07:11 AM
I am trying to create a testClass for my trigger.
Trigger:

Code:
trigger pd_check on SFDC_PTO_Request__c (before insert, before update) {

SFDC_PTO_Request__c[] opp = trigger.new;

String picklist_v = opp[0].Request_Type__c;

Double count_d_n = opp[0].Days_Off__c;

if (picklist_v == 'Personal days') {

String str = opp[0].Employee__c;
str = str.substring(0,15);

date myDate = opp[0].Request_Start_Date__c;
Integer month = myDate.month();
Integer year = myDate.year();

Double count_d;
Double count_d_b = 0;

Double del;
del = month / 3;
Date from_d;
Date to_d;


if(del <= 1) {
from_d = date.newInstance(year, 1, 1);
to_d = date.newInstance(year, 3, 31);
}
else if((del <= 2) && (del > 1)) {
from_d = date.newInstance(year, 4, 1);
to_d = date.newInstance(year, 6, 31);

}
else if((del <= 3) && (del > 2)) {
from_d = date.newInstance(year, 7, 1);
to_d = date.newInstance(year, 9, 31);
}
else if((del <= 4) && (del > 3)) {
from_d = date.newInstance(year, 10, 1);
to_d = date.newInstance(year, 12, 31);
}



for(SFDC_PTO_Request__c[] s : [SELECT Request_Start_Date__c, Request_End_Date__c, Days_Off__c FROM SFDC_PTO_Request__c WHERE Employee__c = :str AND Request_Type__c = 'Personal days' AND Request_Start_Date__c > :from_d AND Request_Start_Date__c < :to_d]) {


for(SFDC_PTO_Request__c c:s) {
Integer month_s = c.Request_Start_Date__c.month();
Integer month_e = c.Request_End_Date__c.month();
if ((month_s != month_e) && ((month_s / 3 == 1) || (month_s / 3 == 2) || (month_s / 3 == 3) || (month_s / 3 == 4)))
{
count_d_b += 1;
}
else
{
count_d_b += c.Days_Off__c;
}

}

}

count_d = count_d_b + count_d_n;

String count_d_b_t = ''+count_d_b+'';

String[] days = count_d_b_t.split('.');

if(count_d > 2) {

Trigger.new[0].OwnerId.addError('This employee already have 2 or more personal days! Every employee can have only 2 personal day\'s per quarter.');

}

}

else if(picklist_v == 'Vacation'){
//---//
String str = opp[0].Employee__c;
str = str.substring(0,15);

date myDate = opp[0].Request_Start_Date__c;
Integer month = myDate.month();
Integer year = myDate.year();

Double count_d;
Double count_d_b = 0;

Double del;
del = month / 3;
Date from_d;
Date to_d;


if(del <= 1) {
from_d = date.newInstance(year, 1, 1);
to_d = date.newInstance(year, 3, 31);
}
else if((del <= 2) && (del > 1)) {
from_d = date.newInstance(year, 4, 1);
to_d = date.newInstance(year, 6, 31);

}
else if((del <= 3) && (del > 2)) {
from_d = date.newInstance(year, 7, 1);
to_d = date.newInstance(year, 9, 31);
}
else if((del <= 4) && (del > 3)) {
from_d = date.newInstance(year, 10, 1);
to_d = date.newInstance(year, 12, 31);
}



for(SFDC_PTO_Request__c[] s : [SELECT Request_Start_Date__c, Request_End_Date__c, Days_Off__c FROM SFDC_PTO_Request__c WHERE Employee__c = :str AND Request_Type__c = 'Personal days' AND Request_Start_Date__c > :from_d AND Request_Start_Date__c < :to_d]) {


for(SFDC_PTO_Request__c c:s) {
Integer month_s = c.Request_Start_Date__c.month();
Integer month_e = c.Request_End_Date__c.month();
if ((month_s != month_e) && ((month_s / 3 == 1) || (month_s / 3 == 2) || (month_s / 3 == 3) || (month_s / 3 == 4)))
{
count_d_b += 1;
}
else
{
count_d_b += c.Days_Off__c;
}

}

}

count_d = count_d_b + count_d_n;

String count_d_b_t = ''+count_d_b+'';

String[] days = count_d_b_t.split('.');

if(count_d > 2) {

Trigger.new[0].OwnerId.addError('This employee already have 2 or more personal days! Every employee can have only 2 personal day\'s per quarter.');

}
//---//
}


}

 
Test class:
Code:
public class pd_check_test {

    public static testMethod void myUnitTest() {

    SFDC_PTO_Request__c opp = new SFDC_PTO_Request__c(Employee__c = 'a0A70000002lu6N', Request_End_Date__c = Date.newInstance(2009,01,08), Request_Start_Date__c = Date.newInstance(2009,01,01), Request_Type__c = 'Personal days', Details__c = '123456789', Date_of_Request__c = Date.newInstance(2008,12,01));

    insert opp;

    String id = opp.Employee__c;

    SFDC_PTO_Request__c[] s = [SELECT Details__c, Date_of_Request__c FROM SFDC_PTO_Request__c WHERE Employee__c = :id AND Request_Type__c = :opp.Request_Type__c AND Request_Start_Date__c = 2009-01-01 AND Request_End_Date__c = 2009-01-08 AND Details__c = '123456789' LIMIT 1];


Double count_d = 0.0;
Double count_d_b = 0.0;

Double del = 0.0;

   System.assertEquals('123456789', s[0].Details__c); 

    }
}

 My trigger only check how many days off have employee and write error if employee have 2 or more daysoff. It doesn't insert or update something. But when I try to deploy to server I can't do it, because I have only 38% coverage and I have error: "System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, This employee already have 2 or more personal days! Every employee can have only 2 personal day's per quarter.: [OwnerId]". Can somebody help me to write correct test class?

Hi Everyone,


I'm trying to deploy my first Apex trigger to PRODUCTION but not pases the validation I only made the 69% of 75%.

I don't know what I'm missing.

First I check the user who's launched the trigger. Then if is not a administrator I call the method MyMethod in the class ThisClass, and I pass the values of the Orders table who has been changed.

The class is tested and is correctly deployed.

Thanks in advance.

The code --> :

trigger Order_UPDATE on Orders (before update) {

    string userrole = UserInfo.getUserRoleId(); --> Get UserRoleId
   
    if (userrole != 'Administrator'){   --> If is not administrator enter the IF
       
        Orders[] accs = Trigger.new; --> Get the values

        This_Class.MyMethod(accs);  --> Pass it to the method
   
    }

}

  • October 09, 2008
  • Like
  • 0
Relating to the article titled The Quick Email Button in the Service & Support Blog of Successforce, I had the following query:

I'm trying to co-opt what Marco Casalaina did for a Case to create a link for an Opportunity.  I'm calling it "quick close email" which, as planned, will allow a rep to pull up our closing email template with one click from the Opportunity page. The syntax I am using follows:

Code:
location.replace('/email/author/emailauthor.jsp—retURL=/{!Opportunity.Id}&p3_lkid={!Opportunity.Id}&rtype=003&p2_lkid={!ContactId}&template_id=<your template here>');

Where "your template here" is the 15-character ID for the email template I would like to use.

Unfortunately, there's something wrong with the command -- it returns an "Unable to Access Page" message when launched from the opportunity. Doubly unfortunately, I know nothing about javascripts, so I can't troubleshoot this on my own. Any clues for me? Thx!
  • July 23, 2008
  • Like
  • 0