• Depton
  • NEWBIE
  • 480 Points
  • Member since 2011

  • Chatter
    Feed
  • 19
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 156
    Questions
  • 268
    Replies

Hi,

 

Is there is any option in informatica dataloader for importing data from salesforce to salesforce.

 

Explanantion:

 

Was using Group Edition earlier now want import all the data with activities  from Group edtition to Professional edition.

 

If yes can anyone guide:

 

This is Urgent!!

 

  • July 15, 2011
  • Like
  • 0

Hello,

 

I have an issue with Web-to-lead form. It doesn't seem to work for me using salesforce (sandbox) default generated code.

here is a code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<title>SFDC Form Test</title>
<head>
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">
</head>
<body>
<div>
<form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST">

<input type=hidden name="oid" value="MY VALUE">
<input type=hidden name="retURL" value="MY VALUE">

<label for="email">Email</label><input  id="email" maxlength="80" name="email" size="20" type="text" /><br>

<label for="first_name">First Name</label><input  id="first_name" maxlength="40" name="first_name" size="20" type="text" /><br>

<label for="last_name">Last Name</label><input  id="last_name" maxlength="80" name="last_name" size="20" type="text" /><br>

<input type="submit" name="submit">
</form>
</div>
</body>
</html>

 

Now runnig above code, It does returing a retURL. But when i search the record; it's pop up with there are no matching found message. Can someone post positive reply for my error?

 

Thanks

Hi all,

 

 

I have a custom button on the opportunites related list. So users can create a new Milestone from there.

 

When users click on NEW the select record type screen show up, which is what i want.

Then i want to prepopulate 3 fields: Account, Opportunity and Owner

 

It's working fine except for the Opportunity custom look up field. id: 0N30000007CKjj

 

I have tried

 

/setup/ui/recordtypeselect.jsp?ent=01I30000001ncx8&=
{!Opportunity.Name}&
CF00N30000007CKjj_lkid={!Opportunity.Id}&

 and

 

/setup/ui/recordtypeselect.jsp?ent=01I30000001ncx8&=
CF00N30000007CKjj={!Opportunity.Name}&
CF00N30000007CKjj_lkid={!Opportunity.Id}&

 

Without success. it works fine for the other 2 fields though (account and owner)

Any ideas?

 

Here is the full code. Thanks

 

/setup/ui/recordtypeselect.jsp?ent=01I30000001ncx8&=
{!Opportunity.Name}&
CF00N30000007CKjj_lkid={!Opportunity.Id}&
CF00N30000007CKiW={!Opportunity.Account_Name__c}&
CF00N30000007CKiW_lkid={!Opportunity.AccountId}&
CF00N30000007CKjk={!$User.FirstName}%20{!$User.LastName}&
CF00N30000007CKjk_lkid={!$User.Id}&
save_new_url=%2Fa2L%2Fe%3FretURL%3D%252Fa2L%252Fo&retURL=/{!Opportunity.Id}

 

  • April 12, 2013
  • Like
  • 0

Hi,

 

is sites.com the only way to get unlimited cases created per day with attachments that are around 15-18mb?

 

I see limitations on Email2case and in On demand but can't' find this info

Thank you

  • March 22, 2013
  • Like
  • 0

I am trying to populate Primary_Contact__c ( contact look up field in opportunities) when converting a lead.

 

The following code populates the standard opportunity contact role with the lead  name and makes the lead as the primary contact.

 

I am looking for a similar behavior but instead of populating the contact role,  automatically populate the Primary_Contact__c field with the Lead/Contact name

 

What should I change to get the opportunity - Primary_Contact__c ?

Thanks

 

 

