• Joel Kikkert 23
  • NEWBIE
  • 15 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 11
    Replies
Hi, 
We're migrating data and I need to set the audit fields with created date which is a datetime format field. I tried everything but it just errors out on me. My current format is: mm/dd/yyyyThh:mm:ss".000GMT+01:00" 
However, this one won't work for me. Anybody knows the right format and has an example on how to set this in formatting in Excel?

Thanks
Hi, 
In my org we have Products(Service Lines) and Subproducts(Product Lines) and I wrote  a trigger on Opportunity to convert them to Assets(Services). 
However, I still need to add the subproducts to assets.

For Example: 1 product has 2 subproducts (master-detail)
it converts to 1 Asset and 2 subassets. 

Here is what I have so far. Any tips?
 
trigger OpportunityToService on Opportunity (after update) {


		
//1. if statement when opportunity field isWon = true AND other condition?
			for(Opportunity wonOpportunity : Trigger.new){
			if (wonOpportunity.IsWon == true && wonOpportunity.IsClosed == true) {
				

				//query all the service lines on the opportunity and store the Id's in an array
				String opportunityID = wonOpportunity.Id;
				Service_Line__c[] serviceLines = [SELECT Id, AccountId__c, Contract_End__c, Contract_Start__c,
													Contract_Term__c, Description__c, GoingToProducts__c, Implementation_Fee__c, 
													IsHealthMgmt__c, Opportunity_Product_Id__c, Opportunity__c, OwnerId, Practice__c,
													Price_Book_Entry_Id__c, Project_Fee__c, Recurring_Fixed_Revenue__c, Recurring_Revenue__c, 
													Recurring_Variable_Revenue__c, Service_Line__c, Service_Name__c, Service__c, 
													Total_Contract_Margin__c, Total_Contract_Value__c, Trust_Employer__c, Won_Service__c, 
													Y4_Revenue__c, Y5_Revenue__c, Y6_Revenue__c, Y7_Revenue__c
													FROM Service_Line__c
													WHERE Opportunity__c = :opportunityID];
				
				System.debug('The array contains the following IDs' + serviceLines);

				//for every Serviceline in the list , create a new service
			
				//create array in which to store all services for bulk insert
				Service__c[] newServices = new Service__c[]{};

				//create service
				Service__c newService = new Service__c();
				for (Service_Line__c sl: serviceLines) {
					newService = new Service__c();
					newService.Account__c						= wonOpportunity.AccountId;
					newService.Contract_Start__c				= sl.Contract_Start__c;
					newService.Contract_Term__c					= sl.Contract_Term__c;
					newService.Description__c					= sl.Description__c;
					newService.Implementation_Fee__c			= sl.Implementation_Fee__c;
					newService.Opportunity__c					= sl.Opportunity__c;
					newService.Price_Book_Entry_Id__c			= sl.Price_Book_Entry_Id__c;
					newService.Recurring_Fixed_Revenue__c		= sl.Recurring_Fixed_Revenue__c;
					newService.Recurring_Variable_Revenue__c	= sl.Recurring_Variable_Revenue__c;
					newService.Project_Fee__c					= sl.Project_Fee__c;
					newService.Total_Contract_Value__c			= sl.Total_Contract_Value__c;
					newService.Total_Contract_Margin__c			= sl.Total_Contract_Margin__c;
					newService.Y4_Revenue__c					= sl.Y4_Revenue__c;
					newService.Y5_Revenue__c					= sl.Y5_Revenue__c;
					newService.Y6_Revenue__c					= sl.Y6_Revenue__c;
					newService.Y7_Revenue__c					= sl.Y7_Revenue__c;
					newService.Is_Won__c						= true;
					newService.Service_Owner__c					= sl.OwnerId;
					newService.Service__c						= sl.Price_Book_Entry_Id__c.Product2.Name;
					newService.Trust_Employer__c				= sl.Trust_Employer__c;
					newServices.add(newService);
				

					}

					insert newServices;
					


				}


			}

				

			


		}

 
Hi,
I just inherited an org and after running a few tests, the test coverage turned out to be 18%. I've never seen such a number. Anyone has any tips on what to do? Reboot or write a lot of test classes? 
Hi, 
We're migrating data and I need to set the audit fields with created date which is a datetime format field. I tried everything but it just errors out on me. My current format is: mm/dd/yyyyThh:mm:ss".000GMT+01:00" 
However, this one won't work for me. Anybody knows the right format and has an example on how to set this in formatting in Excel?

Thanks
Hi, 
We're migrating data and I need to set the audit fields with created date which is a datetime format field. I tried everything but it just errors out on me. My current format is: mm/dd/yyyyThh:mm:ss".000GMT+01:00" 
However, this one won't work for me. Anybody knows the right format and has an example on how to set this in formatting in Excel?

