• Abhilash Daslal
  • NEWBIE
  • 50 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 22
    Questions
  • 11
    Replies
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
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
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;
    }
}
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
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
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();
        }
}

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?