trigger trigMapFields on Lead (before update) {

    
    List<Id> conAcctId = new List<Id>(); // List of the converted Account IDs
    List<Id> conOppId = new List<Id>(); // List of the converted Opportunity IDs
    Map<Id,String> leadStatus = new Map<Id,String>(); // Map of the converted Contact ID and the Lead Status
    Map<Id,Id> leadContactMap = new Map<Id,Id>(); // Map of the Lead ID and the converted contact Id (for expense)
    Map<Id,Id> leadAccountMap = new Map<Id,Id>(); // Map of the Lead ID and the converted account Id (for expense)


    for(Lead lead : Trigger.new) {
        if (lead.IsConverted) {
            leadStatus.put(lead.ConvertedContactId,lead.Status);
            conAcctId.add(lead.ConvertedAccountId);
            if (lead.ConvertedOpportunityId != null) {
                conOppId.add(lead.ConvertedOpportunityId);
            }
        leadContactMap.put(lead.ID,lead.ConvertedContactId);
        leadAccountMap.put(lead.ID,lead.ConvertedAccountId);
        }
    }

    // If an opportunity was created, need to assign the contact role as primary
    List<OpportunityContactRole> oppConRole = [select ContactID from OpportunityContactRole where OpportunityId IN :conOppId];
    for ( OpportunitycontactRole cr :oppConRole) {
        cr.IsPrimary = true;
    }
    update oppConRole;

}

 

  • October 04, 2012
  • Like
  • 0

Hi,

 

I have a trigger that counts the number of close cases for each contact, now I want to send an email alert each times when the close case is , 1,3,6,9,12,15.....etc....

 

 

Any ideas on setting this rule without having to write all numbers until 500!!!

Any tricks??

 

Thank you

  • September 25, 2012
  • Like
  • 0
/* Provide summary of Number of Cases on Contacts record */ 

trigger CaseSumTrigger on Case(after delete, after insert, after undelete, 
after update) {

    Case [] cas;
    if (Trigger.isDelete) 
        cas= Trigger.old;
    else
        cas= Trigger.new;

    // get list of Contacts
    Set<ID> contIds = new Set<ID>();
    for (Case cs : cas) {
            contIds.add(cs.ContactId);
    }
    
    Map<ID, Case> CasesForContacts = new Map<ID, Case>([select Id
                                                            ,ContactId
                                                            from Case
                                                            where ContactId in :contIds]);

    Map<ID, Contact> contToUpdate = new Map<ID, Contact>([select Id
                                                                 ,items__c
                                                                  from Contact
                                                                  where Id in :contIds]);
                                                                 
    for (Contact  cont: contToUpdate.values()) {
        Set<ID> casIds = new Set<ID>();
        for (Case cs : CasesForContacts.values()) {
            if (cs.ContactId == cont.Id)
                casIds.add(cs.Id);
        }
        if (cont.items__c != casIds.size())
            cont.items__c = casIds.size();
    }

    update contToUpdate.values();

}

 

How/Where do i add the loop to get only CLOSED cases?

Thank you!

 

  • September 25, 2012
  • Like
  • 0

Hi all,

 

 

I cannot create a Roll-Up Summaryfield on Contats to see the total of close cases in the contact detail page.

 

Any sample code for this?

 

Tank you

  • September 25, 2012
  • Like
  • 0

 


Hi,

 

I am trying to set up a workflow email alert to be send to the owner of the record 7 days before the Due Date (date/time field ) if the picklist value Attending__c is not equals  to "Yes"

 

Thank you

 

 

  • September 06, 2012
  • Like
  • 0

Hi guys,

 

Hi Guys, I have a after insert trigger on the Opportunity object to auto-update some fields.

via a VF page and a custom button it populates child opportunities.

 

I do have also a validation rule which based on Salesforce info it is supposed to be executed before the after insert trigger. But I am getting the following error

 

Update failed. First exception on row 0 with id 0063000000nF86gAq; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OpportunityAfter: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 00k3000000K0Ra4ABF; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please check!  Monthly Revenue is missing from some products: [] Trigger.OpportunityAfter: line 90, column 41: [] 

 Any idea on how to get only the validation rule error? or what to change/review on the trigger?

 

Thanks

 

  • September 03, 2012
  • Like
  • 0

HI Guys,

 

 

You can avoid using the server name by using relative link : https://na1.salesforce.com/00Oz0000000xxxx

 

should not include https://na1.salesforce.com. Instead we should use:
/00Oz0000000xxxx

 

Any idea on how this works for content files??

So How do I replace this to avoid the NA1 Server?

 

https://c.na1.content.force.com/servlet/servlet.FileDownload?file=00Oz0000000xxxx

 

Thank you

  • August 02, 2012
  • Like
  • 0

Hi,

I have a custom Object “B” and Account is the master detail

