• Samantha Starling
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 9
    Replies

We are running into an error involving Person Accounts and can't figure out why. Any help would be appreciated.

ERROR.>

System.DmlException: ConvertLead failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, A workflow or approval field update caused an error when saving this record. Contact your administrator to resolve it. Record Type ID: value not valid for the entity: PersonAccount: []

TRIGGER>

/*
 * The TestPlatformAppsAfterLeadConversion test runs three Lead Conversion scenarios.  It tests Leads with no Platform
 * Apps attached via a Relate List, with one Platform App, and with two Platform Apps.  The Lead Conversion trigger
 * will add the ID of the newly created Account to any Platform Apps on the Lead.
 * 
 * [dug] 09.24.2015
 */
@isTest
public class TestPlatformAppsAfterLeadConversion {
    
    /*
     * The convertLeadWithNoPlatformApps test Lead Conversion with no associated Platform Apps 
     */
    static testMethod void convertLeadWithNoPlatformApps() {
        // Create a test Lead
        Lead newLead = new Lead();
        newLead.RecordTypeId = '012A0000000VmQk';
        newLead.FirstName = 'Pokit';
        newLead.LastName = 'Bot';
        newLead.Company = 'PokitDok';
        newLead.Status = 'MQL (Marketing Qualified)';  
        insert newLead;

        // Do the conversion
        Database.LeadConvert lc = new Database.LeadConvert();
        lc.setLeadId(newLead.id);

        // Run the test
        test.startTest();

        LeadStatus convertStatus = [Select Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
        lc.setConvertedStatus(convertStatus.MasterLabel);
        Database.LeadConvertResult lcr = Database.convertLead(lc);
        
        // Assert the conversion happened
        System.assert(lcr.isSuccess());

        test.stopTest();
    }

I've read every post I can find on this topic and have followed the instructions in each. I used the formula below and have the RefID populating correctly. However, when I test via email to/from the custom object and to/from my mail client, nothing attaches. Any help in getting emails to attach to a custom object would be very much appreciated.

 "[ref:00D"&MID(Id,4,1)&RIGHT($Organization.Id, 4) &"."& LEFT(Id,4)&RIGHT(Id,5) &":ref]"
I am getting a save error that my expression cannot be assigned. I've read every post related to the error and am unable to figure out how to fix my code. One post said I couldn't use an autonumber (which one of the fields I was using was) so I changed the field type to just number. What I need this to do is, once the two Oppty Number fields match, the fields from the custom object Production Details will send over to the fields on the Opportunity Product.

Any suggestions??

global class PlayerConversion{
    webService
static String copyPlayerDetails(Id ProductionDetailId){
        List<Production_Detail__c> lstProductionDetail =
            [
                SELECT 
                    Id, 
                    Shipping_Costs__c,
                    Act_Postage_Total__c,
                    Per_Piece_Cost__c 
                  
                    
                FROM 
                    Production_Detail__c 
                WHERE 
                    Id = :ProductionDetailId
            ];

       List <OpportunityLineItem> lstOpportunityLineItem = new List<OpportunityLineItem>();

    if(OpportunityLineItem.Opportunity_Product_Number__c == Production_Detail__c.Opportunity_Product__c){
for(Production_Detail__c player : lstProductionDetail){

              
                    lstOpportunityLineItem.add(
                        new OpportunityLineItem()
                            );
                           OpportunityLineItem.Shipping_Costs__c=Production_Detail__c.Shipping_Costs__c;
                           OpportunityLineItem.Postage_Cost__c=Production_Detail__c.Act_Postage_Total__c;
                           OpportunityLineItem.Per_Piece_Cost__c=Production_Detail__c.Per_Piece_Cost__c
                       
                        ;
}
               }     
      try{   
            INSERT lstOpportunityLineItem;
            return lstOpportunityLineItem[0].Id; 
        }
        catch (Exception ex){
            
            return('Error');
        }     
}
}     
 
Hi everyone...I am new to development and working on my first Apex Class to send information from a custom object called Production Details to the Opportunity Product and I am almost there! I need the FOR loop to be contingent on the Opportunity Product Number field on the Production Details matching the same field on the Opportunity Product (which is an auto number field) so that when the user inputs the same number that was generated on the creation of the Oppty Prod onto the Production Details and saves then clicks the "Send to Oppty Prod" button, the data will get sent. Can anyone take look and offer some help in getting this finished? Code below...

global class ProductionDetailConversion{
    webService
    static String copyProductionDetail(Id Production_DetailId){
        List<Production_Detail__c> lstProductionDetail =
            [
                SELECT 
                    Id, 
                    Shipping_Costs__c, 
                    Act_Postage_Total__c,
                    Per_Piece_Cost__c 
                    
                FROM 
             Production_Detail__c 
                WHERE 
                    Id = :ProductionDetailId
            ];
 
    
       List <OpportunityProductLineItem> lstOpportunityProductLineItem = new 

List<OpportunityProductLineItem>();
 
        for(Production_Detail__c Opportunity Product Number : OpportunityLineItem 

Opportunity Product Number){
              
                    lstOpportunityProductLineItem.add(
                        new OpportunityProductLineItem(
                            
                            Shipping_Costs__c = 

OpportunityLineItem.Shipping_Costs__c,
                            Act_Postage_Total__c = 

OpportunityLineItem.Postage_Costs__c,
                            Per_Piece_Cost__c = 

OpportunityLineItem.Per_Piece_Costs__c,
                       
                        )
                    );
               }     
      try{   
            INSERT lstOpportunityProductLineItem;
            return lstOpportunityProductLineItem[0].Id; 
        }
        catch (Exception ex){
            
            return('Error');
        } 
I am very, very new to development and am working on my first Apex Class for a button that will update fields from a custom object (Production Details) to the Opportunity Product based on the matching of the data in two fields (Opportunity Product Number on both objects).I am getting a error message that there's an Unexpected Token 'FROM'. Any direction on materials that will help fix the error? Code below...

global class ProductionDetailConversion{
    webService
    static String copyProductionDetail(Id Production_DetailId){
        List<Production_Detail__c> lstProductionDetail =
            [
                SELECT 
                    Id, 
                    Shipping_Costs__c, 
                    Postage_Costs__c,
                    Per_Piece_Costs__c, 
                    
                FROM 
             Production_Detail__c 
                WHERE 
                    Id = :ProductionDetailId
            ];
 
    
       List <OpportunityProductLineItem> lstOpportunityProductLineItem = new 

List<OpportunityProductLineItem>();
 
        for(!OpportunityLineItem.Opportunity_Product_Number__c : Production_Detail__c.Opportunity_Product__c}){
              
                    lstOpportunityProductLineItem.add(
                        new OpportunityProductLineItem(
                            
                            Shipping_Costs__c = OpportunityLineItem.Shipping_Costs__c,
                            Postage_Costs__c = OpportunityLineItem.Postage_Costs__c,
                            Per_Piece_Costs__c = OpportunityLineItem.Per_Piece_Costs__c,
                       
                        )
                    );
               }     
      try{   
            INSERT lstOpportunityProductLineItem;
            return lstOpportunityProductLineItem[0].Id; 
        }
        catch (Exception ex){
            
            return('Error');
        }     
}
We have a custom object called Production Details and need three fields from that object to push back onto the related Opportunity Product. I set up an auto-numbering field on the Oppty Prod so each would have a unique identifier in order to match each Production Detail. I created a text field on the Production Detail where the user will input that number. Just for the heck of it, I looked at a WFR first knowing there are limits with Oppty Prod and custom objects and probably not possible. The WFR is set up so that once those two numbers match, the field updates for the three fields would kick in. The forumlas are all working with no errors. I've tried every configuration and still the updates are not happening so back to Plan A for a button. I've looked up and tried several codes for buttons to send the data from the Production Detail object to the related Oppty Product but have been unsuccessful.

Anyone know have code for such a thing or know if it's possible to create a "Send to Oppty Prod" button that will send the data from our Production Detail to the matching Oppty Prod?

I'm building a flow that is going to call on a tiny bit of Apex where I need it to delete the Email Campaign record once it's greater than 90 days old. I copied and modified from the original apex replacing quotes with my object. I'm getting error messages for illeglal variables around the salesfusion_web_campaign. Anyone spot what I'm doing wrong?

Here's the article I'm using as a guide: https://automationchampion.com/tag/auto-delete-record-using-process-builder/

ORIGINAL APEX>
public class DeleteUnacceptedQuotes
{
    @InvocableMethod
    public static void QuoteDelete(List<Id> OpportunityIds)
    {
        List<Quote> Quotes =[select id from quote
                          where Opportunity.id in :OpportunityIds
                       and Status != 'Accepted'];
        delete Quotes;
   }
}

MY CUSTOM APEX VERSION 1>
public class DeleteEmailCampaigns
{
   @InvocableMethod
   public static void WebCampaignDelete(List<Id> salesfusion__Web_Campaign__c.Ids)
   {
       List<Web_Campaign__c> Web_Campaign__c =[select id from Web_Campaign__c
                         where salesfusion__Web_Campaign__c.id in :salesfusion__Web_Campaign__c.Ids
                      and Days_Since_Creation__c > 90];
       delete Web_Campaign__c;
  }
}

MY CUSTOM APEX VERSION 2>
public class DeleteEmailCampaigns
{
   @InvocableMethod
   public static void WebCampaignDelete(List<Id> salesfusion__Web_Campaign__cIds)
   {
       List<Web_Campaign__c> Web_Campaign__c =[select id from Web_Campaign__c
                         where salesfusion__Web_Campaign__c.id in :salesfusion__Web_Campaign__cIds
                      and Days_Since_Creation__c > 90];
       delete Web_Campaign__c;
  }
}

I am getting a save error that my expression cannot be assigned. I've read every post related to the error and am unable to figure out how to fix my code. One post said I couldn't use an autonumber (which one of the fields I was using was) so I changed the field type to just number. What I need this to do is, once the two Oppty Number fields match, the fields from the custom object Production Details will send over to the fields on the Opportunity Product.

Any suggestions??

global class PlayerConversion{
    webService
static String copyPlayerDetails(Id ProductionDetailId){
        List<Production_Detail__c> lstProductionDetail =
            [
                SELECT 
                    Id, 
                    Shipping_Costs__c,
                    Act_Postage_Total__c,
                    Per_Piece_Cost__c 
                  
                    
                FROM 
                    Production_Detail__c 
                WHERE 
                    Id = :ProductionDetailId
            ];

       List <OpportunityLineItem> lstOpportunityLineItem = new List<OpportunityLineItem>();

    if(OpportunityLineItem.Opportunity_Product_Number__c == Production_Detail__c.Opportunity_Product__c){
for(Production_Detail__c player : lstProductionDetail){

              
                    lstOpportunityLineItem.add(
                        new OpportunityLineItem()
                            );
                           OpportunityLineItem.Shipping_Costs__c=Production_Detail__c.Shipping_Costs__c;
                           OpportunityLineItem.Postage_Cost__c=Production_Detail__c.Act_Postage_Total__c;
                           OpportunityLineItem.Per_Piece_Cost__c=Production_Detail__c.Per_Piece_Cost__c
                       
                        ;
}
               }     
      try{   
            INSERT lstOpportunityLineItem;
            return lstOpportunityLineItem[0].Id; 
        }
        catch (Exception ex){
            
            return('Error');
        }     
}
}     
 
I am very, very new to development and am working on my first Apex Class for a button that will update fields from a custom object (Production Details) to the Opportunity Product based on the matching of the data in two fields (Opportunity Product Number on both objects).I am getting a error message that there's an Unexpected Token 'FROM'. Any direction on materials that will help fix the error? Code below...

global class ProductionDetailConversion{
    webService
    static String copyProductionDetail(Id Production_DetailId){
        List<Production_Detail__c> lstProductionDetail =
            [
                SELECT 
                    Id, 
                    Shipping_Costs__c, 
                    Postage_Costs__c,
                    Per_Piece_Costs__c, 
                    
                FROM 
             Production_Detail__c 
                WHERE 
                    Id = :ProductionDetailId
            ];
 
    
       List <OpportunityProductLineItem> lstOpportunityProductLineItem = new 

List<OpportunityProductLineItem>();
 
        for(!OpportunityLineItem.Opportunity_Product_Number__c : Production_Detail__c.Opportunity_Product__c}){
              
                    lstOpportunityProductLineItem.add(
                        new OpportunityProductLineItem(
                            
                            Shipping_Costs__c = OpportunityLineItem.Shipping_Costs__c,
                            Postage_Costs__c = OpportunityLineItem.Postage_Costs__c,
                            Per_Piece_Costs__c = OpportunityLineItem.Per_Piece_Costs__c,
                       
                        )
                    );
               }     
      try{   
            INSERT lstOpportunityProductLineItem;
            return lstOpportunityProductLineItem[0].Id; 
        }
        catch (Exception ex){
            
            return('Error');
        }     
}