Thanks
I'm very, very new to Apex and at a loss. I have a business requirement to update a custom Lead picklist field called "Qualification Status" to "Converted" when a Lead is converted. I've created the following Trigger:
trigger LeadQualStatusToConvertedTrigger on Lead (before update) {
    
    List<Lead> convertedLeads = new List<Lead>();
    
    for(Lead convertedLead : Trigger.New) {
        if (convertedLead.IsConverted) {
            convertedLeads.add(convertedLead);
        }
    }

    LeadQualStatusToConverted.setQualStatusConverted(convertedLeads);
}
I've tested LeadQualStatusToConverted.setQualStatusConverted() and it works. The issue is that nothing satisfies the Trigger's If clause. Here's a relevant piece of my test class:
@testSetup
    static void setup() {
        List<Lead> testLeads = new List<Lead>();
        for(Integer i=0; i<10; i++) {
            testLeads.add(new Lead(LastName = 'Smith' + i
                                  ,Company = 'Smith Co.'
                                  ,Qualification_Status__c = 'MQL'
                                  ,IsConverted = False));
        }
        
        Database.insert(testLeads);
    }

    @isTest
    static void TestUpdatedConvertedLead() {
        Lead testLead = [Select Id, Qualification_Status__c, IsConverted
                         From Lead
                         Where LastName='Smith1'];

        Test.startTest();
        Database.LeadConvert lc = new Database.LeadConvert();
        lc.setLeadId(testLead.Id);
        lc.setConvertedStatus('Qualified');
        Database.LeadConvertResult lcr = Database.convertLead(lc);
		Test.stopTest();
        
        System.assert(True,testLead.IsConverted);
        System.assert(lcr.isSuccess());
        System.assertEquals('Converted',testLead.Qualification_Status__c);
    }
The first two asserts pass, but the one that matters (the third), does not. The test result statest that the Qualification_Status__c is still the initialized value of MQL. So, it's successfully being converted, but not making it past the Trigger's If and thus not being passed to the setQualStatusConverted() method.

I'm at a loss... How can I check for IsConverted in the Trigger?

I'm trying to pass trailhead challenge to create flow with flow designer.

It's not loading. All I can see is:
User-added image

Can anyone give advise hot to make flow designer show up?

Hi, 
In my org we have Products(Service Lines) and Subproducts(Product Lines) and I wrote  a trigger on Opportunity to convert them to Assets(Services). 
However, I still need to add the subproducts to assets.

For Example: 1 product has 2 subproducts (master-detail)
it converts to 1 Asset and 2 subassets. 

Here is what I have so far. Any tips?
 
trigger OpportunityToService on Opportunity (after update) {


		
//1. if statement when opportunity field isWon = true AND other condition?
			for(Opportunity wonOpportunity : Trigger.new){
			if (wonOpportunity.IsWon == true && wonOpportunity.IsClosed == true) {
				

				//query all the service lines on the opportunity and store the Id's in an array
				String opportunityID = wonOpportunity.Id;
				Service_Line__c[] serviceLines = [SELECT Id, AccountId__c, Contract_End__c, Contract_Start__c,
													Contract_Term__c, Description__c, GoingToProducts__c, Implementation_Fee__c, 
													IsHealthMgmt__c, Opportunity_Product_Id__c, Opportunity__c, OwnerId, Practice__c,
													Price_Book_Entry_Id__c, Project_Fee__c, Recurring_Fixed_Revenue__c, Recurring_Revenue__c, 
													Recurring_Variable_Revenue__c, Service_Line__c, Service_Name__c, Service__c, 
													Total_Contract_Margin__c, Total_Contract_Value__c, Trust_Employer__c, Won_Service__c, 
													Y4_Revenue__c, Y5_Revenue__c, Y6_Revenue__c, Y7_Revenue__c
													FROM Service_Line__c
													WHERE Opportunity__c = :opportunityID];
				
				System.debug('The array contains the following IDs' + serviceLines);

				//for every Serviceline in the list , create a new service
			
				//create array in which to store all services for bulk insert
				Service__c[] newServices = new Service__c[]{};

				//create service
				Service__c newService = new Service__c();
				for (Service_Line__c sl: serviceLines) {
					newService = new Service__c();
					newService.Account__c						= wonOpportunity.AccountId;
					newService.Contract_Start__c				= sl.Contract_Start__c;
					newService.Contract_Term__c					= sl.Contract_Term__c;
					newService.Description__c					= sl.Description__c;
					newService.Implementation_Fee__c			= sl.Implementation_Fee__c;
					newService.Opportunity__c					= sl.Opportunity__c;
					newService.Price_Book_Entry_Id__c			= sl.Price_Book_Entry_Id__c;
					newService.Recurring_Fixed_Revenue__c		= sl.Recurring_Fixed_Revenue__c;
					newService.Recurring_Variable_Revenue__c	= sl.Recurring_Variable_Revenue__c;
					newService.Project_Fee__c					= sl.Project_Fee__c;
					newService.Total_Contract_Value__c			= sl.Total_Contract_Value__c;
					newService.Total_Contract_Margin__c			= sl.Total_Contract_Margin__c;
					newService.Y4_Revenue__c					= sl.Y4_Revenue__c;
					newService.Y5_Revenue__c					= sl.Y5_Revenue__c;
					newService.Y6_Revenue__c					= sl.Y6_Revenue__c;
					newService.Y7_Revenue__c					= sl.Y7_Revenue__c;
					newService.Is_Won__c						= true;
					newService.Service_Owner__c					= sl.OwnerId;
					newService.Service__c						= sl.Price_Book_Entry_Id__c.Product2.Name;
					newService.Trust_Employer__c				= sl.Trust_Employer__c;
					newServices.add(newService);
				

					}

					insert newServices;
					


				}


			}

				

			


		}