When I submit an Account for Approval, Salesforce blocks any related list that has a master detail to the Account. So I no user can edit “B”

I can change the master detail to a look up field BUT then “B” won’t be controlled by parent but, "Private", "Read-only" OR "Public”

Is there any way to change relationship from a Master Detail to Look up and keep security as per account visibility? so "Controlled by Parent”

Thank you

Hi,

 

I am running crazy trying to calculate age since a custom date/time field gets populated. Avoiding weekends.

I thought I founded the formula but is giving me some errors.

 

Anyone has a trigger that counts the hours bases on a date/time field?. Avoiding weekends.

 

So it will count 24 hours from Monday to Friday.

Zero hours Saturday and Sunday!

 

Basically once I select Status A, I populate a custom date/time field with NOW(), and then I want the Age Status to tell me how many hours the field is with that status.

If I change the status I want the field to be Zero again....Avoiding weekends

 

Anyone had this issue before?

Thanks.:)

Hi,

 

I am running crazy trying to calculate age since a custom date/time field gets populated. Avoiding weekends.

I thought I founded the formula but is giving me some errors.

 

Anyone has a formula that counts the hours bases on a date/time field?. Avoiding weekends.

 

So it will count 24 hours from Monday to Friday.

Zero hours Saturday and Sunday!

 

Thanks.

Hi,

 

Anyone has an idea to avouid the error: Thanks!!:)

 

IF( date1__c > 2, 
IMAGE("/img/samples/color_red.gif", "red", 30, 30),
IF( date1__c > 1,
IMAGE("/img/samples/color_yellow.gif", "yellow", 30, 30),
IMAGE("/img/samples/color_green.gif", "green", 30, 30)))

 Error: Compiled formula is too big to execute (5,509 characters). Maximum size is 5,000 characters

 

 

Hi, I am trying to create a time depending workflow avoiding weekends, bank holidays, etc...

 

I have found this interesting post:

http://forcemonkey.blogspot.com/2009/11/calculating-business-hours.html

 

Anyone came across to the same issue/ situation?

 

Thanks!:)

I am trying to create a workflow to notify the contact when the case owner changes from the queue to an specific user.

 

I am trying something like

 

 

AND( 
ISCHANGED(OwnerId),
NOT(OwnerId  = "00G30000002CJIA"))

 but getting this error:

 

Function ISCHANGED may not be used in this type of formula

 

Any idea on how can I create this workflow? Thank you

Any way to mass upload chatter pics.

I was looking at the Chatter Rest Api documentation but it's not clear for me?

 

Thank you.

Hi,

 

I have a trigger that automatically creates a related contact when a user is created.

Now I  want to autopopulate some user fields when the contact records is populated.

 

So if fields AA and BB in contact records are filled in I would like to have this info on the related user.

 

Any tips, as formulas didn't work.

How should the trigger for this should look, any sample? Thank you

Hi, when I do create a custom object record, I automatically create an event.

From the custom object record people click on a custom link and then,  an email is sent to the owner so he/she knows who is attending the event.

Is there any way to automatically add attendees to the event?

I have read that this cannot be done through apex, is it true? any workaround? maybe creating a VF page?

 

Thank you

I am just writing a basic trigger and I'd like to change the related to field, and populate the event type field.

 

trigger Event on Web__c (after insert) {     
List<Event> ev = new List<Event>();
    for (Web__C newWeb: Trigger.New)
         if (newWeb.Name !='1'){
                 ev.add (new Event(
                     Subject = newWeb.Name,
                     WhoId= newWeb.Trainer__c,
                     WhatId = newWeb.id,
                     StartDateTime= newWeb.Web_Start_Date__c,
                     EndDateTime= newWeb.Web_End_Date__c));   
         }
   insert ev;
 }

 Y tried without success

 

Owner(related to)= newWeb.Ownerid

Type = 'Web' (Web is one of the event picklist values and has no relaed field in the Web object)

 

Any ideas??

 

Thank you!

 

 

 

 

 

Hi,

 

I have the following custom link that automatically sends and email to the AccDev Manager.

 

