-
ChatterFeed
-
0Best Answers
-
2Likes Received
-
0Likes Given
-
22Questions
-
11Replies
After Insert Trigger not getting invoked
Hi ,
I have written a simple after insert trigger on Account such that for every new Account created, a new related Opportunity is created.
But the trigger is not getting invoked.Any ideas why this may be happening
trigger CreateNewAccountOpportunity on Account (after insert) {
List<Opportunity> oppList = new List<Opportunity>();
for(Account acc : Trigger.new){
Opportunity opp = new Opportunity();
opp.Name = acc.Name;
opp.StageName = 'Proposal';
opp.CloseDate = System.today() + 30;
oppList.add(opp);
}
System.debug('@@@---->'+Trigger.new);
System.debug('oppList---->'+oppList);
if(oppList.isEmpty() == false){
Database.insert(oppList);
}
}
I have written a simple after insert trigger on Account such that for every new Account created, a new related Opportunity is created.
But the trigger is not getting invoked.Any ideas why this may be happening
trigger CreateNewAccountOpportunity on Account (after insert) {
List<Opportunity> oppList = new List<Opportunity>();
for(Account acc : Trigger.new){
Opportunity opp = new Opportunity();
opp.Name = acc.Name;
opp.StageName = 'Proposal';
opp.CloseDate = System.today() + 30;
oppList.add(opp);
}
System.debug('@@@---->'+Trigger.new);
System.debug('oppList---->'+oppList);
if(oppList.isEmpty() == false){
Database.insert(oppList);
}
}
- Abhilash Daslal
- June 08, 2019
- Like
- 0
- Continue reading or reply
Need help testing the below code
Hi People,
I have written the folloing VF page usin custom controller and a test class. I am getting the following error. Plase help me solve this error
12:05:46:160 FATAL_ERROR System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [LastName]: [LastName]
VF Page: showContacts
<apex:page controller="showContactsController" tabstyle="Account">
<apex:pageBlock title="Recent Contacts">
<apex:pageblockTable value="{!conList}" var="con">
<apex:column >
<apex:facet name="header">Salesforce Id</apex:facet>
<apex:outputText value="{!con.id}"/>
</apex:column>
<apex:column >
<apex:facet name="header">Name</apex:facet>
<apex:outputText value="{!con.NAme}"/>
</apex:column>
</apex:pageblockTable>>
</apex:pageBlock>
<apex:form >
<apex:pageBlock title="Redirect">
<apex:commandButton value="Go To My Custom Page" action="{!doSubmit}"/>
</apex:pageBlock>
</apex:form>
<apex:form >
<apex:pageBlock title="Contact Form">
FIRST NAME:<apex:inputText value="{!con.FirstName}"/><br/><br/>
LAST NAME: <apex:inputText value="{!con.LastName}"/>
</apex:pageBlock>
<apex:commandButton value="Save" action="{!save}"/>
</apex:form>
</apex:page>
Controller: showContactsController
public with sharing class showContactsController {
public List<Contact> conList{get;set;}
public Contact con{get;set;}
public showContactsController(){
con = new Contact();
conList = [Select id,LastName,Name,Phone from Contact LIMIT 10];
}
public pagereference doSubmit(){
pagereference pageRef = new pagereference('/apex/PaginationRecords');
pageRef.setRedirect(true);
return pageRef;
}
public pagereference save(){
if(!String.isBlank(con.LastName))
System.debug('LastName------------>'+con.LastName);
insert con;
System.debug('Contact id---------->'+con.id);
return new pagereference('/'+con.id);
}
}
Test Class for Controller:
@isTest
public class showContactsController_Test {
public static testMethod void controllerTest(){
Account acc = new Account(Name='Test');
insert acc;
Contact con = new Contact(LastName='Test12',Phone='852149633',AccountId=acc.Id);
insert con;
Pagereference pageRef = Page.showContacts;
pageRef.getParameters().put('LastName','Test123');
pageRef.getParameters().put('id',con.id);
Test.setCurrentPage(pageRef);
Test.startTest();
showContactsController controller = new showContactsController();
PageReference pr1 = controller.doSubmit();
Pagereference pr2 = controller.save();
Test.stopTest();
System.assertEquals(pr2.getUrl(),'/'+con.Id);
}
}
I have written the folloing VF page usin custom controller and a test class. I am getting the following error. Plase help me solve this error
12:05:46:160 FATAL_ERROR System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [LastName]: [LastName]
VF Page: showContacts
<apex:page controller="showContactsController" tabstyle="Account">
<apex:pageBlock title="Recent Contacts">
<apex:pageblockTable value="{!conList}" var="con">
<apex:column >
<apex:facet name="header">Salesforce Id</apex:facet>
<apex:outputText value="{!con.id}"/>
</apex:column>
<apex:column >
<apex:facet name="header">Name</apex:facet>
<apex:outputText value="{!con.NAme}"/>
</apex:column>
</apex:pageblockTable>>
</apex:pageBlock>
<apex:form >
<apex:pageBlock title="Redirect">
<apex:commandButton value="Go To My Custom Page" action="{!doSubmit}"/>
</apex:pageBlock>
</apex:form>
<apex:form >
<apex:pageBlock title="Contact Form">
FIRST NAME:<apex:inputText value="{!con.FirstName}"/><br/><br/>
LAST NAME: <apex:inputText value="{!con.LastName}"/>
</apex:pageBlock>
<apex:commandButton value="Save" action="{!save}"/>
</apex:form>
</apex:page>
Controller: showContactsController
public with sharing class showContactsController {
public List<Contact> conList{get;set;}
public Contact con{get;set;}
public showContactsController(){
con = new Contact();
conList = [Select id,LastName,Name,Phone from Contact LIMIT 10];
}
public pagereference doSubmit(){
pagereference pageRef = new pagereference('/apex/PaginationRecords');
pageRef.setRedirect(true);
return pageRef;
}
public pagereference save(){
if(!String.isBlank(con.LastName))
System.debug('LastName------------>'+con.LastName);
insert con;
System.debug('Contact id---------->'+con.id);
return new pagereference('/'+con.id);
}
}
Test Class for Controller:
@isTest
public class showContactsController_Test {
public static testMethod void controllerTest(){
Account acc = new Account(Name='Test');
insert acc;
Contact con = new Contact(LastName='Test12',Phone='852149633',AccountId=acc.Id);
insert con;
Pagereference pageRef = Page.showContacts;
pageRef.getParameters().put('LastName','Test123');
pageRef.getParameters().put('id',con.id);
Test.setCurrentPage(pageRef);
Test.startTest();
showContactsController controller = new showContactsController();
PageReference pr1 = controller.doSubmit();
Pagereference pr2 = controller.save();
Test.stopTest();
System.assertEquals(pr2.getUrl(),'/'+con.Id);
}
}
- Abhilash Daslal
- April 21, 2019
- Like
- 0
- Continue reading or reply
Separate OWD for Contract object
Hi Guys,
I want users to be able to see only the contracts for which they are the owners, but in OWD there is option to set sharing for both 'Accounts and Contracts', but not Contracts separately. Please give suggestions to overcome this problem
Thanks,
Abhilash
I want users to be able to see only the contracts for which they are the owners, but in OWD there is option to set sharing for both 'Accounts and Contracts', but not Contracts separately. Please give suggestions to overcome this problem
Thanks,
Abhilash
- Abhilash Daslal
- March 28, 2019
- Like
- 0
- Continue reading or reply
how to use checkboxes with apex:selectList
Hi Guys,
I want to display a table of Account records with checkboxes in such a way that, whenever a checkbox is selected,it should display the related
Opportunities for the specific Account. Only one Account record must be selected at a time.
I was able to achieve similar functionality through Picklist, but how to do the same with checkboxes.
My Code for picklist is shown below
Controller
--------------
public class WrapperOpp {
public List<OppWrapper> Opplist = new List<OppWrapper>();
public String SelectedValue {get;set;}
public List<SelectOption> Accs {get{
List<SelectOption> AccName = new List<SelectOption>();
for(Account a :[Select Id, name from Account limit 10])
{
AccName.add(new SelectOption(a.name,a.name));
}
return AccName;
}
}
public PageReference refresh()
{
Opplist .clear();
for(Account a :[Select id,name,(Select name from opportunities) from Account where name =:SelectedValue])
{
for (opportunity opp :a.opportunities)
Opplist.add(new OppWrapper(false,opp));
}
return null;
}
public List<OppWrapper> getOppList()
{
System.debug('count'+Opplist.size());
return Opplist;}
public class OppWrapper{
public Boolean selected{get;set;}
public Opportunity opp{get;set;}
public OppWrapper(Boolean selected1, Opportunity opp1)
{
selected = selected1;
opp = opp1;
}
}
}
VF page
-------------
<apex:page controller="WrapperOpp" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:selectList value="{!SelectedValue}" size="1">
<apex:selectOptions value="{!Accs}"/>
<apex:actionSupport event="onchange" action="{!refresh}" reRender="OppTable"/>
</apex:selectList>
<apex:pageBlockTable value="{!Opplist}" id="OppTable" var="o">
<apex:column value="{!o.opp.Name}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Thanks,
Abhilash
I want to display a table of Account records with checkboxes in such a way that, whenever a checkbox is selected,it should display the related
Opportunities for the specific Account. Only one Account record must be selected at a time.
I was able to achieve similar functionality through Picklist, but how to do the same with checkboxes.
My Code for picklist is shown below
Controller
--------------
public class WrapperOpp {
public List<OppWrapper> Opplist = new List<OppWrapper>();
public String SelectedValue {get;set;}
public List<SelectOption> Accs {get{
List<SelectOption> AccName = new List<SelectOption>();
for(Account a :[Select Id, name from Account limit 10])
{
AccName.add(new SelectOption(a.name,a.name));
}
return AccName;
}
}
public PageReference refresh()
{
Opplist .clear();
for(Account a :[Select id,name,(Select name from opportunities) from Account where name =:SelectedValue])
{
for (opportunity opp :a.opportunities)
Opplist.add(new OppWrapper(false,opp));
}
return null;
}
public List<OppWrapper> getOppList()
{
System.debug('count'+Opplist.size());
return Opplist;}
public class OppWrapper{
public Boolean selected{get;set;}
public Opportunity opp{get;set;}
public OppWrapper(Boolean selected1, Opportunity opp1)
{
selected = selected1;
opp = opp1;
}
}
}
VF page
-------------
<apex:page controller="WrapperOpp" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:selectList value="{!SelectedValue}" size="1">
<apex:selectOptions value="{!Accs}"/>
<apex:actionSupport event="onchange" action="{!refresh}" reRender="OppTable"/>
</apex:selectList>
<apex:pageBlockTable value="{!Opplist}" id="OppTable" var="o">
<apex:column value="{!o.opp.Name}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Thanks,
Abhilash
- Abhilash Daslal
- November 11, 2018
- Like
- 0
- Continue reading or reply
Is there a book to learn salesforce lightning from scratch to expert level
Hi Guys,
I want to learn Lightning from scratch to expert level. Is there a book that you can suggest. I don't want to depend on trailers coz its Hardy to keep track of necessary trailhead at critical times.
Thanks,
Abhilash
I want to learn Lightning from scratch to expert level. Is there a book that you can suggest. I don't want to depend on trailers coz its Hardy to keep track of necessary trailhead at critical times.
Thanks,
Abhilash
- Abhilash Daslal
- November 09, 2018
- Like
- 0
- Continue reading or reply
Problem with my trigger
Hi Guys,
I have the following trigger which is not working as expected.
The User has a picklist field Colour__c which has values red,pink,purple,green and yellow.
The Account has a text field called Owner_Colour__c.
The Trigger assigns the Owner's colour while inserting the Account record.Please help
trigger AssignUserColourToAccount on Account (before insert , before update) {
List<Account> accList = new List<Account>();
String ownerColour = [Select id,Colour__c from User WHERE id=:UserInfo.getUserId()][0].Colour__c;
for (Account acc : trigger.new){
acc.Owner_Colour__c = ownerColour;
accList.add(acc);
}
}
Thanks,
Abhilash
I have the following trigger which is not working as expected.
The User has a picklist field Colour__c which has values red,pink,purple,green and yellow.
The Account has a text field called Owner_Colour__c.
The Trigger assigns the Owner's colour while inserting the Account record.Please help
trigger AssignUserColourToAccount on Account (before insert , before update) {
List<Account> accList = new List<Account>();
String ownerColour = [Select id,Colour__c from User WHERE id=:UserInfo.getUserId()][0].Colour__c;
for (Account acc : trigger.new){
acc.Owner_Colour__c = ownerColour;
accList.add(acc);
}
}
Thanks,
Abhilash
- Abhilash Daslal
- November 09, 2018
- Like
- 0
- Continue reading or reply
datacloud.matchresult
Hi Guys,
Can anyone give examples of usage of Datacloud.MatchResult in apex class. And how can I test it in test classes
Thanks,
Abhilash
Can anyone give examples of usage of Datacloud.MatchResult in apex class. And how can I test it in test classes
Thanks,
Abhilash
- Abhilash Daslal
- June 28, 2018
- Like
- 0
- Continue reading or reply
where can i learn lightning development
Hi Guys,
I want to learn Lightning development.Can you please share any sources or particular trailheads which can elp me in learning lightning development
Thanks,
Abhilash
I want to learn Lightning development.Can you please share any sources or particular trailheads which can elp me in learning lightning development
Thanks,
Abhilash
- Abhilash Daslal
- May 25, 2018
- Like
- 0
- Continue reading or reply
Platform developer 1 exam
Hi Guys,
I am about to take Platform developer 1 exam in 10 days. Has anyone taken the exam recently.if so, please share the methods you took for preparation. please suggest as to how to study for the exam
Thanks,
Abhilash
I am about to take Platform developer 1 exam in 10 days. Has anyone taken the exam recently.if so, please share the methods you took for preparation. please suggest as to how to study for the exam
Thanks,
Abhilash
- Abhilash Daslal
- May 01, 2018
- Like
- 0
- Continue reading or reply
How to cover Test.isRunningTest() in test class
Hi guys,
how can I cover if(Test.isRunningTest()) in test class. Can anyone give an example
Thanks,
Abhilash
how can I cover if(Test.isRunningTest()) in test class. Can anyone give an example
Thanks,
Abhilash
- Abhilash Daslal
- April 25, 2018
- Like
- 0
- Continue reading or reply
test method to cover for loop
Hi Guys,
I have the following code and want a test method to cover the for loop.Please give the test method so as to cover the for loop
Public class CreateDummyAccount{
Public static void dummyMethod(List<Account> accList){
try{
if(accList != NULL && !accList.isEmpty()){
List<Contact> conList = new List<Contact>();
for(Account acc : accList){
conList.add(new Contact(LastName = 'Larry'))
}
insert conList;
}
}
}
}
Thanks,
Abhilash
I have the following code and want a test method to cover the for loop.Please give the test method so as to cover the for loop
Public class CreateDummyAccount{
Public static void dummyMethod(List<Account> accList){
try{
if(accList != NULL && !accList.isEmpty()){
List<Contact> conList = new List<Contact>();
for(Account acc : accList){
conList.add(new Contact(LastName = 'Larry'))
}
insert conList;
}
}
}
}
Thanks,
Abhilash
- Abhilash Daslal
- April 18, 2018
- Like
- 1
- Continue reading or reply
how to cover the lines of method having multiple nested if statements
Hi Guys,
Can anyone give the test method for the following
public static List<Contact> updateContactList(Set<ID> setAccountID, Map<ID,Contact> mapContact,List<Contact> listNewContacts,List<Contact> listExistingContacts){
try{
Contact newContact = new Contact();
if(!setAccountID.isEmpty()){
listExistingContacts = [select id,LastName,Phone from Contact where Account in : setAccountID];
//Update existing Contact Records
if(listExistingContacts != null && !listExistingContacts.isEmpty()){
for(Contact existingContact :listExistingContacts){
newContact = mapContact.get(existingContact.Account);
if( existingContact.Required__c = true && (newContact.Account == existingContact.Account) ){
//No need to insert a new Contact record
if (listNewContacts.indexOf(newContact) !=-1 ){
listNewContacts.remove(listNewContacts.indexOf(newContact));
}else{}
}else if( existingContact.Required__c = true && (newContact.Account != existingContact.Account )){
existingContact.Required__c = false;
}
}
}
}
}catch(Exception ex){ex.getMessage();}
return listExistingContacts;
}
Can anyone give the test method for the following
public static List<Contact> updateContactList(Set<ID> setAccountID, Map<ID,Contact> mapContact,List<Contact> listNewContacts,List<Contact> listExistingContacts){
try{
Contact newContact = new Contact();
if(!setAccountID.isEmpty()){
listExistingContacts = [select id,LastName,Phone from Contact where Account in : setAccountID];
//Update existing Contact Records
if(listExistingContacts != null && !listExistingContacts.isEmpty()){
for(Contact existingContact :listExistingContacts){
newContact = mapContact.get(existingContact.Account);
if( existingContact.Required__c = true && (newContact.Account == existingContact.Account) ){
//No need to insert a new Contact record
if (listNewContacts.indexOf(newContact) !=-1 ){
listNewContacts.remove(listNewContacts.indexOf(newContact));
}else{}
}else if( existingContact.Required__c = true && (newContact.Account != existingContact.Account )){
existingContact.Required__c = false;
}
}
}
}
}catch(Exception ex){ex.getMessage();}
return listExistingContacts;
}
- Abhilash Daslal
- April 04, 2018
- Like
- 0
- Continue reading or reply
test method for the following method
Hi Guys,
Please give the test class for the following class
Public class getAccounts{
private String getAccountRecords(String AccuntId, String accountFor){
String recordId;
List<Account> accList =[Select id,Name,phone,Email from Account LIMIT 1];
if(!accList.isEmpty()){
recordId = accList[0].id;
}
return recordId;
}
}
Please give the test class for the following class
Public class getAccounts{
private String getAccountRecords(String AccuntId, String accountFor){
String recordId;
List<Account> accList =[Select id,Name,phone,Email from Account LIMIT 1];
if(!accList.isEmpty()){
recordId = accList[0].id;
}
return recordId;
}
}
- Abhilash Daslal
- March 30, 2018
- Like
- 0
- Continue reading or reply
Test class for a dynamic query
Hi Guys,
I want to write a test class for a controller class having dynamic query.please give examples....
Eg-
query = 'SELECT id' + ',' + fields +'FROM'+ objectName + 'WHERE' + queyCondition '=accId';
sObjectList = Database.query(query);
Thanks,
Abhilash
I want to write a test class for a controller class having dynamic query.please give examples....
Eg-
query = 'SELECT id' + ',' + fields +'FROM'+ objectName + 'WHERE' + queyCondition '=accId';
sObjectList = Database.query(query);
Thanks,
Abhilash
- Abhilash Daslal
- March 28, 2018
- Like
- 0
- Continue reading or reply
Assigning record ids to lookup fields on junction object
Hi,
I have the following code
Opportunity oppty = new Opportunity();
oppty.Name='123';
insert oppty;
Product2 pr = new Product2();
pr.Name = '123';
pr.Description = 'my product';
myJunctionObject obj = new myJunctionObject();
obj.Product2.id = pr.id; //
obj.Opportunity.id = oppty.id;
insert obj;
I am getting the error - Attempt to dereference a null object.Null pointer exception at 'insert obj;'
Can anyone suggest a solution to overcome this
Thanks,
Abhilash
I have the following code
Opportunity oppty = new Opportunity();
oppty.Name='123';
insert oppty;
Product2 pr = new Product2();
pr.Name = '123';
pr.Description = 'my product';
myJunctionObject obj = new myJunctionObject();
obj.Product2.id = pr.id; //
obj.Opportunity.id = oppty.id;
insert obj;
I am getting the error - Attempt to dereference a null object.Null pointer exception at 'insert obj;'
Can anyone suggest a solution to overcome this
Thanks,
Abhilash
- Abhilash Daslal
- March 23, 2018
- Like
- 0
- Continue reading or reply
Test class for the following controller class
Hi Guys,
Please give the test class for the following test class
public class ClsAccountController{
public contact con{get; set;}
public List<Account> AccountList{get; set;}
public Account acc{get;set;}
public id conID{get; set;}
public ClsAccountController(){
}
public List<Account> getConttacts(){
conID=ApexPages.currentPage().getParameters().get('id');
AccountList=new List<Account>();
AccountList=[Select Id,Name,Phone from Account where Contact=:conID];
return AccountList;
}
}
Thanks in advance,
Abhilash
Please give the test class for the following test class
public class ClsAccountController{
public contact con{get; set;}
public List<Account> AccountList{get; set;}
public Account acc{get;set;}
public id conID{get; set;}
public ClsAccountController(){
}
public List<Account> getConttacts(){
conID=ApexPages.currentPage().getParameters().get('id');
AccountList=new List<Account>();
AccountList=[Select Id,Name,Phone from Account where Contact=:conID];
return AccountList;
}
}
Thanks in advance,
Abhilash
- Abhilash Daslal
- March 21, 2018
- Like
- 0
- Continue reading or reply
Constructor vs method
Hi guys,
Can anyone tell me when a constructor is used and preferred more than a method.
What are the limitations of both method and constructor
Thanks,
Abhilash
Can anyone tell me when a constructor is used and preferred more than a method.
What are the limitations of both method and constructor
Thanks,
Abhilash
- Abhilash Daslal
- March 18, 2018
- Like
- 0
- Continue reading or reply
Test class for my controller class
Hi all,
I need a test class for the below controller class.Please help
public without sharing class ClsAccountController{
public List<Contact> Contactlist{get; set;}
public Account acc{get;set;}
public Id accId{get;set;}
public ClsAccountController(){
accId = ApexPages.currentPage().getParameters().get('id');
Contactlist = [Select id,LastName from Contact where
Account =: accId];
}
public ClsAccountController(ApexPages.StandardController controller){
acc = (Account)controller.getRecord();
Contactlist = [Select id,LastName from Contact where
Account =: acc.Id];
}
}
Thanks in advance,
Abhilash
I need a test class for the below controller class.Please help
public without sharing class ClsAccountController{
public List<Contact> Contactlist{get; set;}
public Account acc{get;set;}
public Id accId{get;set;}
public ClsAccountController(){
accId = ApexPages.currentPage().getParameters().get('id');
Contactlist = [Select id,LastName from Contact where
Account =: accId];
}
public ClsAccountController(ApexPages.StandardController controller){
acc = (Account)controller.getRecord();
Contactlist = [Select id,LastName from Contact where
Account =: acc.Id];
}
}
Thanks in advance,
Abhilash
- Abhilash Daslal
- March 17, 2018
- Like
- 0
- Continue reading or reply
Use a dynamic SOQL inside a VF component
I have controller class where I am using a dynamic query as shown below
String query = 'SELECT ' + newsletterField + ' FROM Contact WHERE Id = ' + user_id;
Contact[] myContacts = Database.query(query);
How to include the dynamic query inside a Visualforce Component and the same Visualforce component is later used in a VF page
Thanks....
String query = 'SELECT ' + newsletterField + ' FROM Contact WHERE Id = ' + user_id;
Contact[] myContacts = Database.query(query);
How to include the dynamic query inside a Visualforce Component and the same Visualforce component is later used in a VF page
Thanks....
- Abhilash Daslal
- March 15, 2018
- Like
- 0
- Continue reading or reply
Dynamic SOQL used inside a constructor
I want to use 2 constructors within my Controller class, one for a VF component and another for VF page.is it possible to have the same SOQL within 2 constructors.Please give an example
- Abhilash Daslal
- March 13, 2018
- Like
- 1
- Continue reading or reply
test method to cover for loop
Hi Guys,
I have the following code and want a test method to cover the for loop.Please give the test method so as to cover the for loop
Public class CreateDummyAccount{
Public static void dummyMethod(List<Account> accList){
try{
if(accList != NULL && !accList.isEmpty()){
List<Contact> conList = new List<Contact>();
for(Account acc : accList){
conList.add(new Contact(LastName = 'Larry'))
}
insert conList;
}
}
}
}
Thanks,
Abhilash
I have the following code and want a test method to cover the for loop.Please give the test method so as to cover the for loop
Public class CreateDummyAccount{
Public static void dummyMethod(List<Account> accList){
try{
if(accList != NULL && !accList.isEmpty()){
List<Contact> conList = new List<Contact>();
for(Account acc : accList){
conList.add(new Contact(LastName = 'Larry'))
}
insert conList;
}
}
}
}
Thanks,
Abhilash
- Abhilash Daslal
- April 18, 2018
- Like
- 1
- Continue reading or reply
Dynamic SOQL used inside a constructor
I want to use 2 constructors within my Controller class, one for a VF component and another for VF page.is it possible to have the same SOQL within 2 constructors.Please give an example
- Abhilash Daslal
- March 13, 2018
- Like
- 1
- Continue reading or reply
Problem with my trigger
Hi Guys,
I have the following trigger which is not working as expected.
The User has a picklist field Colour__c which has values red,pink,purple,green and yellow.
The Account has a text field called Owner_Colour__c.
The Trigger assigns the Owner's colour while inserting the Account record.Please help
trigger AssignUserColourToAccount on Account (before insert , before update) {
List<Account> accList = new List<Account>();
String ownerColour = [Select id,Colour__c from User WHERE id=:UserInfo.getUserId()][0].Colour__c;
for (Account acc : trigger.new){
acc.Owner_Colour__c = ownerColour;
accList.add(acc);
}
}
Thanks,
Abhilash
I have the following trigger which is not working as expected.
The User has a picklist field Colour__c which has values red,pink,purple,green and yellow.
The Account has a text field called Owner_Colour__c.
The Trigger assigns the Owner's colour while inserting the Account record.Please help
trigger AssignUserColourToAccount on Account (before insert , before update) {
List<Account> accList = new List<Account>();
String ownerColour = [Select id,Colour__c from User WHERE id=:UserInfo.getUserId()][0].Colour__c;
for (Account acc : trigger.new){
acc.Owner_Colour__c = ownerColour;
accList.add(acc);
}
}
Thanks,
Abhilash
- Abhilash Daslal
- November 09, 2018
- Like
- 0
- Continue reading or reply
Platform developer 1 exam
Hi Guys,
I am about to take Platform developer 1 exam in 10 days. Has anyone taken the exam recently.if so, please share the methods you took for preparation. please suggest as to how to study for the exam
Thanks,
Abhilash
I am about to take Platform developer 1 exam in 10 days. Has anyone taken the exam recently.if so, please share the methods you took for preparation. please suggest as to how to study for the exam
Thanks,
Abhilash
- Abhilash Daslal
- May 01, 2018
- Like
- 0
- Continue reading or reply
test method for the following method
Hi Guys,
Please give the test class for the following class
Public class getAccounts{
private String getAccountRecords(String AccuntId, String accountFor){
String recordId;
List<Account> accList =[Select id,Name,phone,Email from Account LIMIT 1];
if(!accList.isEmpty()){
recordId = accList[0].id;
}
return recordId;
}
}
Please give the test class for the following class
Public class getAccounts{
private String getAccountRecords(String AccuntId, String accountFor){
String recordId;
List<Account> accList =[Select id,Name,phone,Email from Account LIMIT 1];
if(!accList.isEmpty()){
recordId = accList[0].id;
}
return recordId;
}
}
- Abhilash Daslal
- March 30, 2018
- Like
- 0
- Continue reading or reply
Test class for the following controller class
Hi Guys,
Please give the test class for the following test class
public class ClsAccountController{
public contact con{get; set;}
public List<Account> AccountList{get; set;}
public Account acc{get;set;}
public id conID{get; set;}
public ClsAccountController(){
}
public List<Account> getConttacts(){
conID=ApexPages.currentPage().getParameters().get('id');
AccountList=new List<Account>();
AccountList=[Select Id,Name,Phone from Account where Contact=:conID];
return AccountList;
}
}
Thanks in advance,
Abhilash
Please give the test class for the following test class
public class ClsAccountController{
public contact con{get; set;}
public List<Account> AccountList{get; set;}
public Account acc{get;set;}
public id conID{get; set;}
public ClsAccountController(){
}
public List<Account> getConttacts(){
conID=ApexPages.currentPage().getParameters().get('id');
AccountList=new List<Account>();
AccountList=[Select Id,Name,Phone from Account where Contact=:conID];
return AccountList;
}
}
Thanks in advance,
Abhilash
- Abhilash Daslal
- March 21, 2018
- Like
- 0
- Continue reading or reply
Dynamic SOQL used inside a constructor
I want to use 2 constructors within my Controller class, one for a VF component and another for VF page.is it possible to have the same SOQL within 2 constructors.Please give an example
- Abhilash Daslal
- March 13, 2018
- Like
- 1
- Continue reading or reply
i am getting the message - 0/1 test methods passed
I am able to save the code, when i run the test class,it gives the error - 0/1 test methods passed
Please help..
Controller class
--------------------
public without sharing class ClsCustomController{
public List<myCustomObject__c> mylist{get; set;}
public myCustomObject__c myObject{get;set;}
public Id myId{get;set;}
public ClsCustomController(){
myId = ApexPages.currentPage().getParameters().get('id');
mylist = [select ID,Link__c,Product__c,Hierarchy_Name__c ,Item_Position__c,Primary_Product_Group__c ,
Probability__c ,Quantity__c ,
NetPrice__c,LineStatus__c ,
Validated__c,Line_Item_Id__c from myCustomObject__c where
Proposal__c =: myId];
}
public ClsCustomController(ApexPages.StandardController controller){
qte = (myCustomObject__c)controller.getRecord();
mylist = [select ID,Link__c,Product__c,Hierarchy_Name__c ,Item_Position__c,Primary_Product_Group__c ,
Probability__c ,Quantity__c ,
NetPrice__c,LineStatus__c ,
Validated__c,Line_Item_Id__c from myCustomObject__c where
Proposal__c =: myId];
}
}
---------------------------------------------------------------------------------------
test class
----------------
@isTest(SeeAllData=true)
public class ClsCustomController {
static testMethod void ClsCustomController() {
myCustomObject__c myObject = new myCustomObject__c();
myObject.id = propSO.id;
myObject.Hierarchy_Name__c = 'Indoor SF6-Insulated Load Break Switch GSec';
myObject.Item_Position__c ='1';
myObject.Primary_Product_Group__c = true;
myObject.Probability__c =Decimal.valueOf(30);
myObject.Quantity2__c =Decimal.valueOf(30);
myObject.NetPrice__c =Decimal.valueOf(1000);
myObject.LineStatus__c = 'Open';
myObject.Validated__c = true;
myObject.DerivedFromId__c = 'a2X25000004rSPuEAM';
insert proposalLineItem;
Test.startTest();
PageReference pageRef = Page.VFCustomController;
Test.setCurrentPage(pageRef);
pageRef.getParameters().put('id',myObject.id);
ApexPages.StandardController sc = new ApexPages.StandardController(myObject);
ClsCustomController myClass = new ClsCustomController(sc);
ClsCustomController myClass1 = new ClsCustomController();
Test.stopTest();
}
}
Please help..
Controller class
--------------------
public without sharing class ClsCustomController{
public List<myCustomObject__c> mylist{get; set;}
public myCustomObject__c myObject{get;set;}
public Id myId{get;set;}
public ClsCustomController(){
myId = ApexPages.currentPage().getParameters().get('id');
mylist = [select ID,Link__c,Product__c,Hierarchy_Name__c ,Item_Position__c,Primary_Product_Group__c ,
Probability__c ,Quantity__c ,
NetPrice__c,LineStatus__c ,
Validated__c,Line_Item_Id__c from myCustomObject__c where
Proposal__c =: myId];
}
public ClsCustomController(ApexPages.StandardController controller){
qte = (myCustomObject__c)controller.getRecord();
mylist = [select ID,Link__c,Product__c,Hierarchy_Name__c ,Item_Position__c,Primary_Product_Group__c ,
Probability__c ,Quantity__c ,
NetPrice__c,LineStatus__c ,
Validated__c,Line_Item_Id__c from myCustomObject__c where
Proposal__c =: myId];
}
}
---------------------------------------------------------------------------------------
test class
----------------
@isTest(SeeAllData=true)
public class ClsCustomController {
static testMethod void ClsCustomController() {
myCustomObject__c myObject = new myCustomObject__c();
myObject.id = propSO.id;
myObject.Hierarchy_Name__c = 'Indoor SF6-Insulated Load Break Switch GSec';
myObject.Item_Position__c ='1';
myObject.Primary_Product_Group__c = true;
myObject.Probability__c =Decimal.valueOf(30);
myObject.Quantity2__c =Decimal.valueOf(30);
myObject.NetPrice__c =Decimal.valueOf(1000);
myObject.LineStatus__c = 'Open';
myObject.Validated__c = true;
myObject.DerivedFromId__c = 'a2X25000004rSPuEAM';
insert proposalLineItem;
Test.startTest();
PageReference pageRef = Page.VFCustomController;
Test.setCurrentPage(pageRef);
pageRef.getParameters().put('id',myObject.id);
ApexPages.StandardController sc = new ApexPages.StandardController(myObject);
ClsCustomController myClass = new ClsCustomController(sc);
ClsCustomController myClass1 = new ClsCustomController();
Test.stopTest();
}
}
- Abhilash Daslal
- March 12, 2018
- Like
- 0
- Continue reading or reply
Problem posting snapshot of dashboard on chatter feed.
This is the trailhead challenge I'm working on.
Create a report of Opportunities grouped by Type. Then follow the dashboard and share a snapshot on Chatter.
Name the report 'Opportunities by Type' and save it to the 'Unfiled Public Reports' folder.
The report must be of type Opportunities.
The report format must be a Summary report.
The report must be grouped by 'Type'.
The date range should be for All Time.
You can include any columns you like, but must include 'Amount' as one of the columns.
Create a dashboard named 'Opportunities Dashboard' and save it to the 'My Personal Dashboards' folder.
Create a dashboard component on the dashboard using the report you just created.
Set the header to 'Opptys by Type' and the title to 'For all time' for the dashboard component.
Use the horizontal bar chart dashboard component, and ensure the record count is displayed on the x-axis.
Follow the 'Opportunities Dashboard' dashboard in Chatter. Make sure that Feed Tracking is enabled for Dashboards first.
Post a snapshot of the 'Opptys by Type' dashboard component to Dashboard Chatter feed.
But I'm getting the following error when I check if the challenge has been completed
Challenge Not yet complete... here's what's wrong:
The dashboard snapshot post to Chatter was not found.
Can someone hepl me?
If possible post the snapshots?
- Kalashree Borgaonkar 5
- May 26, 2016
- Like
- 0
- Continue reading or reply