• Narcissu
  • NEWBIE
  • 0 Points
  • Member since 2012

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

Hi All,

 

I want to add a email button to solution page and it will works as below. Could anyone please give me some ideas how to accomplish it? Thanks a lot!

 

1. By clicking on the email button, a popup window will show up.

 

2. In the window, there are 4 fields.

 

(1) Email to

(2) Subject

(3) Text

(4) Attachment

 

3. I want to link the Solution subject automatically to the Subject line. Link the Solution Details automatically to the Text. Link the Solution attachment to the Attachment. All these fileds are modifiable on the popup window.

 

4. There are two buttons, Send and Cacnel. By giving Email address and clicking on Send, the email will be sent to the target.

 

Thanks again.

Hi,

 

I am writing the code below to update the fields on different objects. But I have a hard time writing the test code. Please have a look at the code and a 66% test code below, and please give me some ideas pointing me to the right direction.

 

Thanks in advance.

 

Main Code:

 

Trigger UpdateUpcoming on Task (after insert, after update)
{
    Set<id>AccountsIDs = new Set<id>();
    List<Account>AcctList = new List<Account>();
    
//This section will address the account

    For (task t:Trigger.new)
    {
    For (Account at:[Select id,upcoming_due__c,upcoming_due_2__c From Account where id =: t.accountid])
{

//This section will pick up the due date of the task

    If (at.upcoming_due__c == null)
        at.upcoming_due__c = date.valueof(t.activitydate);
    Else
    If (date.valueof(t.activitydate) < at.upcoming_due__c)
        at.upcoming_due__c = date.valueof(t.activitydate);
    Else
    If (date.valueof(t.activitydate) > at.upcoming_due__c)
        at.upcoming_due_2__c = date.valueof(t.activitydate);
    AcctList.add(at);
}
}

//This section will update the due date into the Upcoming Due in the corresponding Account

    update AcctList;
}

 

66% Code (Need 75% at least..):

 

@isTest
private class TestUpcomingDueDate
{
private static TestMethod void testTrigger()
{
account ac=new account(name='abc');
insert ac;
task t=new task(activitydate=system.today(),whatid=ac.id);
insert t;
update ac;
}
}


Hi,

 

I just wrote down the code below but have a hard time writing test coverage code. Can someone please write it or give me some ideas pointing me to the right direction. Thanks very much.

 

Trigger UpdateUpcoming on Task (after insert, after update)
{
    Set<id> AccountsIDs = new Set<id>();
    List<Account>AcctList = new List<Account>();
    For (task t:Trigger.new)
    {
    For (account at:[select id,upcoming_due__c,(select id,activitydate from tasks where isclosed = false and activitydate != null order by activitydate asc limit 1) from account where id =: t.accountid])
{
    If (date.valueof(t.activitydate) < at.upcoming_due__c || at.upcoming_due__c == null)
        at.upcoming_due__c = date.valueof(t.activitydate);
    If (trigger.isDelete)
        at.upcoming_due__c = null;
    AcctList.add(at);
}
}
    update AcctList;
}

Hi,

 

I am thinking about this language "If delete A, the value of A will become null."

 

Does anyone have any ideas?

 

Thanks in advance.

Hi,

 

I just finished the code below. It works fine as my expect but I have a hard time writing the test code. Can anyone please have a look at it and help me write the test code? Thanks in advance.

 

trigger UpdateUpcoming on Task (after insert, after update)
{
    Set<id> AccountIDs = new set<id>();
    list<Account> AcctList = new list<Account>();
    for(task c : Trigger.new)
    {
        for(Account at:[Select id,upcoming_due__c From Account where id =: c.accountid])
        {
            if (date.valueof(c.ActivityDate) == null)
                at.upcoming_due__c = null;
            else
            if (at.upcoming_due__c == null)
                at.upcoming_due__c = date.valueof(c.ActivityDate);
            if (date.valueof(c.ActivityDate) < at.upcoming_due__c)
                at.upcoming_due__c = date.valueof(c.ActivityDate);
            else
                at.upcoming_due__c = at.upcoming_due__c;
            AcctList.add(at);
        }
    }
    update AcctList;
}

Hi,

 

As we know, we can have multiple open tasks with different due dates at the same time.

 

Now I want to create a field in Account object, and this field will pick up the most recent due date of the multiple tasks. For example, there are two open tasks. One's due date is 1/1/2013, the other's is 2/1/2013. Since 1/1/2013 is the first task I create, it will automatically be populated into the field using the trigger below:

 