location.replace('/email/author/emailauthor.jsp?retURL=/{!AccDev__c.Id}&p3_lkid={!AccDev__c.Id}&rtype=003&p2_lkid={!AccDev__c.DevManagerId__c}&template_id=00X30000001VixC&p5=&save=1');

 I would like to replace this custom link/detail page button for a custom forrmula field or a VF component so users avoid to go to each record and click on the button and they can do it from a list view but individually

 

So I am thinking to replace it for a VF component in the page (if it is possible to add this component in the list view) so if the user click on Attend for a specific AccDevt will refresh the page and the email will be sent to the DevManager and it will be recorder in the activity related list of the AccDev

 

 

Thank you!

Hi,

 

Is there any way to refresh a Dynamic Dashboard?....

 

This is an amazing feature but have to refresh them manually is pretty annoying

Thank you!:)

  • January 13, 2012
  • Like
  • 1

I am trying to populate Primary_Contact__c ( contact look up field in opportunities) when converting a lead.

 

The following code populates the standard opportunity contact role with the lead  name and makes the lead as the primary contact.

 

I am looking for a similar behavior but instead of populating the contact role,  automatically populate the Primary_Contact__c field with the Lead/Contact name

 

What should I change to get the opportunity - Primary_Contact__c ?

Thanks

 

 

trigger trigMapFields on Lead (before update) {

    
    List<Id> conAcctId = new List<Id>(); // List of the converted Account IDs
    List<Id> conOppId = new List<Id>(); // List of the converted Opportunity IDs
    Map<Id,String> leadStatus = new Map<Id,String>(); // Map of the converted Contact ID and the Lead Status
    Map<Id,Id> leadContactMap = new Map<Id,Id>(); // Map of the Lead ID and the converted contact Id (for expense)
    Map<Id,Id> leadAccountMap = new Map<Id,Id>(); // Map of the Lead ID and the converted account Id (for expense)


    for(Lead lead : Trigger.new) {
        if (lead.IsConverted) {
            leadStatus.put(lead.ConvertedContactId,lead.Status);
            conAcctId.add(lead.ConvertedAccountId);
            if (lead.ConvertedOpportunityId != null) {
                conOppId.add(lead.ConvertedOpportunityId);
            }
        leadContactMap.put(lead.ID,lead.ConvertedContactId);
        leadAccountMap.put(lead.ID,lead.ConvertedAccountId);
        }
    }

    // If an opportunity was created, need to assign the contact role as primary
    List<OpportunityContactRole> oppConRole = [select ContactID from OpportunityContactRole where OpportunityId IN :conOppId];
    for ( OpportunitycontactRole cr :oppConRole) {
        cr.IsPrimary = true;
    }
    update oppConRole;

}

 

  • October 04, 2012
  • Like
  • 0

Hi,

 

I have a trigger that counts the number of close cases for each contact, now I want to send an email alert each times when the close case is , 1,3,6,9,12,15.....etc....

 

 

Any ideas on setting this rule without having to write all numbers until 500!!!

Any tricks??

 

Thank you

  • September 25, 2012
  • Like
  • 0
/* Provide summary of Number of Cases on Contacts record */ 

trigger CaseSumTrigger on Case(after delete, after insert, after undelete, 
after update) {

    Case [] cas;
    if (Trigger.isDelete) 
        cas= Trigger.old;
    else
        cas= Trigger.new;

    // get list of Contacts
    Set<ID> contIds = new Set<ID>();
    for (Case cs : cas) {
            contIds.add(cs.ContactId);
    }
    
    Map<ID, Case> CasesForContacts = new Map<ID, Case>([select Id
                                                            ,ContactId
                                                            from Case
                                                            where ContactId in :contIds]);

    Map<ID, Contact> contToUpdate = new Map<ID, Contact>([select Id
                                                                 ,items__c
                                                                  from Contact
                                                                  where Id in :contIds]);
                                                                 
    for (Contact  cont: contToUpdate.values()) {
        Set<ID> casIds = new Set<ID>();
        for (Case cs : CasesForContacts.values()) {
            if (cs.ContactId == cont.Id)
                casIds.add(cs.Id);
        }
        if (cont.items__c != casIds.size())
            cont.items__c = casIds.size();
    }

    update contToUpdate.values();

}

 

How/Where do i add the loop to get only CLOSED cases?

Thank you!

 

  • September 25, 2012
  • Like
  • 0

