• aqueller
  • NEWBIE
  • 24 Points
  • Member since 2011

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

Hi,

 

This may not be quite the best discussion board for my question, but I couldn't find a better one.

 

I am meeting with a customer who currently uses ACT 2011, regarding deployment of Salesforce.

Does anyone have material that compares the Salesforce with ACT?

 

        Thank you in advance.

 

                   aqueller

I am looking for help on the following issue.

 

I have a trigger that is supposed to delete certain types of opportunities, identified

by a custom field   PDS__Document_Type__c  as a 'Sales Order'.

 

My code is as follows:

 

trigger DeleteSO on Opportunity(after update)
{
   // Create a list of Opportunities, newOpps, to make it bulk fiendly
   List<Opportunity> newOpps = new List<Opportunity>();

   for(Opportunity o : Trigger.new)
   {
      // If it is a sales order, delete it
      if(o.PDS__Document_Type__c == 'Sales Order')
      {
          delete o;
      }
   }

   update newOpps;
}
      

 When I run it, I get an error:   DML statement cannot operate on trigger.new or trigger.old

 

Why do I get this error?

How can I fix it?



           Thx,

 

                      aqueller

 

 

 

 

I have an opportunity with a number of product line items.

I want to find the name of a product in a given line item (oldProdList[i] is an OpportunityLineItem).

 

I use the following query:

 

String ProdName = [SELECT Name FROM Product2 WHERE (id = :[SELECT Product2Id FROM PriceBookEntry WHERE ID = :oldProdList[i].PricebookEntryId].Id)];

 I get the error: Illegal assignment from LIST<Product2> to String .

 

I have the following questions:

 

1. Name is defined as a string field in Product2. Why am I getting this error?

2. Is it the right query structure for obtaining the product name?

 

            Thanks,

 

                       aqueller

I am setting an opportunity closing date as being 90 days from today ( date.today( ) ).

 

At a later point I create a string with the month name of the closing date, using the following code:

if (NewOpp.CloseDate.month() == 1) {monthName = 'Jan';}
 174	   // else if (NewOpp.CloseDate.month() == 2) {monthName = 'Feb';}
 175	   // else if (NewOpp.CloseDate.month() == 3) {monthName = 'Mar';}
 176	   // else if (NewOpp.CloseDate.month() == 4) {monthName = 'Apr';}
 177	   // else if (NewOpp.CloseDate.month() == 5) {monthName = 'May';}
 178	   // else if (NewOpp.CloseDate.month() == 6) {monthName = 'Jun';}
 179	   // else if (NewOpp.CloseDate.month() == 7) {monthName = 'Jul';}
 180	   // else if (NewOpp.CloseDate.month() == 8) {monthName = 'Aug';}
 181	   // else if (NewOpp.CloseDate.month() == 9) {monthName = 'Sep';}
 182	   // else if (NewOpp.CloseDate.month() == 10) {monthName = 'Oct';}
 183	   // else if (NewOpp.CloseDate.month() == 11) {monthName = 'Nov';}
 184	   // else {monthName = 'Dec';}

 The problem is that when I test the code it comes below 75% coverage,

given that we are in October and the close date of the next opportunity is in January.

 

How can I modify the test program to get full coverage? Is there a way to simulate

a system time for test purposes?

 

       Thank you

I am looking for help.

 

I have written a test program for an Apex trigger. The program creates a test account and an opportunity

that is associated with it. The code is shown below:

        // Create a test account for 'Corp Admin'
        Account testAccount = new Account
        (
            Name = 'Test Account',
            Owner = [select username from user where username = 'Corp Admin']
        );
        
        insert testAccount;
        
        // Create a forecast opportunity
        Opportunity testOpp = new Opportunity
        (
            AccountId = testAccount.ID,
            Name = 'testOpportunity' + date.today(),
            CloseDate = date.today() + 1,                    
            StageName = 'Contract signed; waiting for P.O',
            Type = 'Existing Business',
            Pricebook2Id = [select Id from Pricebook2 where name = 'Standard Price Book'],
            OwnerId = testAccount.OwnerId
         );
         
         insert testOpp;
         

 In the program, I want to set the appropriate Price Book, so that I can later enter line items from a specific price book.

The line:

Pricebook2Id = [select Id from Pricebook2 where name = 'Standard Price Book']

is used for this purpose.

 

When compiling, I get the error:

Invalid initial expression type for field Opportunity.Pricebook2Id, expecting: Id.

 

How would I get the Id for the price book?

 

In the same way, I am using the following, to enter a line item (OpportunityLineItem) for the opportunity:

PricebookEntryId = [select Id from Product2 where name = 'AC02'],

 

I get the same kind of error.

 

         Thanks,

 

                aqueller

 

I need help with the following:

 

I have a trigger on a record update. The record is uploaded with the owner being 'admin'.

I want to change it to the true owner of the account:

 

trigger ChangeOwner on Opportunity(before update)
{
   // Create a list of Opportunities, newOpps, to make it bulk fiendly
   List<Opportunity> newOpps = new List<Opportunity>();

   for(Opportunity o : Trigger.new)
   {
      if(o.ForecastCategoryName == 'Closed')
      {
         // This query retrieves the account associated with the Opportunity
         Account myAcct = [select id, name, AccountNumber, owner from account where id = :o.AccountId];


         // Change owner

         o.OwnerId = myAcct.owner;

 

         update o;

 

   }

}

 

This code returns an (understandable) error that it contains illegal recursion.

 

How can I get around this problem and change a field just before the record is updated?

 

      Thx,

 

            aqueller

 

I have an opportunity, ExOp that I receive through a query.

 

Opportunity ExOp = [SELECT name from opportunity

                                    WHERE (AccountId = :o.AccountId and ForecastCategoryName !='Closed')

                                    ORDER BY CloseDate ASC NULLS last LIMIT 1];

 

I am trying to access the list of product in it. (is it OpportunityLineItem?)

Specifically, I want to get to the 'Product2' and 'quantity' fields.



Can someone suggest code to access it?

 

I have an administrator account.

 

I can't edit the opportunity category of opportunities that are not mine,

although I can change the owner to myself, at which point I can edit

the opportunity category.

 

Is there a configuration setting that will allow me to edit the category

without changing owners?

Hi,

 

I have created two price books and want to set the system up such that some users

see Price Book 1, others see Price Book 2 and a third group sees Price Books 1 & 2 (selectable)

 

How do I configure the system to do that?

 

      Thx,

 

           aqueller

Hi,

 

I have a problem with permissions and perhaps someone can help me.

 

I have two managers, MGR A and MGR B.

 

Sales A reports to MGR A (MGR A is defined as his manager, MGR A is the direct manager of Sales A in the role hierarchy as well as the forecast hierarchy)

 

Sales B reports to MGR B in the same way.

 

To allow the managers to override the quota of their subordinates, I have configured them 'modify all data'. The problem is that by doing so, now MGR A can see the forecast for Sales B and MGR B can see the forecast of Sales A.

 

How would I enable the managers to overided their subordinates, yet only see the forecast of their group?

 

        Thx

Does the Apex Data Loader work on a developer sandbox?

- I am able to log into the production site, using its login, password and security token

  but am unable to do so in the sandbox that we have created for this site.

 

       Thx.

Hi,

 

I have an issue with seeing/editing another user's data.

 

1. I have 'edit quota' enabled in my profile

2. I am able to 'Manage Users'

3. The other users's profile shows that I am his manager

4. The other user has 'edit quota' enabled

5. In the forecasting hierarchy I show as being "above" the other user

6. Both of us have forecasting enabled.

7. Our site is configured for 'customizable forecasting'

 

I am able to see and modify my quota (from the user profile screen) but am unable

to see the 'Quotas' area in his profile.

 

Can someone tell me what is missing in the configuration?

 

         Thx,

 

                  aqueller

I am trying to write a trigger that will create a new opportunity when one is closed.

The code that I use is as follows:

 

trigger Recurring on Opportunity (after update)
{
    if (Opportunity.StageName == 'Closed Won')
    {
        Opportunity newOpp = new Opportunity (
                                    Account = 'TEST',
                                    StageName = 'Prospecting',
                                    Type = 'Existing Business');
        insert newOpp;
    }
}

I get two errors, one related to the IF statement and the other

related to setting the account.

 

Can someone suggest what are my mistakes and how I can correct them?

 

       Thx