trigger UpcomingActivity on Task(after update, after insert)
{
Task b = new Task();
Set<id> AccountIDs = new set<id>();
list<Account> AcctList = new list<Account>();
for(Task c : Trigger.new)
{
for(Account at:[Select id,Upcoming_Due__c From Account where id =: c.accountid])
{
at.Upcoming_Due__c = date.valueof(c.ActivityDate);
AcctList.add(at);
}
}
update AcctList;
}

 

However, if I create another task, the new due date will override 1/1/2013. There are two issues.

 

1. If the new task due date is after the due date of the second task - 2/1/2013, the second one will be ignored.

2. If the new task due date is prior to the two existing ones, the code cannot pick the existing ones anymore. E.g. the new one is 5/1/2012, even 1/1/2013 and 2/1/2013 are in the future and never happen, they are out of the date pending flow.

 

Please give me some ideas how to make the field always show the most recent upcoming due date no matter how many open tasks I have. *Task and Opportunity are two different objects.

Hi,

 

I am trying to create a Leads report that will show me how many unique companies have been contacted by my salespersons. However, one difficulty is that if there are two leads in the same company, I cannot combine the two records (leads) into one (company).

 

Please advise and any comment is highly appreciated.

 

Thanks.

Hi,

 

I just added a new custom picklist A to the Task tab. The picklist A actually depends on the other picklist B. On B, there are two values, one is Contact, the other is Lead. My purpose is that if A is empty or set as Contact, B would be hidden or not allowed to modify. If A is Lead, then B would show up or become changeable.

 

Can anyone advise? Thanks in advance.

Hi,

 

I just added a new application from a third party into Salesforce last week. However, I tried to deploy a new trigger today but my code coverage dropped to 43%. So I ran all tests and found most of the codes from this third party failed the test methods.

 

Is there anyone who encountered this problem before? Is it possible that I installed the application incorrectly?

 

Thanks in advance.

Can anyone give me some ideas how and where to write a test method for the following code? Much thanks.

 

trigger Caseupdate on Case(after insert)
{
Case b = new Case();
Set<id> AccountIDs = new set<id>();
list<Account> AcctList = new list<Account>();
for(case c : Trigger.new)
{
for(Account at:[Select id,Last_Update__c From Account where id =: c.accountid])
{
at.Last_Update__c = date.valueof(c.createddate);
AcctList.add(at);
}
}
update AcctList;
}

Hi,

 

I just created a new trigger and am trying to push it to the production site. As I know I cannot do it unless I have 75% test coverage. However, I have tested it in Sandbox and it worked the way I need. I think it will work without code test.

 

So is it possible that I can deploy my trigger from Sandbox to Production site without any tests?

 

Any responds are much appreciated.

Hi,

 

I am a new user to Apex.

 

I am trying to write a trigger which will automatically enter the case open date to a custom date field on my Account object when anyone in my group opens a case for the client.

 

I understand the difficulty is to sync records between two objects. In both objects, I have a field called Account Name. My guess is to figure out a way to match this field in both objects and then write down a code to insert the case open date to the custom field.

 

I also copied and tried to modify the code from other users to fit my own situation, however I may get into a wrong direction. Following is the code I copied, I put it in the case object:

 

trigger Caseupdate on Case(after insert) {
Case b = new Case();
Set<Date> AccountIDs = new set<Date>();
map<Date, Account> AcctMap = new Map<Date, Account>();
for(Account c : Trigger.new){
AccountIDs.add(c.CreatedDate);
}
for(Account at:[Select a.CreatedDate
From Account a where a.CreatedDate = 'Date/Time Opened']){
AcctMap.put(at.CreatedDate, at);
}
for(Account c: Trigger.new){
if(AcctMap.contains(c.CreatedDate)){
c.Last_Update = AcctMap.get(c.CreatedDate);
}
}
}

 

Thanks in advance, any helps are much appreciated.

Hi,

 

I just wrote down the code below but have a hard time writing test coverage code. Can someone please write it or give me some ideas pointing me to the right direction. Thanks very much.

 

Trigger UpdateUpcoming on Task (after insert, after update)
{
    Set<id> AccountsIDs = new Set<id>();
    List<Account>AcctList = new List<Account>();
    For (task t:Trigger.new)
    {
    For (account at:[select id,upcoming_due__c,(select id,activitydate from tasks where isclosed = false and activitydate != null order by activitydate asc limit 1) from account where id =: t.accountid])
{
    If (date.valueof(t.activitydate) < at.upcoming_due__c || at.upcoming_due__c == null)
        at.upcoming_due__c = date.valueof(t.activitydate);
    If (trigger.isDelete)
        at.upcoming_due__c = null;
    AcctList.add(at);
}
}
    update AcctList;
}

Hi,

 

I am thinking about this language "If delete A, the value of A will become null."

 