Hi all,

 

 

I cannot create a Roll-Up Summaryfield on Contats to see the total of close cases in the contact detail page.

 

Any sample code for this?

 

Tank you

  • September 25, 2012
  • Like
  • 0

 


Hi,

 

I am trying to set up a workflow email alert to be send to the owner of the record 7 days before the Due Date (date/time field ) if the picklist value Attending__c is not equals  to "Yes"

 

Thank you

 

 

  • September 06, 2012
  • Like
  • 0

Hi .

I have created a visualforce email template and using it in the workflow email  alert. When i test the template it works fine. But when I test it with a different user wh o is not admin, i am seeing blank emails. Any ideas of why this is causing an issue?

  • September 05, 2012
  • Like
  • 0

Hi,

 

I am running crazy trying to calculate age since a custom date/time field gets populated. Avoiding weekends.

I thought I founded the formula but is giving me some errors.

 

Anyone has a formula that counts the hours bases on a date/time field?. Avoiding weekends.

 

So it will count 24 hours from Monday to Friday.

Zero hours Saturday and Sunday!

 

Thanks.

Hi everyone,

 

I am trying to set up a field update to determine the correct  links to be sent using ISPICKVAL.

 

I have three links (survey links) that has to be sent based on which one you select from the drop down box.

 

For example if you select Germany, it should send the survey link in german language, if you select England, English and so on.

 

Many thanks,

 

  • June 26, 2012
  • Like
  • 0

Hi,

 

Anyone has an idea to avouid the error: Thanks!!:)

 

IF( date1__c > 2, 
IMAGE("/img/samples/color_red.gif", "red", 30, 30),
IF( date1__c > 1,
IMAGE("/img/samples/color_yellow.gif", "yellow", 30, 30),
IMAGE("/img/samples/color_green.gif", "green", 30, 30)))

 Error: Compiled formula is too big to execute (5,509 characters). Maximum size is 5,000 characters

 

 

I am trying to create a workflow to notify the contact when the case owner changes from the queue to an specific user.

 

I am trying something like

 

 

AND( 
ISCHANGED(OwnerId),
NOT(OwnerId  = "00G30000002CJIA"))

 but getting this error:

 

Function ISCHANGED may not be used in this type of formula

 

Any idea on how can I create this workflow? Thank you

1.Create a field for business days using a number formula field. Use the following formula to calculate minus weekends.

 

CASE( 
MOD(DATEVALUE(CreatedDate) - DATE(1900, 1, 7), 7), 
0, (TODAY() - DATEVALUE(CreatedDate)) - 1 - FLOOR((TODAY() - DATEVALUE(CreatedDate))/7)*2, 
1, (TODAY() - DATEVALUE(CreatedDate)) - FLOOR((TODAY() - DATEVALUE(CreatedDate))/7)*2, 
2, (TODAY() - DATEVALUE(CreatedDate)) - FLOOR((TODAY() - DATEVALUE(CreatedDate))/7)*2, 
3, (TODAY() - DATEVALUE(CreatedDate)) - FLOOR((TODAY() - DATEVALUE(CreatedDate))/7)*2, 
4, (TODAY() - DATEVALUE(CreatedDate)) - FLOOR((TODAY() - DATEVALUE(CreatedDate))/7)*2, 
5, (TODAY() - DATEVALUE(CreatedDate)) - 2 - FLOOR((TODAY() - DATEVALUE(CreatedDate))/7)*2, 
6, (TODAY() - DATEVALUE(CreatedDate)) - 2 - FLOOR((TODAY() - DATEVALUE(CreatedDate))/7)*2, 
null)

 

 

2.Create a date/time field for the current date/time 

 

3.Create workflow rule to update this field every time it is edited with formula below

 

Now()

 

 

4.Create a number formula field to calculate the age difference of the case today. I used the formula

 

VALUE( MID( TEXT( NOW__c ), 12, 2 ) ) - VALUE( MID( TEXT( CreatedDate ), 12, 2 ) )

 

 

5.Create a number formula field for the business hours of the company ie. 8 hrs

 

 

 

6.Create a number formula field to calculate the total age of the case in business hours

 

(business_days__c * business_hours ) + age_difference_of_case

 

