• JennM
  • NEWBIE
  • 5 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 5
    Replies

I am helping out a nonprofit and wondering if a more experienced Apex developer can help me finish this change to their code?  I could probably even pay for an hour of your time if need be.  Here is what I need to do:

 

Project: Parse string and insert opportunity line items for each value

 

Example of string to parse (quantity, product, totalprice):

| 1, donation-variable, 50 | 2, ticket-individual, 500 | 1, publication-schools, 25

 

Desired result from example: 3 opportunity line items (opportunity products) inserted:

 

OpportunityID = (provided by another piece of code already written)
Quantity = 1
PricebookEntryID = (provided)
TotalPrice = 50
ServiceDate = (provided)

 

OpportunityID = (provided by another piece of code already written)
Quantity = 2
PricebookEntryID = (provided)
TotalPrice = 500
ServiceDate = (provided)

 

OpportunityID = (provided by another piece of code already written)
Quantity = 1
PricebookEntryID = (provided)
TotalPrice = 25
ServiceDate = (provided)

 

I think a loop would need to be performed to grab and insert each item in the string. Obviously, the values in the string could be of any existing products, quantity and price.  This block of code will be added to an existing Apex class right after the Opportunity is inserted.

 

Let me know if you can help me out.  Thanks.

Jenn

  • August 16, 2010
  • Like
  • 0
How do you insert an opportunity product?  The schema is very confusing, I think that I would find the PricebookEntryID and insert that?  But, I am getting an error that the PricebookEntryID is of the wrong type (MALFORMED_ID, Price Book Entry ID: id value of incorrect type: 01us0000001eOEkIAM)

 

 

opportunityId = newopp.id,

Quantity = 1,

ServiceDate = l.Donation_Close_Date__c,

PricebookEntryId =

OpportunityLineItem newoppprod = new OpportunityLineItem('01us0000001eOEkIAM');

insert newoppprod;

 

  • August 11, 2010
  • Like
  • 0

I am adding a bit of code to an existing Apex class and it won't compile.  Any thought on what is wrong and why I am getting the error message: Error: Compile Error: Expression cannot be assigned at line -1 column -1 ?

 

OpportunityLineItem newoppprod = new OpportunityLineItem(

 opportunityId = newopp.id,
  Quantity = 1,
  ServiceDate = l.Donation_Close_Date__c,
  TotalPrice = l.Donation_Amount__c);
 
  if(l.Product_Information__c != null)
      {
      if(l.Product_Information__c == 'Donate')
          {
          OpportunityLineItem.ID = '01tS0000000kI02';
          }
      if(l.Product_Information__c == 'ticket-individual')
          {
          OpportunityLineItem.ID = '01tS0000000kFsk';
          } 
      if(l.Product_Information__c =='sponsorship-mentor')
          {
          OpportunityLineItem.ID = '01tS0000000kFsV';
          }   
      }
  insert newoppprod;

  • August 11, 2010
  • Like
  • 0

Is there any way to clone the notes of the printable view page? (so that all notes are in printable)

  • July 28, 2010
  • Like
  • 0

Is it possible to update the ID in a custom object in a managed package?  I want to be able to update the ID (which is an Autonumber with string) to add another string value such as:

 

From:

Intake-{0000001}

 

To:

Intake-{0000001} - Doe, Jane

 

This is because all the emails and tasks associated with the Intake only show the ID and it would be convenient to show the name of the person without needing to click into the record.  I was thinking an after update trigger could update the ID.

 

Thanks for any advice.

  • July 23, 2010
  • Like
  • 0

I am wondering if it is possible and if anyone could help a newbie out with figuring out a VF page that can display all the Notes entered similar to the functionality of the Printable View, but with only a few key fields and then the full Notes?  Thanks.

  • July 23, 2010
  • Like
  • 0
Does anyone know of a formula that will count the number of value selected in a multi-picklist?  I want to use it in a calculation to come up with an average. Thanks.
  • March 24, 2010
  • Like
  • 0

I am trying to find out whether I can build a Site that can search, edit and insert Contact records.  I have seen conflicting information about this so am hoping to get a definitive answer so I know whether this is an option to pursue or not for an issue my client has.  Thanks for any advice!

 

Jenn

  • December 07, 2009
  • Like
  • 0
How do you insert an opportunity product?  The schema is very confusing, I think that I would find the PricebookEntryID and insert that?  But, I am getting an error that the PricebookEntryID is of the wrong type (MALFORMED_ID, Price Book Entry ID: id value of incorrect type: 01us0000001eOEkIAM)

 

 

opportunityId = newopp.id,

Quantity = 1,

ServiceDate = l.Donation_Close_Date__c,

PricebookEntryId =

OpportunityLineItem newoppprod = new OpportunityLineItem('01us0000001eOEkIAM');

insert newoppprod;

 

  • August 11, 2010
  • Like
  • 0

I am adding a bit of code to an existing Apex class and it won't compile.  Any thought on what is wrong and why I am getting the error message: Error: Compile Error: Expression cannot be assigned at line -1 column -1 ?

 

OpportunityLineItem newoppprod = new OpportunityLineItem(

 opportunityId = newopp.id,
  Quantity = 1,
  ServiceDate = l.Donation_Close_Date__c,
  TotalPrice = l.Donation_Amount__c);
 
  if(l.Product_Information__c != null)
      {
      if(l.Product_Information__c == 'Donate')
          {
          OpportunityLineItem.ID = '01tS0000000kI02';
          }
      if(l.Product_Information__c == 'ticket-individual')
          {
          OpportunityLineItem.ID = '01tS0000000kFsk';
          } 
      if(l.Product_Information__c =='sponsorship-mentor')
          {
          OpportunityLineItem.ID = '01tS0000000kFsV';
          }   
      }
  insert newoppprod;

  • August 11, 2010
  • Like
  • 0

I am trying to find out whether I can build a Site that can search, edit and insert Contact records.  I have seen conflicting information about this so am hoping to get a definitive answer so I know whether this is an option to pursue or not for an issue my client has.  Thanks for any advice!

 

Jenn

  • December 07, 2009
  • Like
  • 0