Does anyone have any ideas?

 

Thanks in advance.

Hi,

 

I just finished the code below. It works fine as my expect but I have a hard time writing the test code. Can anyone please have a look at it and help me write the test code? Thanks in advance.

 

trigger UpdateUpcoming on Task (after insert, after update)
{
    Set<id> AccountIDs = new set<id>();
    list<Account> AcctList = new list<Account>();
    for(task c : Trigger.new)
    {
        for(Account at:[Select id,upcoming_due__c From Account where id =: c.accountid])
        {
            if (date.valueof(c.ActivityDate) == null)
                at.upcoming_due__c = null;
            else
            if (at.upcoming_due__c == null)
                at.upcoming_due__c = date.valueof(c.ActivityDate);
            if (date.valueof(c.ActivityDate) < at.upcoming_due__c)
                at.upcoming_due__c = date.valueof(c.ActivityDate);
            else
                at.upcoming_due__c = at.upcoming_due__c;
            AcctList.add(at);
        }
    }
    update AcctList;
}

Hi,

 

As we know, we can have multiple open tasks with different due dates at the same time.

 

Now I want to create a field in Account object, and this field will pick up the most recent due date of the multiple tasks. For example, there are two open tasks. One's due date is 1/1/2013, the other's is 2/1/2013. Since 1/1/2013 is the first task I create, it will automatically be populated into the field using the trigger below:

 

trigger UpcomingActivity on Task(after update, after insert)
{
Task b = new Task();
Set<id> AccountIDs = new set<id>();
list<Account> AcctList = new list<Account>();
for(Task c : Trigger.new)
{
for(Account at:[Select id,Upcoming_Due__c From Account where id =: c.accountid])
{
at.Upcoming_Due__c = date.valueof(c.ActivityDate);
AcctList.add(at);
}
}
update AcctList;
}

 

However, if I create another task, the new due date will override 1/1/2013. There are two issues.

 

1. If the new task due date is after the due date of the second task - 2/1/2013, the second one will be ignored.

2. If the new task due date is prior to the two existing ones, the code cannot pick the existing ones anymore. E.g. the new one is 5/1/2012, even 1/1/2013 and 2/1/2013 are in the future and never happen, they are out of the date pending flow.

 

Please give me some ideas how to make the field always show the most recent upcoming due date no matter how many open tasks I have. *Task and Opportunity are two different objects.

Hi,

 

I just added a new application from a third party into Salesforce last week. However, I tried to deploy a new trigger today but my code coverage dropped to 43%. So I ran all tests and found most of the codes from this third party failed the test methods.

 

Is there anyone who encountered this problem before? Is it possible that I installed the application incorrectly?

 

Thanks in advance.

Can anyone give me some ideas how and where to write a test method for the following code? Much thanks.

 

trigger Caseupdate on Case(after insert)
{
Case b = new Case();
Set<id> AccountIDs = new set<id>();
list<Account> AcctList = new list<Account>();
for(case c : Trigger.new)
{
for(Account at:[Select id,Last_Update__c From Account where id =: c.accountid])
{
at.Last_Update__c = date.valueof(c.createddate);
AcctList.add(at);
}
}
update AcctList;
}

Hi,

 

I just created a new trigger and am trying to push it to the production site. As I know I cannot do it unless I have 75% test coverage. However, I have tested it in Sandbox and it worked the way I need. I think it will work without code test.

 

So is it possible that I can deploy my trigger from Sandbox to Production site without any tests?

 

Any responds are much appreciated.

Hi,

 

I am a new user to Apex.

 

I am trying to write a trigger which will automatically enter the case open date to a custom date field on my Account object when anyone in my group opens a case for the client.

 

I understand the difficulty is to sync records between two objects. In both objects, I have a field called Account Name. My guess is to figure out a way to match this field in both objects and then write down a code to insert the case open date to the custom field.

 

I also copied and tried to modify the code from other users to fit my own situation, however I may get into a wrong direction. Following is the code I copied, I put it in the case object:

 

trigger Caseupdate on Case(after insert) {
Case b = new Case();
Set<Date> AccountIDs = new set<Date>();
map<Date, Account> AcctMap = new Map<Date, Account>();
for(Account c : Trigger.new){
AccountIDs.add(c.CreatedDate);
}
for(Account at:[Select a.CreatedDate
From Account a where a.CreatedDate = 'Date/Time Opened']){
AcctMap.put(at.CreatedDate, at);
}
for(Account c: Trigger.new){
if(AcctMap.contains(c.CreatedDate)){
c.Last_Update = AcctMap.get(c.CreatedDate);
}
}
}

 

Thanks in advance, any helps are much appreciated.