-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
17Questions
-
13Replies
Trigger: Update record of different record type with same field values
trigger createOrderforABFSCB1 on Stem_Cell_Bank__c (after update) { // Collect all updated SCB Ids Set<Id> setSCBIds = new Set<Id>(); // Collect all SCB Id which has stem cell banked date populated for(Stem_Cell_Bank__c scb : Trigger.new) { if (scb.Stage__c == 'Stem Cells Banked' && Trigger.oldMap.get(scb.Id).Stage__c != 'Stem Cells Banked') { setSCBIds.add(scb.Id); } } // List for collecting Orders to update List<ChargentOrders__ChargentOrder__c> colist = new List<ChargentOrders__ChargentOrder__c>(); // Iterate all the Orders of SCB for(ChargentOrders__ChargentOrder__c o : [SELECT Id, Account__c, Stem_Cell_Bank__c, ChargentOrders_Expiration_Month__c, ChargentOrders_Number__c, ChargentOrders_Type__c, ChargentOrders__Payment_Method__c, RecordTypeId FROM ChargentOrders__ChargentOrder__c WHERE Stem_Cell_Bank__c IN: setSCBIds]) { if(o.RecordTypeId == '012E0000000VPOC') { colist.add(new ChargentOrders__ChargentOrder__c(Id = o.Id, RecordTypeId = '012E0000000VPOH', ChargentOrders_Number__c = o.ChargentOrders_Number__c)); } } if(!colist.isEmpty()) { update colist; } }
- daniel1110
- July 22, 2014
- Like
- 0
- Continue reading or reply
Visual Workflow BUG - Missing Image
Hi. Does anyone know who do I need to speak with to have a bug fixed with visual workflow?
I tried contacting Basic Support and they directed me log this problem in developerforce
I'm not sure if I'm crazy of they are, but I thought developerforce is a collaboration of external developers
In my personal experience, basic support has been subpar to say the least and lack the technical knowledge to resolve some of the most simplistic problems
Here's an explanation of this bug:
When you progress through the visual workflow from one screen to another, there's an image named loading.gif, that shows the progression
The problem is this image is not being shown properly and shows as image missing. This problem shows up in Chrome, not sure if it's a cross brower issue
Any feedback would be appreciated
- daniel1110
- October 02, 2013
- Like
- 0
- Continue reading or reply
Too many SOQL queries 101 in testClass w/o for loop
Hi. I'm not using any for loop but getting System.LimitException: Too many SOQL queries: 101
The error is recognized in insert(testTask)
Sorry I'm not a good coder. Any suggestions would be appreciated. Thank you in advance.
@isTest public class updateSCBonT4Test { static testMethod void testupdateSCBonT4(){ Account testAccount = new Account(name='test account'); insert(testAccount); Stem_Cell_Bank__c s = new Stem_Cell_Bank__c(); s.name = 'Test'; // system.debug('value is = ' + testAccount.Id); s.account__c = testAccount.Id; test.startTest(); insert(s); LIST<Stem_Cell_Bank__c> a = [SELECT Id, Stage__c FROM Stem_Cell_Bank__c WHERE Name = 'Test']; Task testTask = new Task(Subject
= 'Collect Enrollment Information', whatId = a[0].ID); insert(testTask); Stem_Cell_Bank__c updatedStem_Cell_Bank = [SELECT stage__c FROM Stem_Cell_Bank__c WHERE name = 'Test']; system.AssertEquals('Collect Enrollment Information',updatedStem_Cell_Bank.stage__c); testTask.whatId = s.Id; testTask.Status='Completed'; update(testTask); Task testTask1 = new Task(Subject = 'Process Payment', whatId = a[0].ID); insert(testTask1); Stem_Cell_Bank__c updatedStem_Cell_Bank1 = [SELECT stage__c FROM Stem_Cell_Bank__c WHERE name = 'Test']; system.AssertEquals('Process Payment',updatedStem_Cell_Bank1.stage__c); testTask1.whatId = s.Id; testTask1.Status='Completed'; update(testTask1); Task testTask2 = new Task(Subject = 'Order Blood Test', whatId = a[0].ID); insert(testTask2); Stem_Cell_Bank__c updatedStem_Cell_Bank2 = [SELECT stage__c FROM Stem_Cell_Bank__c WHERE name = 'Test']; system.AssertEquals('Order Blood Test',updatedStem_Cell_Bank2.stage__c); testTask2.whatId = s.Id; testTask2.Status='Completed'; update(testTask2); Task testTask3 = new Task(Subject = 'Schedule Fat Extraction', whatId = a[0].ID); insert(testTask3); Stem_Cell_Bank__c updatedStem_Cell_Bank3 = [SELECT stage__c FROM Stem_Cell_Bank__c WHERE name = 'Test']; system.AssertEquals('Schedule Fat Extraction',updatedStem_Cell_Bank3.stage__c); testTask3.whatId = s.Id; testTask3.Status='Completed'; update(testTask3); Stem_Cell_Bank__c checkupdate = [SELECT stage__c, id FROM Stem_Cell_Bank__c WHERE name='Test']; System.debug(checkupdate.Id); System.debug(checkupdate.Stage__c); system.AssertEquals('Review Eligibility Test',checkupdate.stage__c); test.stopTest(); } }
- daniel1110
- August 20, 2013
- Like
- 0
- Continue reading or reply
Field set question or not...
Hi all!
Is it possible to create consecutive field set records from a detail page?
The reason I ask is I have 5 fields that need to be collected in "groups" and the number of these "groups" can be anywhere from 1 to 30.
If field set is not the solution to this, can anyone pls provide any workaround solution/recommendation?
Thank you! ^^
Daniel
- daniel1110
- August 02, 2013
- Like
- 0
- Continue reading or reply
Trigger applies to all records instead on relevant ID
Hi. I have a trigger that triggers for more records than I hope for
trigger createOrderforABFSCB on Stem_Cell_Bank__c (after update) { List<ChargentOrders__ChargentOrder__c> co = new List<ChargentOrders__ChargentOrder__c>(); for (Stem_Cell_Bank__c scb : Trigger.new) { if (scb.Stage__c == 'Stem Cells Banked') { /*scb to oscb*/ //initiate the object to put values for furture record ChargentOrders__ChargentOrder__c c = new ChargentOrders__ChargentOrder__c(); //map Order fields to SCB that is being created for this Order c.Stem_Cell_Bank__c = scb.Id; /*scb to oscb*/ c.ChargentOrders__Date__c = date.today(); c.Order_Item__c = 'Yearly Stem Cell Banking Fee'; if(scb.Stem_Cells_Banked_Date__c!=null) c.ChargentOrders__Payment_Start_Date__c = scb.Stem_Cells_Banked_Date__c.addYears(1); else scb.addError('Cannot have empty stem cell bank date before stage is set to stem cell banked'); //add this new object to the list that would be inserted later co.add(c); } //end if } //end for scb //once the loop is done, insert the new record to Order try{ insert co; } catch (system.Dmlexception e) { system.debug(e); } }
This seems to add a new record for all records with stage__c = 'Stem Cells Banked'
I need to add a new ChargentOrder record for existing Stem_Cell_Bank__c record only to the respective ID when Stage__c is updated to 'Stem Cells Banked'
I tried researching more about using oldMap and played around with the logic:
Stem_Cell_Bank__c oscb = Trigger.oldMap.get(scb.ID);
But having a hard time getting it work. Plus if I could add a checksum logic to only allow 2 ChargentOrder records to 1 Stem_Cell_Bank record it will help even more to not encounter these type of errors in the future
Any suggestions would be greatly appreciated
Thank you in advance
Daniel
- daniel1110
- July 15, 2013
- Like
- 0
- Continue reading or reply
System.NullPointerException pls help
trigger createOrderforABFSCB on Stem_Cell_Bank__c (after update) { List<ChargentOrders__ChargentOrder__c> co = new List<ChargentOrders__ChargentOrder__c>(); for (Stem_Cell_Bank__c scb : Trigger.new) { if (scb.Stage__c == 'Stem Cells Banked') { /*scb to oscb*/ //initiate the object to put values for furture record ChargentOrders__ChargentOrder__c c = new ChargentOrders__ChargentOrder__c(); //map Order fields to SCB that is being created for this Order c.Stem_Cell_Bank__c = scb.Id; /*scb to oscb*/ c.ChargentOrders__Date__c = date.today(); c.ChargentOrders__Gateway__c = 'xxxxxxxxxxxxxxxxx'; c.ChargentOrders__Currency__c = 'U.S. Dollar'; c.Order_Item__c = 'Yearly Subscription Fee'; // add one year to stem cell banked date c.ChargentOrders__Payment_Start_Date__c = scb.Stem_Cells_Banked_Date__c.addYears(1); //add this new object to the list that would be inserted later co.add(c); } //end if } //end for scb //once the loop is done, insert the new record to Order try{ insert co; } catch (system.Dmlexception e) { system.debug(e); } }
Hi, as you could see, i have a pretty straightforward trigger, but i am getting the following error:
System.NullPointerException: Attempt to de-reference a null object Trigger.createOrderforABFSCB
it appears to not like c.ChargentOrders__Payment_Start_Date__c = scb.Stem_Cells_Banked_Date__c.addYears(1);
Stem_Cells_Banked_Date__c is a DATE data type, but i can't seem to use the addYears() method
Any suggestion would be appreciated.
thank u
- daniel1110
- July 08, 2013
- Like
- 0
- Continue reading or reply
Save Content in a Form and Then Resume Work
Hi everyone,
I was wondering if anybody had this sort of requirement. Just like the popular online tax forms, how can I save the content in a form to resume work later?
I plan to have series of screens/forms to collect data over a course of weeks. I would imagine when the user signs off for the day, he/she would "save" and the next day, he/she would enter in the Id and be lead to the existing online form to resume from where he/she left off.
I wanted to build this with VF flow and can see how it can be done, but the problem is addressing partially complete scenarios and how to recover from where the user left off.
Ideally, a plug-in to VF would be amazing, but I am limited in my APEX skills.
Can anyone provide a suggestion or workaround?
Thank u!
Daniel
- daniel1110
- May 20, 2013
- Like
- 0
- Continue reading or reply
How can I save my data and continue later?
Hi everyone,
I was wondering if anybody had this sort of requirement? Just like the popular online tax forms, how can I save the content in a form to resume work later?
I plan to have series of screens/forms to collect data over a course of weeks. I would imagine when the user signs off for the day, he/she would "save" and the next day, he/she would enter in the Id and be lead to the existing online form to resume from where he/she left off.
I wanted to build this with VF flow and can see how it can be done, but the problem is addressing partially complete scenarios and how to recover from where the user left off.
Ideally, a plug-in to VF would be amazing, but I am limited in my APEX skills.
Can anyone provide a suggestion or workaround?
Thank u!
Daniel
- daniel1110
- May 20, 2013
- Like
- 0
- Continue reading or reply
PageReference is confusing. Pls help
Hi,
I'm trying to add a VF Page that is rendered as pdf to attach to 'Notes & Attachment' in my custom object. I have working page, trigger, and class that does this, except it does not successfully add the body.
My VF Page:
<apex:page showHeader="false" renderAs="pdf"> <head> <style type="text/css"> body{ padding:0; background:url(http://www.google.com/footer.background.03.png) no-repeat fixed #192771; background-position: center bottom; /* same as 50% 100% */ } </style> </head> <body> this is the body </body> </apex:page>
My Trigger:
trigger generateSCBAgreementPDF on Stem_Cell_Bank__c (after insert) { for(Stem_Cell_Bank__c scb : Trigger.new) { attachSCBPDF.attachPDF(trigger.new[0]); } }
My Class:
public with sharing class attachSCBPDF{ public static void attachPDF(Stem_Cell_Bank__c scb) { Attachment myAttach = new Attachment(); PageReference myPdf = Page.SCBPDF;//myPdfPage is the name of your pdf page Blob body; try { body = myPdf.getContentAsPdf(); } catch (VisualforceException e) { body = Blob.valueOf('Some Text'); } myAttach.ParentId = SCB.Id;//Id of the object to which the page is attached myAttach.name = 'DisplayName.pdf'; myAttach.body = body; insert myAttach; } }
The DisplayName.pdf is attached to Notes & Attachments, I see that 'Some Text' is caught and the body is not properly being rendered
The PageReference's getContent method does not work with triggers. But I believe I'm not using it directly through trigger, so I thought this would not apply to my situation.
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_pages_pagereference.htm
I've been stuck on this all day and would really appreciate it if someone can shed some light on this
Thank u for your efforts in advance
Daniel
- daniel1110
- May 09, 2013
- Like
- 0
- Continue reading or reply
trigger stuck at 62% coverage
Hi,
I have the following trigger, but it's my test code is not covered for line 10 and lines 15 and 16. I'm new to this and any suggestion would be appreciated.
line source 1 trigger updateSCBonTask1 on Task (after update) { 2 3 Set<Id> SCBIds = new Set<Id>(); 4 5 for(Task t: [SELECT Subject,WhatId, Status FROM Task WHERE ID IN:trigger.new]){ 6 7 String wId = t.WhatId; 8 9 if(wId!=null && !SCBIds.contains(t.WhatId) && t.Status == 'Completed' && t.Subject.Contains('Collect Enrollment Information')){ 10 SCBIds.add(t.WhatId); 11 } 12 } 13 14 for(Stem_Cell_Bank__c a:[SELECT stage__c FROM Stem_Cell_Bank__c WHERE ID IN:SCBIds]){ 15 a.stage__c = 'Process Payment'; 16 update a; 17 } 18 19 }
My test code:
@isTest public class updateSCBonT1Test { static testMethod void testupdateSCBonT1(){ Stem_Cell_Bank__c s = new Stem_Cell_Bank__c(); s.name = 'Test'; s.account__c = '001c000000AfLHOAA3'; test.startTest(); insert(s); LIST<Stem_Cell_Bank__c> a = [SELECT Id, Stage__c FROM Stem_Cell_Bank__c WHERE Name = 'Test']; Task testTask = new Task(Subject = 'Test', whatId = a[0].ID); insert(testTask); Stem_Cell_Bank__c updatedStem_Cell_Bank = [SELECT stage__c FROM Stem_Cell_Bank__c WHERE name = 'Test']; system.AssertEquals('Collect Enrollment Information',updatedStem_Cell_Bank.stage__c); testTask.Status='Completed'; update(testTask); Stem_Cell_Bank__c checkupdate = [SELECT stage__c FROM Stem_Cell_Bank__c WHERE name = 'Test']; system.AssertEquals('Process Payment',checkupdate.stage__c); test.stopTest(); } }
thank u in advance~
- daniel1110
- May 02, 2013
- Like
- 0
- Continue reading or reply
Customer Portal Manager Standard to access Opportunity
Hi,
Is it possible for Customer Portal Manager Standard to access Opportunity object?
I tried creating a VF page to expose opportunity with opportunity's standard detail page, but received a permissions error.
So, I tried exposing just the opportunity name field, but that still didn't work.
Is the opportunity object completely not sharable?
Any input/suggestions would be appreciated. Thank you in advance.
Daniel
- daniel1110
- April 10, 2013
- Like
- 0
- Continue reading or reply
Customer Portal Manager Standard to access Opportunity
Hi,
Is it possible for Customer Portal Manager Standard to access Opportunity object?
I tried creating a VF page to expose opportunity with opportunity's standard detail page, but received a permissions error.
So, I tried exposing just the opportunity name field, but that still didn't work.
Is the opportunity object completely not sharable?
Any input/suggestions would be appreciated. Thank you in advance.
Daniel
- daniel1110
- April 10, 2013
- Like
- 0
- Continue reading or reply
email content automatically justifies to center
Hi. My email template always justifies center even if I save it with left align. Can anybody guess why this might be happening?
Thank u,
Daniel
- daniel1110
- March 04, 2013
- Like
- 0
- Continue reading or reply
Leads where IsConverted=True is buried
I have some lead records that are buried under Leads and I cannot view them because the view filter criteria does not extend to what I need.
The records that are "buried" are Leads where IsConverted=True
I have these records pulling from the All leads report, but I cannot manage these records because I cannot view them from the lead object.
Can someone provide some light on this?
Thank you.
- daniel1110
- February 21, 2013
- Like
- 0
- Continue reading or reply
85% code coverage, but fails to deploy
Hi,
I'm trying to convert use VWFConvertLead plugin. It has 85% pass rate, but I cannot successfully push this to production
Here's the error I'm receiving
VWFConvertLead.basicTest() | Class | 133 | Failure Message: "System.DmlException: ConvertLead failed. First exception on row 0; first error: INVALID_STATUS, invalid convertedStatus: Qualified: []", Failure Stack Trace: "Class.VWFConvertLead.convertLead: line 133, column 1 Class.VWFConvertLead.invoke: line 22, column 1 Class.VWFConvertLead.basicTest: line 171, column 1" | |
VWFConvertLead.basicTestwithAccount() | Class | 133 | Failure Message: "System.DmlException: ConvertLead failed. First exception on row 0; first error: INVALID_STATUS, invalid convertedStatus: Qualified: []", Failure Stack Trace: "Class.VWFConvertLead.convertLead: line 133, column 1 Class.VWFConvertLead.invoke: line 22, column 1 Class.VWFConvertLead.basicTestwithAccount: line 205, ... | |
VWFConvertLead.basicTestwithAccounts() | Class | 133 | Failure Message: "System.DmlException: ConvertLead failed. First exception on row 0; first error: INVALID_STATUS, invalid convertedStatus: Qualified: []", Failure Stack Trace: "Class.VWFConvertLead.convertLead: line 133, column 1 Class.VWFConvertLead.invoke: line 22, column 1 Class.VWFConvertLead.basicTestwithAccounts: line 241,... |
The full code is at http://docs.database.com/dbcom/en-us/db_apex/apex_process_plugin_example_lead_convert.htm?version=182.0
Does anybody have any idea what I'm missing? Thank you in advance
- daniel1110
- February 13, 2013
- Like
- 0
- Continue reading or reply
unit test 0% coverage for this trigger
Hi. I'm still new at this so please bear with me. Here is a working trigger that add products to opportunity upon logic:
trigger LeadConvert on Lead (after update) {
RecordType ClientLead = [SELECT Id FROM RecordType WHERE SobjectType = 'Lead' AND Name = 'Client' LIMIT 1];
for (Lead l: Trigger.new) {
// no bulk processing; will only run from the UI & only trigger is lead record type is Client
if (Trigger.new.size() == 1 && l.RecordTypeId == ClientLead.Id) {
if (Trigger.old[0].isConverted == false && Trigger.new[0].isConverted == true) {
// if a new opportunity was created
if (Trigger.new[0].ConvertedOpportunityId != null && Trigger.new[0].RecordTypeId=='012E0000000UMzBIAW') {
// update the converted opportunity with some text from the lead
Opportunity opp = [Select o.Id, o.Description from Opportunity o Where o.Id = :Trigger.new[0].ConvertedOpportunityId];
opp.Description = Trigger.new[0].Name;
update opp;
// add an opportunity line item - Banking Enrollment Fee
OpportunityLineItem bef = new OpportunityLineItem();
bef.OpportunityId = opp.Id;
bef.Quantity = 1;
bef.TotalPrice = 3696.00;
bef.PricebookEntryId = [Select p.Id From PricebookEntry p Where Id = '01uE0000000mc6AIAQ' And IsActive = true limit 1].Id;
insert bef;
// add an opportunity line item - Mandatory Blood Screening
OpportunityLineItem mbs = new OpportunityLineItem();
mbs.OpportunityId = opp.Id;
mbs.Quantity = 1;
mbs.TotalPrice = 1027.00;
mbs.PricebookEntryId = [Select p.Id From PricebookEntry p Where Id = '01uE0000000mc65IAA' And IsActive = true limit 1].Id;
insert mbs;
// add an opportunity line item - Yearly Banking Fee
OpportunityLineItem ybf = new OpportunityLineItem();
ybf.OpportunityId = opp.Id;
ybf.Quantity = 1;
ybf.TotalPrice = 150.00;
ybf.PricebookEntryId = [Select p.Id From PricebookEntry p Where Id = '01uE0000000mc6FIAQ' And IsActive = true limit 1].Id;
insert ybf;
}
}
}
}
}
Here is the trigger that covers 0%
@IsTest(SeeAllData=true)
Public class ConvertLead_test{
static testmethod void Unittest(){
Opportunity opp = new Opportunity(Name='Test opp',CloseDate=system.today(),StageName='Banking',RecordTypeId='012E0000000UMzBIAW');// You need to populate all the mandatory field to insert opportunity record
insert opp;
OpportunityLineItem mbs = new OpportunityLineItem ();
mbs.OpportunityId = opp.id;
mbs.Quantity = 1;
mbs.TotalPrice = 3696.00;
mbs.PricebookEntryId = [Select p.Id From PricebookEntry p Where Id = '01uE0000000mc6AIAQ' And IsActive = true limit 1].Id;
insert mbs;
}
}
Any help would be appreciated. Thank u in advance.
- daniel1110
- February 01, 2013
- Like
- 0
- Continue reading or reply
help writing unit test
Hi. I'm new to force and having some trouble writing proper unit test for my trigger. The goal of this trigger is to attach a pdf to Notes & Attachments object. I would appreciate any help to get started in the right direction. I read the tutorials on writing unit tests, but still having problems. Trigger: trigger AttachAgreement on Opportunity (after insert) { if(trigger.new[0].RecordTypeId=='012E0000000UMzBIAW') { OpportunityPDFGenerator1.generateClientAgreementPDF(trigger.new[0]); } } Class: public with sharing class OpportunityPDFGenerator1 { public static final String FORM_HTML_START = '<HTML><BODY>'; public static final String FORM_HTML_END = '</BODY></HTML>'; public static void generateClientAgreementPDF(Opportunity opp) { datetime myDT = Datetime.now(); String myDate = myDT.format('h:mm a'); String pdfContent = '' + FORM_HTML_START; try { pdfContent = '' + FORM_HTML_START; pdfContent = pdfContent + 'body message goes here'; pdfContent = pdfContent + FORM_HTML_END; }catch(Exception e) { pdfContent = '' + FORM_HTML_START; pdfContent = pdfContent + '<P>THERE WAS AN ERROR GENERATING PDF: ' + e.getMessage() + '</P>'; pdfContent = pdfContent + FORM_HTML_END; } attachPDF(opp,pdfContent); } public static void attachPDF(Opportunity opp, String pdfContent) { try { Attachment attachmentPDF = new Attachment(); attachmentPDF.parentId = opp.Id; attachmentPDF.Name = 'EnrollmentAgreement.pdf'; attachmentPDF.body = Blob.toPDF(pdfContent); //This creates the PDF content insert attachmentPDF; }catch(Exception e) { opp.addError(e.getMessage()); } } }
|
- daniel1110
- February 01, 2013
- Like
- 0
- Continue reading or reply
Trigger: Update record of different record type with same field values
trigger createOrderforABFSCB1 on Stem_Cell_Bank__c (after update) { // Collect all updated SCB Ids Set<Id> setSCBIds = new Set<Id>(); // Collect all SCB Id which has stem cell banked date populated for(Stem_Cell_Bank__c scb : Trigger.new) { if (scb.Stage__c == 'Stem Cells Banked' && Trigger.oldMap.get(scb.Id).Stage__c != 'Stem Cells Banked') { setSCBIds.add(scb.Id); } } // List for collecting Orders to update List<ChargentOrders__ChargentOrder__c> colist = new List<ChargentOrders__ChargentOrder__c>(); // Iterate all the Orders of SCB for(ChargentOrders__ChargentOrder__c o : [SELECT Id, Account__c, Stem_Cell_Bank__c, ChargentOrders_Expiration_Month__c, ChargentOrders_Number__c, ChargentOrders_Type__c, ChargentOrders__Payment_Method__c, RecordTypeId FROM ChargentOrders__ChargentOrder__c WHERE Stem_Cell_Bank__c IN: setSCBIds]) { if(o.RecordTypeId == '012E0000000VPOC') { colist.add(new ChargentOrders__ChargentOrder__c(Id = o.Id, RecordTypeId = '012E0000000VPOH', ChargentOrders_Number__c = o.ChargentOrders_Number__c)); } } if(!colist.isEmpty()) { update colist; } }
- daniel1110
- July 22, 2014
- Like
- 0
- Continue reading or reply
Visual Workflow BUG - Missing Image
Hi. Does anyone know who do I need to speak with to have a bug fixed with visual workflow?
I tried contacting Basic Support and they directed me log this problem in developerforce
I'm not sure if I'm crazy of they are, but I thought developerforce is a collaboration of external developers
In my personal experience, basic support has been subpar to say the least and lack the technical knowledge to resolve some of the most simplistic problems
Here's an explanation of this bug:
When you progress through the visual workflow from one screen to another, there's an image named loading.gif, that shows the progression
The problem is this image is not being shown properly and shows as image missing. This problem shows up in Chrome, not sure if it's a cross brower issue
Any feedback would be appreciated
- daniel1110
- October 02, 2013
- Like
- 0
- Continue reading or reply
Too many SOQL queries 101 in testClass w/o for loop
Hi. I'm not using any for loop but getting System.LimitException: Too many SOQL queries: 101
The error is recognized in insert(testTask)
Sorry I'm not a good coder. Any suggestions would be appreciated. Thank you in advance.
@isTest public class updateSCBonT4Test { static testMethod void testupdateSCBonT4(){ Account testAccount = new Account(name='test account'); insert(testAccount); Stem_Cell_Bank__c s = new Stem_Cell_Bank__c(); s.name = 'Test'; // system.debug('value is = ' + testAccount.Id); s.account__c = testAccount.Id; test.startTest(); insert(s); LIST<Stem_Cell_Bank__c> a = [SELECT Id, Stage__c FROM Stem_Cell_Bank__c WHERE Name = 'Test']; Task testTask = new Task(Subject
= 'Collect Enrollment Information', whatId = a[0].ID); insert(testTask); Stem_Cell_Bank__c updatedStem_Cell_Bank = [SELECT stage__c FROM Stem_Cell_Bank__c WHERE name = 'Test']; system.AssertEquals('Collect Enrollment Information',updatedStem_Cell_Bank.stage__c); testTask.whatId = s.Id; testTask.Status='Completed'; update(testTask); Task testTask1 = new Task(Subject = 'Process Payment', whatId = a[0].ID); insert(testTask1); Stem_Cell_Bank__c updatedStem_Cell_Bank1 = [SELECT stage__c FROM Stem_Cell_Bank__c WHERE name = 'Test']; system.AssertEquals('Process Payment',updatedStem_Cell_Bank1.stage__c); testTask1.whatId = s.Id; testTask1.Status='Completed'; update(testTask1); Task testTask2 = new Task(Subject = 'Order Blood Test', whatId = a[0].ID); insert(testTask2); Stem_Cell_Bank__c updatedStem_Cell_Bank2 = [SELECT stage__c FROM Stem_Cell_Bank__c WHERE name = 'Test']; system.AssertEquals('Order Blood Test',updatedStem_Cell_Bank2.stage__c); testTask2.whatId = s.Id; testTask2.Status='Completed'; update(testTask2); Task testTask3 = new Task(Subject = 'Schedule Fat Extraction', whatId = a[0].ID); insert(testTask3); Stem_Cell_Bank__c updatedStem_Cell_Bank3 = [SELECT stage__c FROM Stem_Cell_Bank__c WHERE name = 'Test']; system.AssertEquals('Schedule Fat Extraction',updatedStem_Cell_Bank3.stage__c); testTask3.whatId = s.Id; testTask3.Status='Completed'; update(testTask3); Stem_Cell_Bank__c checkupdate = [SELECT stage__c, id FROM Stem_Cell_Bank__c WHERE name='Test']; System.debug(checkupdate.Id); System.debug(checkupdate.Stage__c); system.AssertEquals('Review Eligibility Test',checkupdate.stage__c); test.stopTest(); } }
- daniel1110
- August 20, 2013
- Like
- 0
- Continue reading or reply
Field set question or not...
Hi all!
Is it possible to create consecutive field set records from a detail page?
The reason I ask is I have 5 fields that need to be collected in "groups" and the number of these "groups" can be anywhere from 1 to 30.
If field set is not the solution to this, can anyone pls provide any workaround solution/recommendation?
Thank you! ^^
Daniel
- daniel1110
- August 02, 2013
- Like
- 0
- Continue reading or reply
System.NullPointerException pls help
trigger createOrderforABFSCB on Stem_Cell_Bank__c (after update) { List<ChargentOrders__ChargentOrder__c> co = new List<ChargentOrders__ChargentOrder__c>(); for (Stem_Cell_Bank__c scb : Trigger.new) { if (scb.Stage__c == 'Stem Cells Banked') { /*scb to oscb*/ //initiate the object to put values for furture record ChargentOrders__ChargentOrder__c c = new ChargentOrders__ChargentOrder__c(); //map Order fields to SCB that is being created for this Order c.Stem_Cell_Bank__c = scb.Id; /*scb to oscb*/ c.ChargentOrders__Date__c = date.today(); c.ChargentOrders__Gateway__c = 'xxxxxxxxxxxxxxxxx'; c.ChargentOrders__Currency__c = 'U.S. Dollar'; c.Order_Item__c = 'Yearly Subscription Fee'; // add one year to stem cell banked date c.ChargentOrders__Payment_Start_Date__c = scb.Stem_Cells_Banked_Date__c.addYears(1); //add this new object to the list that would be inserted later co.add(c); } //end if } //end for scb //once the loop is done, insert the new record to Order try{ insert co; } catch (system.Dmlexception e) { system.debug(e); } }
Hi, as you could see, i have a pretty straightforward trigger, but i am getting the following error:
System.NullPointerException: Attempt to de-reference a null object Trigger.createOrderforABFSCB
it appears to not like c.ChargentOrders__Payment_Start_Date__c = scb.Stem_Cells_Banked_Date__c.addYears(1);
Stem_Cells_Banked_Date__c is a DATE data type, but i can't seem to use the addYears() method
Any suggestion would be appreciated.
thank u
- daniel1110
- July 08, 2013
- Like
- 0
- Continue reading or reply
trigger stuck at 62% coverage
Hi,
I have the following trigger, but it's my test code is not covered for line 10 and lines 15 and 16. I'm new to this and any suggestion would be appreciated.
line source 1 trigger updateSCBonTask1 on Task (after update) { 2 3 Set<Id> SCBIds = new Set<Id>(); 4 5 for(Task t: [SELECT Subject,WhatId, Status FROM Task WHERE ID IN:trigger.new]){ 6 7 String wId = t.WhatId; 8 9 if(wId!=null && !SCBIds.contains(t.WhatId) && t.Status == 'Completed' && t.Subject.Contains('Collect Enrollment Information')){ 10 SCBIds.add(t.WhatId); 11 } 12 } 13 14 for(Stem_Cell_Bank__c a:[SELECT stage__c FROM Stem_Cell_Bank__c WHERE ID IN:SCBIds]){ 15 a.stage__c = 'Process Payment'; 16 update a; 17 } 18 19 }
My test code:
@isTest public class updateSCBonT1Test { static testMethod void testupdateSCBonT1(){ Stem_Cell_Bank__c s = new Stem_Cell_Bank__c(); s.name = 'Test'; s.account__c = '001c000000AfLHOAA3'; test.startTest(); insert(s); LIST<Stem_Cell_Bank__c> a = [SELECT Id, Stage__c FROM Stem_Cell_Bank__c WHERE Name = 'Test']; Task testTask = new Task(Subject = 'Test', whatId = a[0].ID); insert(testTask); Stem_Cell_Bank__c updatedStem_Cell_Bank = [SELECT stage__c FROM Stem_Cell_Bank__c WHERE name = 'Test']; system.AssertEquals('Collect Enrollment Information',updatedStem_Cell_Bank.stage__c); testTask.Status='Completed'; update(testTask); Stem_Cell_Bank__c checkupdate = [SELECT stage__c FROM Stem_Cell_Bank__c WHERE name = 'Test']; system.AssertEquals('Process Payment',checkupdate.stage__c); test.stopTest(); } }
thank u in advance~
- daniel1110
- May 02, 2013
- Like
- 0
- Continue reading or reply
Customer Portal Visualforce how set id of page when I click a tab
I am creating an alert tab for my customer portal users via a visualforce tab. I am grabbling the contactId via {$User.ContactID} and want to set the current page to this ID when a user click this tab from the Home tab. Am I going to have to make every tab a VF tab and pass the param that way or is there a way to set the Current Page id to a default id?
I'd like to have it automically set to something like this
https://c.cs7.visual.force.com/apex/Customer_Alerts?id=aid
<apex:page standardcontroller="Contact" showHeader="true">
<apex:param name="aid" value="{!$User.ContactId}"/>
<h1>Alerts will go here</h1><br/>
{!$User.ContactId}
{!Contact.name}<br/>
{!Contact.Alert_Management__r.Alert_Message__c}<br/>
{!Contact.Account.Name}
</apex:page>
Thanks in advance,
D
- Dahveed
- March 01, 2013
- Like
- 0
- Continue reading or reply
85% code coverage, but fails to deploy
Hi,
I'm trying to convert use VWFConvertLead plugin. It has 85% pass rate, but I cannot successfully push this to production
Here's the error I'm receiving
VWFConvertLead.basicTest() | Class | 133 | Failure Message: "System.DmlException: ConvertLead failed. First exception on row 0; first error: INVALID_STATUS, invalid convertedStatus: Qualified: []", Failure Stack Trace: "Class.VWFConvertLead.convertLead: line 133, column 1 Class.VWFConvertLead.invoke: line 22, column 1 Class.VWFConvertLead.basicTest: line 171, column 1" | |
VWFConvertLead.basicTestwithAccount() | Class | 133 | Failure Message: "System.DmlException: ConvertLead failed. First exception on row 0; first error: INVALID_STATUS, invalid convertedStatus: Qualified: []", Failure Stack Trace: "Class.VWFConvertLead.convertLead: line 133, column 1 Class.VWFConvertLead.invoke: line 22, column 1 Class.VWFConvertLead.basicTestwithAccount: line 205, ... | |
VWFConvertLead.basicTestwithAccounts() | Class | 133 | Failure Message: "System.DmlException: ConvertLead failed. First exception on row 0; first error: INVALID_STATUS, invalid convertedStatus: Qualified: []", Failure Stack Trace: "Class.VWFConvertLead.convertLead: line 133, column 1 Class.VWFConvertLead.invoke: line 22, column 1 Class.VWFConvertLead.basicTestwithAccounts: line 241,... |
The full code is at http://docs.database.com/dbcom/en-us/db_apex/apex_process_plugin_example_lead_convert.htm?version=182.0
Does anybody have any idea what I'm missing? Thank you in advance
- daniel1110
- February 13, 2013
- Like
- 0
- Continue reading or reply
unit test 0% coverage for this trigger
Hi. I'm still new at this so please bear with me. Here is a working trigger that add products to opportunity upon logic:
trigger LeadConvert on Lead (after update) {
RecordType ClientLead = [SELECT Id FROM RecordType WHERE SobjectType = 'Lead' AND Name = 'Client' LIMIT 1];
for (Lead l: Trigger.new) {
// no bulk processing; will only run from the UI & only trigger is lead record type is Client
if (Trigger.new.size() == 1 && l.RecordTypeId == ClientLead.Id) {
if (Trigger.old[0].isConverted == false && Trigger.new[0].isConverted == true) {
// if a new opportunity was created
if (Trigger.new[0].ConvertedOpportunityId != null && Trigger.new[0].RecordTypeId=='012E0000000UMzBIAW') {
// update the converted opportunity with some text from the lead
Opportunity opp = [Select o.Id, o.Description from Opportunity o Where o.Id = :Trigger.new[0].ConvertedOpportunityId];
opp.Description = Trigger.new[0].Name;
update opp;
// add an opportunity line item - Banking Enrollment Fee
OpportunityLineItem bef = new OpportunityLineItem();
bef.OpportunityId = opp.Id;
bef.Quantity = 1;
bef.TotalPrice = 3696.00;
bef.PricebookEntryId = [Select p.Id From PricebookEntry p Where Id = '01uE0000000mc6AIAQ' And IsActive = true limit 1].Id;
insert bef;
// add an opportunity line item - Mandatory Blood Screening
OpportunityLineItem mbs = new OpportunityLineItem();
mbs.OpportunityId = opp.Id;
mbs.Quantity = 1;
mbs.TotalPrice = 1027.00;
mbs.PricebookEntryId = [Select p.Id From PricebookEntry p Where Id = '01uE0000000mc65IAA' And IsActive = true limit 1].Id;
insert mbs;
// add an opportunity line item - Yearly Banking Fee
OpportunityLineItem ybf = new OpportunityLineItem();
ybf.OpportunityId = opp.Id;
ybf.Quantity = 1;
ybf.TotalPrice = 150.00;
ybf.PricebookEntryId = [Select p.Id From PricebookEntry p Where Id = '01uE0000000mc6FIAQ' And IsActive = true limit 1].Id;
insert ybf;
}
}
}
}
}
Here is the trigger that covers 0%
@IsTest(SeeAllData=true)
Public class ConvertLead_test{
static testmethod void Unittest(){
Opportunity opp = new Opportunity(Name='Test opp',CloseDate=system.today(),StageName='Banking',RecordTypeId='012E0000000UMzBIAW');// You need to populate all the mandatory field to insert opportunity record
insert opp;
OpportunityLineItem mbs = new OpportunityLineItem ();
mbs.OpportunityId = opp.id;
mbs.Quantity = 1;
mbs.TotalPrice = 3696.00;
mbs.PricebookEntryId = [Select p.Id From PricebookEntry p Where Id = '01uE0000000mc6AIAQ' And IsActive = true limit 1].Id;
insert mbs;
}
}
Any help would be appreciated. Thank u in advance.
- daniel1110
- February 01, 2013
- Like
- 0
- Continue reading or reply
help writing unit test
Hi. I'm new to force and having some trouble writing proper unit test for my trigger. The goal of this trigger is to attach a pdf to Notes & Attachments object. I would appreciate any help to get started in the right direction. I read the tutorials on writing unit tests, but still having problems. Trigger: trigger AttachAgreement on Opportunity (after insert) { if(trigger.new[0].RecordTypeId=='012E0000000UMzBIAW') { OpportunityPDFGenerator1.generateClientAgreementPDF(trigger.new[0]); } } Class: public with sharing class OpportunityPDFGenerator1 { public static final String FORM_HTML_START = '<HTML><BODY>'; public static final String FORM_HTML_END = '</BODY></HTML>'; public static void generateClientAgreementPDF(Opportunity opp) { datetime myDT = Datetime.now(); String myDate = myDT.format('h:mm a'); String pdfContent = '' + FORM_HTML_START; try { pdfContent = '' + FORM_HTML_START; pdfContent = pdfContent + 'body message goes here'; pdfContent = pdfContent + FORM_HTML_END; }catch(Exception e) { pdfContent = '' + FORM_HTML_START; pdfContent = pdfContent + '<P>THERE WAS AN ERROR GENERATING PDF: ' + e.getMessage() + '</P>'; pdfContent = pdfContent + FORM_HTML_END; } attachPDF(opp,pdfContent); } public static void attachPDF(Opportunity opp, String pdfContent) { try { Attachment attachmentPDF = new Attachment(); attachmentPDF.parentId = opp.Id; attachmentPDF.Name = 'EnrollmentAgreement.pdf'; attachmentPDF.body = Blob.toPDF(pdfContent); //This creates the PDF content insert attachmentPDF; }catch(Exception e) { opp.addError(e.getMessage()); } } }
|
- daniel1110
- February 01, 2013
- Like
- 0
- Continue reading or reply
apex trigger that creates a new record
OK so I've been an admin for about 3 years and (for better or worse) know more about SF than anyone in my company. i have some experience with apex and Visualforce, but little with triggers.
what i need is to write a trigger in production that does this: the trigger should create a new record in a custom object called "Vehicles" when an Opportunity record is created with a specific value in one of its custom fields (the field is called "Type"). So, when an opp is created and saved with Type = "x", then the trigger should fire, and a new vehicle object record should be created that is populated with a few fields from that opportunity record.
can anyone send me some code to show me what this trigger should be or look like? I've been researching this but have no clue, and I'm afraid of writing bad code that will cause problems.
also, the custom object is not in a parent-child relationship with the opporuntiy object, and i don't want it to be unless it has to be.
i know the developers in here are ridiculously smart and talented, and i'm just hoping one of you feels sorry enough for an amateur like me to help me out. thanks a lot.
- RossGilbert
- March 16, 2011
- Like
- 0
- Continue reading or reply