I think I might be a little bit blind here, because I cannot see why a validation rule should be throwing up an exception.

 

The only thing that I can fathom that would create the error would be if the associated test class was setting an illegal date - i.e. one that is not on the first of the month.

 

However, the only Start Dates set are:

Start_Date__c=date.newinstance(2011, 1, 1)

Start_Date__c=date.newinstance(2011, 7, 1)

which are both on the first of the month!



 

So, first, the error:

Error:Apex trigger ItemandIPISubscriptionLinks caused an unexpected exception, contact your administrator: ItemandIPISubscriptionLinks: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a092000000KcY3sAAF; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, The Start Date must be the first of the month.: [Start_Date__c]: Trigger.ItemandIPISubscriptionLinks: line 223, column 1

 Now the validation rule:

AND (
NOT ( ISBLANK ( Start_Date__c )),
DAY ( Start_Date__c ) > 1
)

 Now the Trigger:

trigger ItemandIPISubscriptionLinks on Item__c (after update, after insert) {

Set<Id> itemIds = new Set<Id>();
Set<Id> eventIds = new Set<Id>();
Set<Id> itemCountIds = new Set<Id>();


//Put the list value ids in the set
if (Trigger.isUpdate){
    for (Integer i = 0; i < Trigger.new.size(); i++){
        if (Trigger.new[i].RecordTypeId == '01220000000AGp1' &&
            ((Trigger.new[i].Probability__c == 100 && Trigger.new[i].Cancelled__c == FALSE 
            && 
            ((Trigger.old[i].Probability__c <> 100 || Trigger.old[i].Cancelled__c <> FALSE)
            || 
            (Trigger.new[i].Start_Date__c <> Trigger.old[i].Start_Date__c ||
            Trigger.new[i].Term__c <> Trigger.old[i].Term__c ||
            Trigger.new[i].Full_Amount2__c <> Trigger.old[i].Full_Amount2__c)))
            
            ||
            
            (Trigger.new[i].Probability__c <> 100 || Trigger.new[i].Cancelled__c <> FALSE) 
            && 
            Trigger.old[i].Probability__c == 100 && Trigger.old[i].Cancelled__c == FALSE)
           )
        {
            itemIds.add(Trigger.new[i].id);
            eventIds.add(Trigger.new[i].Event_Issue__c);
        }
    }
}
if (Trigger.isInsert){
    for (Integer i = 0; i < Trigger.new.size(); i++){
        if (Trigger.new[i].RecordTypeId == '01220000000AGp1' && Trigger.new[i].Probability__c == 100 && Trigger.new[i].Cancelled__c == FALSE) {
            itemIds.add(Trigger.new[i].id);
            eventIds.add(Trigger.new[i].Event_Issue__c);
        }
    }
}

IPI_Subscription__c[] sub =
[SELECT Id, Event_Issue__c, Month__c FROM IPI_Subscription__c WHERE Event_Issue__c IN :eventIds];

Item__c[] ite =
[SELECT Id, Event_Issue__c, Probability__c, Cancelled__c, Start_Date__c, End_Date__c, Term__c, Amount_Formula__c, Monthly_Amount__c, Jan_Amount__c, Feb_Amount__c, Mar_Amount__c,
Apr_Amount__c, May_Amount__c, Jun_Amount__c, Jul_Amount__c, Aug_Amount__c, Sep_Amount__c, Oct_Amount__c, 
Nov_Amount__c, Dec_Amount__c FROM Item__c WHERE Event_Issue__c IN :eventIds];

for (IPI_Subscription__c subs :sub){
    Decimal amou = 0;
    Integer n = 0;

for (Item__c items :ite){
    
    if (items.Probability__c == 100 && items.Cancelled__c == FALSE){
    
    //January 
        if (subs.Month__c == 'Jan'){
            if (items.Jan_Amount__c>0){
                items.Jan_Subscription__c = subs.Id;
                amou += items.Monthly_Amount__c;
                n += 1;
                subs.Amount_Sold2__c = amou;
            }
            else
                items.Jan_Subscription__c = NULL;
        }

    //February
        else if (subs.Month__c == 'Feb'){
            if (items.Feb_Amount__c>0){
                items.Feb_Subscription__c = subs.Id;
                amou += items.Monthly_Amount__c;
                subs.Amount_Sold2__c = amou;
                n += 1;
            }
            else
                items.Feb_Subscription__c = NULL;
        }
       
    //March
        else if (subs.Month__c == 'Mar'){
            if (items.Mar_Amount__c>0){
                items.Mar_Subscription__c = subs.Id;
                amou += items.Monthly_Amount__c;
                subs.Amount_Sold2__c = amou;
                n += 1;
            }
            else
                items.Mar_Subscription__c = NULL;
        }
    
    //April
        else if (subs.Month__c == 'Apr'){
            if (items.Apr_Amount__c>0){
                items.Apr_Subscription__c = subs.Id;
                amou += items.Monthly_Amount__c;
                subs.Amount_Sold2__c = amou;
                n += 1;
            }
            else
                items.Apr_Subscription__c = NULL;
        }
    
    //May
        else if (subs.Month__c == 'May'){
            if (items.May_Amount__c>0){
                items.May_Subscription__c = subs.Id;
                amou += items.Monthly_Amount__c;
                subs.Amount_Sold2__c = amou;
                n += 1;
            }
            else
                items.May_Subscription__c = NULL;
        }
    
    //Jun
        else if (subs.Month__c == 'Jun'){
            if (items.Jun_Amount__c>0){
                items.Jun_Subscription__c = subs.Id;
                amou += items.Monthly_Amount__c;
                subs.Amount_Sold2__c = amou;
                n += 1;
            }
            else
                items.Jun_Subscription__c = NULL;
        }
    
    //July
        else if (subs.Month__c == 'Jul'){
            if (items.Jul_Amount__c>0){
                items.Jul_Subscription__c = subs.Id;
                amou += items.Monthly_Amount__c;
                subs.Amount_Sold2__c = amou;
                n += 1;
            }
            else
                items.Jul_Subscription__c = NULL;
        }
    
    //August
        else if (subs.Month__c == 'Aug'){
            if (items.Aug_Amount__c>0){
                items.Aug_Subscription__c = subs.Id;
                amou += items.Monthly_Amount__c;
                subs.Amount_Sold2__c = amou;
                n += 1;
            }
            else
                items.Aug_Subscription__c = NULL;
        }
    
    //September
        else if (subs.Month__c == 'Sep'){
            if (items.Sep_Amount__c>0){
                items.Sep_Subscription__c = subs.Id;
                amou += items.Monthly_Amount__c;
                subs.Amount_Sold2__c = amou;
                n += 1;
            }
            else
                items.Sep_Subscription__c = NULL;
        }
    
    //October
        else if (subs.Month__c == 'Oct'){
            if (items.Oct_Amount__c>0){
                items.Oct_Subscription__c = subs.Id;
                amou += items.Monthly_Amount__c;
                subs.Amount_Sold2__c = amou;
                n += 1;
            }
            else
                items.Oct_Subscription__c = NULL;
        }
    
    //November
        else if (subs.Month__c == 'Nov'){
            if (items.Nov_Amount__c>0){
                items.Nov_Subscription__c = subs.Id;
                amou += items.Monthly_Amount__c;
                subs.Amount_Sold2__c = amou;
                n += 1;
            }
            else
                items.Nov_Subscription__c = NULL;
        }
    
    //December
        else if (subs.Month__c == 'Dec'){
            if (items.Dec_Amount__c>0){
                items.Dec_Subscription__c = subs.Id;
                amou += items.Monthly_Amount__c;
                subs.Amount_Sold2__c = amou;
                n += 1;
            }
            else
                items.Dec_Subscription__c = NULL;
        }
    }
    
    else {
    items.Jan_Subscription__c = NULL;
    items.Feb_Subscription__c = NULL;
    items.Mar_Subscription__c = NULL;
    items.Apr_Subscription__c = NULL;
    items.May_Subscription__c = NULL;
    items.Jun_Subscription__c = NULL;
    items.Jul_Subscription__c = NULL;
    items.Aug_Subscription__c = NULL;
    items.Sep_Subscription__c = NULL;
    items.Oct_Subscription__c = NULL;
    items.Nov_Subscription__c = NULL;
    items.Dec_Subscription__c = NULL;
    }
}
    
    subs.Number_Sold__c = n;
    
}

update sub;
update ite;





}

 

