• Peter Noges
  • NEWBIE
  • 0 Points
  • Member since 2013

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

Hey community,  I'm looking to build a custom FIELD1 on every Opportunity Record in my Organization.

 

 Here is my data model:

Opportunity Object
     Opportunity Record 1
               Amount field = $5
               SerialNumber = 77

               Stage =   (stage can be equal to X, Y)

               Date_c 
     Opportunity Record 2
               Amount field =$10
               SerialNumber =77
               Date_c
     Opportunity Record 3
               Amount field = $3
               SerialNumber = 99 
               Date_c

 

I'm seeking help/advice on building the triggers for custom FIELD1.  Here are my code requirements:

I need FIELD1 to collect all Opportunities in my Org's database where any Opportunity.SerialNumber_c field matches the SerialNumber in the same Opportunity Record as FIELD1.  Furthermore, I only want to collect Opportunities where Stage = X or Y.

 

 

I then need FIELD1 to perform mathematical operations on the Amounts for all of the returned opportunities:

 

                 add Amounts if stage=X

                 subtract Amounts if stage = Y

 

Thank you everyone!  Please let me know if I can clarify anything.

-Peter

Hey community,  I'm looking to build a custom FIELD1 on every Opportunity Record in my Organization.

 

 Here is my data model:

Opportunity Object
     Opportunity Record 1
               Amount field = $5
               SerialNumber = 77

               Stage =   (stage can be equal to X, Y)

               Date_c 
     Opportunity Record 2
               Amount field =$10
               SerialNumber =77
               Date_c
     Opportunity Record 3
               Amount field = $3
               SerialNumber = 99 
               Date_c

 

I'm seeking help/advice on building the triggers for custom FIELD1.  Here are my code requirements:

I need FIELD1 to collect all Opportunities in my Org's database where any Opportunity.SerialNumber_c field matches the SerialNumber in the same Opportunity Record as FIELD1.  Furthermore, I only want to collect Opportunities where Stage = X or Y.

 

 

I then need FIELD1 to perform mathematical operations on the Amounts for all of the returned opportunities:

 

                 add Amounts if stage=X

                 subtract Amounts if stage = Y

 

Thank you everyone!  Please let me know if I can clarify anything.

-Peter

I'm currently working to create a test class and am running into a brick wall.  The test is returning an error after the first run and not iterating through.  My error is:

 

System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [ParentId]: [ParentId]

 

Class.saleIO.ioJJInit: line 336, column 9 Class.saleIOTest.IOTest: line 38, column 15 External entry point

 

The relevant code is below.  What am I doing wrong?

 

                         

 Opportunity a = [SELECT Id, Account.Id, Account.Owner.Name, Contact__r.Name, Account.BillingStreet, Account.Name,
                         Account.BillingCity, Contact__r.Email, Contact__r.Fax, Contact__r.Phone,
                         Account.BillingState, Account.BillingPostalCode, Category__c,
                         Notes__c, Display_Ad_Size_JJ__c, Display_Ad_Size_TR__c, Display_Ad_Size__c,
                         Art_Date__c, Art_Info__c, Bill_To__c, Insertion_Dates__c, Insertion_Dates_TR__c,
                         Amount, Color__c, New_Advertiser__c
                         FROM Opportunity
 WHERE id = :ApexPages.currentPage().getParameters().get('id')];

 



public PageReference ioJJInit()
{
    String xmlContent = getJJXmlString(a);
    
    Attachment attachment = new Attachment();
        attachment.Name = 'JJ_' + a.Account.Name + '_' + formatted + '.xfdf';
        attachment.ParentId = a.Account.Id;
        attachment.Body = Blob.valueof(xmlContent);
        insert attachment; /* line 336, location of the error */
    
    PageReference orgPage = new PageReference('/' + a.Account.id);
    orgPage.setRedirect(true);
    return orgPage;
}



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
@isTest
private class saleIOTest {

    static testMethod void IOTest() {

    String [] jjSizes = new String[] {'1/16', '1/2 Horizontal', '1/2 Vertical', '1/4 Horizontal', '1/4 Vertical', '1/8 Horizontal', '1/8 Vertical', '3/4', '3/8', 'Full', 'Jr.', 'TOC', null};
    
    String [] trSizes = new String[] {'1/6', '1/3 Vertical', '1/2 Horizontal', '1/2 Vertical', '1/4 Vertical', '2/3', 'Full', 'Double Truck', null};
    
    String [] mpSizes = new String[] {'1/2 Horizontal', '1/2 Vertical', '1/3 Vertical', '1/4 Vertical', '1/8 Horizontal', 'Full', '1x1', '1x2', '1x3', '2x1', '2x2', '2x3', '3x1', '3x2', '3x3', null};
    
    Date testDay = Date.parse('11/10/2011');
    
    User u = [SELECT Id FROM User WHERE name = 'Jared Baker'];
    
    Account testOrg = new Account (Name = 'Test', BillingStreet = '3580 Wilshire',
        BillingState = 'CA', BillingPostalCode = '90010');
    insert testOrg;
        
    Contact testCon = new Contact (FirstName = 'Joe', LastName = 'Tester', Email = 'jotes@jewishjournal.com', Fax = '(213) 555-0789', Phone = '(213) 555-0790', Account = testOrg);
    insert testCon;
    
    Opportunity testOpp = new Opportunity (Name = 'Test Op', Owner = u, Account = testOrg, Contact__c = testCon.ID, Category__c = 'Rockin Test', Art_Date__c = testDay,
        Notes__c = 'notes test', New_Advertiser__c = true, Bill_to__c = 'Agency', StageName = 'Won', CloseDate = testDay, Color__c = 'One');
    insert testOpp;
    System.debug('Organization ID=' + testOpp.Account.ID);

    for(Integer i = 0; i<13; i++)
    {
        testOpp.Display_Ad_Size_JJ__c = jjSizes[i];
        update testOpp;
        if(testOpp.Display_Ad_Size_JJ__c != null)
        {
            System.debug('Organization ID=' + testOpp.Account.ID);
            PageReference jjRef = new PageReference('/apex/saleIO?id=' + testOpp.id);
            Test.setCurrentPage(jjRef);
            saleIO testJJIO = new  saleIO();
              testJJIO.ioJJInit();
        }
    }
    
    testOpp.Notes__c = null;
    testOpp.New_Advertiser__c = false;
    testOpp.Bill_to__c = 'Advertiser';
    testOpp.Insertion_Dates__c = '11/10';
    update testOpp;    

  }  
}

 

Hi to all,
I sent mail from my developer edition to my mail account. It sents with my mail subject & description.Its working properly.But I am using Sandbox edition to sent a mail to my mail account. that time the subject & description values are added with "Force.com Sandbox" label.
how to remove the "force.com sandbox" Label???

Thanks,
Krishna.