- Sebastian Jud
- NEWBIE
- 10 Points
- Member since 2016
- Zebraltar
-
ChatterFeed
-
0Best Answers
-
1Likes Received
-
0Likes Given
-
2Questions
-
3Replies
Help with a basic trigger to convert Leads to Opportunities
Convert a Lead to an Opportunity using triger
Hi guys given two fields on the lead object:
FieldA__c
FieldB__c
I need to write a trigger to convert from Lead to opportunity every time a user fill out those two fields. Can anyone help me with the trigger?
Thanks in advance!
Hi guys given two fields on the lead object:
FieldA__c
FieldB__c
I need to write a trigger to convert from Lead to opportunity every time a user fill out those two fields. Can anyone help me with the trigger?
Thanks in advance!
- Sebastian Jud
- March 22, 2018
- Like
- 1
- Continue reading or reply
I need to improve my code coverage
Hi everyone! I need to improve my code coverage, the current code coverage 62%. In my understanding the problem reside in Adobe Docusign. If I am right, is there any way to skip that?
this is the code:
public class UploadAttachmentControllerAccounts { public String selectedType {get;set;} public String description {get;set;} private Account account {get;set;} public String fileName {get;set;} public Blob fileBody {get;set;} public UploadAttachmentControllerAccounts(ApexPages.StandardController controller) { this.Account = (account)controller.getRecord(); } // creates a new Account_Attachment__c record private Database.SaveResult saveCustomAttachment() { Account_Document_Attachment__c obj = new Account_Document_Attachment__c(); obj.Account__c = Account.Id; obj.description__c = description; obj.type__c = selectedType; // fill out cust obj fields return Database.insert(obj); } // create an actual Attachment record with the Account_Attachment__c as parent private Database.SaveResult saveStandardAttachment(Id parentId) { Database.SaveResult result; Attachment attachment = new Attachment(); attachment.body = this.fileBody; attachment.name = this.fileName; attachment.parentId = parentId; // inser the attahcment result = Database.insert(attachment); // reset the file for the view state fileBody = Blob.valueOf(' '); return result; } /** * Upload process is: * 1. Insert new Account_Attachment__c record * 2. Insert new Attachment with the new Account_Attachment__c record as parent * 3. Update the Account_Attachment__c record with the ID of the new Attachment **/ public PageReference processUpload() { try { Database.SaveResult customAttachmentResult = saveCustomAttachment(); if (customAttachmentResult == null || !customAttachmentResult.isSuccess()) { ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Could not save attachment.')); return null; } Database.SaveResult attachmentResult = saveStandardAttachment(customAttachmentResult.getId()); if (attachmentResult == null || !attachmentResult.isSuccess()) { ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Could not save attachment.')); return null; } else { // update the custom attachment record with some attachment info Account_Document_Attachment__c customAttachment = [select id from Account_Document_Attachment__c where id = :customAttachmentResult.getId()]; customAttachment.name = this.fileName; customAttachment.Attachment__c = attachmentResult.getId(); update customAttachment; } } catch (Exception e) { ApexPages.AddMessages(e); return null; } return new PageReference('/'+Account.Id); } public PageReference back() { return new PageReference('/'+Account.Id); } }Test:
Thanks in advance!
- Sebastian Jud
- March 01, 2018
- Like
- 0
- Continue reading or reply
Help with a basic trigger to convert Leads to Opportunities
Convert a Lead to an Opportunity using triger
Hi guys given two fields on the lead object:
FieldA__c
FieldB__c
I need to write a trigger to convert from Lead to opportunity every time a user fill out those two fields. Can anyone help me with the trigger?
Thanks in advance!
Hi guys given two fields on the lead object:
FieldA__c
FieldB__c
I need to write a trigger to convert from Lead to opportunity every time a user fill out those two fields. Can anyone help me with the trigger?
Thanks in advance!
- Sebastian Jud
- March 22, 2018
- Like
- 1
- Continue reading or reply
Help with a basic trigger to convert Leads to Opportunities
Convert a Lead to an Opportunity using triger
Hi guys given two fields on the lead object:
FieldA__c
FieldB__c
I need to write a trigger to convert from Lead to opportunity every time a user fill out those two fields. Can anyone help me with the trigger?
Thanks in advance!
Hi guys given two fields on the lead object:
FieldA__c
FieldB__c
I need to write a trigger to convert from Lead to opportunity every time a user fill out those two fields. Can anyone help me with the trigger?
Thanks in advance!
- Sebastian Jud
- March 22, 2018
- Like
- 1
- Continue reading or reply
I need to improve my code coverage
Hi everyone! I need to improve my code coverage, the current code coverage 62%. In my understanding the problem reside in Adobe Docusign. If I am right, is there any way to skip that?
this is the code:
public class UploadAttachmentControllerAccounts { public String selectedType {get;set;} public String description {get;set;} private Account account {get;set;} public String fileName {get;set;} public Blob fileBody {get;set;} public UploadAttachmentControllerAccounts(ApexPages.StandardController controller) { this.Account = (account)controller.getRecord(); } // creates a new Account_Attachment__c record private Database.SaveResult saveCustomAttachment() { Account_Document_Attachment__c obj = new Account_Document_Attachment__c(); obj.Account__c = Account.Id; obj.description__c = description; obj.type__c = selectedType; // fill out cust obj fields return Database.insert(obj); } // create an actual Attachment record with the Account_Attachment__c as parent private Database.SaveResult saveStandardAttachment(Id parentId) { Database.SaveResult result; Attachment attachment = new Attachment(); attachment.body = this.fileBody; attachment.name = this.fileName; attachment.parentId = parentId; // inser the attahcment result = Database.insert(attachment); // reset the file for the view state fileBody = Blob.valueOf(' '); return result; } /** * Upload process is: * 1. Insert new Account_Attachment__c record * 2. Insert new Attachment with the new Account_Attachment__c record as parent * 3. Update the Account_Attachment__c record with the ID of the new Attachment **/ public PageReference processUpload() { try { Database.SaveResult customAttachmentResult = saveCustomAttachment(); if (customAttachmentResult == null || !customAttachmentResult.isSuccess()) { ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Could not save attachment.')); return null; } Database.SaveResult attachmentResult = saveStandardAttachment(customAttachmentResult.getId()); if (attachmentResult == null || !attachmentResult.isSuccess()) { ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Could not save attachment.')); return null; } else { // update the custom attachment record with some attachment info Account_Document_Attachment__c customAttachment = [select id from Account_Document_Attachment__c where id = :customAttachmentResult.getId()]; customAttachment.name = this.fileName; customAttachment.Attachment__c = attachmentResult.getId(); update customAttachment; } } catch (Exception e) { ApexPages.AddMessages(e); return null; } return new PageReference('/'+Account.Id); } public PageReference back() { return new PageReference('/'+Account.Id); } }Test:
Thanks in advance!
- Sebastian Jud
- March 01, 2018
- Like
- 0
- Continue reading or reply