And finally the Test class:

@isTest
private class TestIPITriggers {

static TestMethod void TestTotalItemAmount(){

Account company = new Account(Name='test company', BillingStreet='123 red', BillingCity='London', BillingPostalCode='123fgh', BillingCountry='United Kingdom');
insert company;

Contact contact = new Contact(LastName = 'test', AccountId = company.Id, Email = 'test@test.com', Phone='1234');
insert contact;

Opportunity deal = new Opportunity(Name='autofill', AccountId = company.Id, RecordTypeId ='01220000000AGqi', Contact_Delegate__c=contact.Id, CloseDate=date.today(), 
                    StageName='Closed - Awaiting Approval', Invoice_Address__c='Company', Address_Invoice_to_contact_above__c='Yes', 
                    Voucher_Copy_Address__c='Company', Address_Voucher_Copy_to_contact_above__c='Yes');
insert deal;

Issue_Year__c event = new Issue_Year__c(Name='LC11a', Date__c=date.newinstance(2011, 1, 1), Description__c='Leaders Council 2011', SUN_T3_Code__c = 'LC2011');
insert event;

IPI_Subscription__c subscription1 = new IPI_Subscription__c(Event_Issue__c=event.Id, Month__c='Jan', Name='LCJan11a');
insert subscription1;

IPI_Subscription__c subscription2 = new IPI_Subscription__c(Event_Issue__c=event.Id, Month__c='Feb', Name='LCFeb11a');
insert subscription2;

IPI_Subscription__c subscription3 = new IPI_Subscription__c(Event_Issue__c=event.Id, Month__c='Mar', Name='LCMar11a');
insert subscription3;

IPI_Subscription__c subscription4 = new IPI_Subscription__c(Event_Issue__c=event.Id, Month__c='Apr', Name='LCApr11a');
insert subscription4;

IPI_Subscription__c subscription5 = new IPI_Subscription__c(Event_Issue__c=event.Id, Month__c='May', Name='LCMay11a');
insert subscription5;

IPI_Subscription__c subscription6 = new IPI_Subscription__c(Event_Issue__c=event.Id, Month__c='Jun', Name='LCJun11a');
insert subscription6;

IPI_Subscription__c subscription7 = new IPI_Subscription__c(Event_Issue__c=event.Id, Month__c='Jul', Name='LCJul11a');
insert subscription7;

IPI_Subscription__c subscription8 = new IPI_Subscription__c(Event_Issue__c=event.Id, Month__c='Aug', Name='LCAug11a');
insert subscription8;

IPI_Subscription__c subscription9 = new IPI_Subscription__c(Event_Issue__c=event.Id, Month__c='Sep', Name='LCSep11a');
insert subscription9;

IPI_Subscription__c subscription10 = new IPI_Subscription__c(Event_Issue__c=event.Id, Month__c='Oct', Name='LCOct11a');
insert subscription10;

IPI_Subscription__c subscription11 = new IPI_Subscription__c(Event_Issue__c=event.Id, Month__c='Nov', Name='LCNov11a');
insert subscription11;

IPI_Subscription__c subscription12 = new IPI_Subscription__c(Event_Issue__c=event.Id, Month__c='Dec', Name='LCDec11a');
insert subscription12;

Item__c item1 = new Item__c(Name='.', Opportunity__c = deal.Id, Full_Amount2__c=6000, RecordTypeId='01220000000AGp1', Probability__c=100, 
                Event_Issue__c = event.Id, Start_Date__c=date.newinstance(2011, 1, 1), Term__c=6, Payment_Terms__c='28 days');
insert item1;

Item__c[] items = [SELECT Id, Amount__c, Amount_Formula__c, Jan_Subscription__r.Name, Jan_Amount__c, Event_Issue__r.Name FROM Item__c WHERE Event_Issue__r.Name = 'LC11a'];

for (Item__c it :items){
system.assertEquals(it.Jan_Amount__c, 1000);
system.assertEquals(it.Jan_Subscription__r.Name, 'LCJan11a');
}

item1.Start_Date__c=date.newinstance(2011, 7, 1);
update item1;

item1.Probability__c = 50;
update item1;

delete item1;


}

}

 

 

Hope you can help!