• Mukesh_SfdcDev
  • NEWBIE
  • 55 Points
  • Member since 2016

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 32
    Replies
in a vf page u have 2 buttons 
   if click button 1 then display pageblock1 only,and button1 will disable
   if click button2 then disply pageblock2 only,and button2 will disable.....
Hi,

I have created a visualforce page that shows the lists of al the Accounts in my org. Now I have to display the count of hits this page has? I think we can create a custom object for this but since I am new to this I don't know the exact way to do this. Can anyone help me with this ?

Below is how I created the Visualforce page.

<apex:page standardController="Account" recordSetVar="accounts" sidebar="false">
    <apex:pageBlock title="List of Accounts">
        <apex:form >
          <apex:pageBlockTable value="{!accounts}" var="acct" id="list">
            <apex:column value="{!acct.Name}"/>
            <apex:column value="{!acct.type}"/>
            <apex:column value="{!acct.billingCountry}" />
            <apex:column value="{!acct.shippingCountry}"/>
            <apex:column value="{!acct.createdById}"/>
          </apex:pageBlockTable>
        </apex:form>
      </apex:pageBlock>
</apex:page>
 
Hi,

I have added a component in quick action button in lightning and this button show the standard modal.
And I want to remove/hide this standard modal, Is there any solution to remove the standard quick action modal.

Here is the code of component
<aura:component controller="somecontrollername" implements="flexipage:availableForRecordHome,force:appHostable,force:hasRecordId,force:lightningQuickActionWithoutHeader" access="global" >
<!-- Declared component attributes -->
<aura:attribute name="recordId" type="Id"/>
<aura:attribute name="message" type="String" default="false"/>
<lightning:notificationsLibrary aura:id="notifLib"/>

<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<lightning:spinner class="slds-show" variant="brand" size="small" aura:id="mySpinner" />
<!-- main div start -->

</aura:component>

User-added image
and this component is added on quick action button.
 
Hi Expert,

how to retrieve more than 2000 records returned from the rest api in Salesforce.
When I execute the below query through rest api then it will return only 2000 records.
https://" + instanceName + ".salesforce.com/services/data/v35.0/query?q='SELECT+Id,Name,ParentId,Phone,Website,Description,OwnerId+FROM+Account'

I'm stuck on this salesforce limit.
Help on this how to get more than 2000 records through rest api.

Thanks & Regards
Mukesh Kumar
Hi Experts,

I want to get the metadata result of workflow rule and Validation Rule through tooling api.
but salesforce have a limit "Query this field only if the query result contains 
no more than one record. Otherwise, an error is returned. If more than one record exists, 
use multiple queries to retrieve the records. This limit protects performance."

this query working fine:
/services/data/v41.0/tooling/query/?q=Select+Name,MetaData,TableEnumOrId+From+WorkflowRule+LIMIT+1

but I want more than record like the below query and this not work : 
/services/data/v41.0/tooling/query/?q=Select+Name,MetaData,TableEnumOrId+From+WorkflowRule
is there another alternate solution to overcome of such type of situation.

Thanks 
Mukesh Kumar
Hello,

I need some help in my test class which has written on Trigger.

My Test Class :

@isTest
public class AccountNameUpdate {  
  @isTest  static void updateAccount(){
        Account a = new Account();
        a.Name = 'Abhishek Gupta';
        insert a;
        Booking_Link__c bl= new Booking_Link__c();
        bl.Customer_Number__c = a.Customer_Number__pc;
        bl.T2G__c =True;
        bl.Account__c = a.Id;
        bl.OwnerId = a.OwnerId;
        update bl;
    }

}


My Trigger:

trigger AccountNameUpdate on Booking_Link__c (before insert, before update) {
    List<Account> accountList = new List<Account>();
    String CustomNumber;
    for(Booking_Link__c bl : Trigger.new)
    {       
        CustomNumber = bl.Customer_Number__c;
       
    }
    accountList = [Select Id, OwnerId, Customer_Number__pc from Account where Customer_Number__pc =:CustomNumber ];
    for(Booking_Link__c bl : Trigger.new)
    {
        for(Account a : accountList)
        {
           if(bl.Customer_Number__c == a.Customer_Number__pc && bl.T2G__c==True)
            {
                bl.Account__c = a.Id;
                bl.OwnerId = a.OwnerId;
                  
            }
        }
    }  
}

Please Help me out from this

Thanks and Regards,
Azar Khasim.
Hi All,
          i wanna know about this line?
Case caseObj = caseRecords.get(0);
Hello everyone,
I have created a trigger which will update Contact Object field(Most_recent_Opportunity_Stage__c) whenever opportunity status gets changed.
My trigger is working fine but associated Test class is not making 75% code coverage of Trigger. I am new to salesforce and not having much experince to build test class so please help me.

Here is my Trigger and associated test class :

Trigger :

trigger UpdateMostRecentOpportunityStageOfContact on Opportunity (after update) {
  Set<String> ContactIds = new Set<String>();
     Set<String> oppIds = new Set<String>();
     if(UpdateStageOnContactHandler.isFirstTime){
             UpdateStageOnContactHandler.isFirstTime=false;
    List<OpportunityContactRole> conList = new List<OpportunityContactRole>([select ContactId from OpportunityContactRole where IsPrimary = true and OpportunityId IN :Trigger.newMap.keySet() limit 1]);
     for(OpportunityContactRole c :conList)
       {
           ContactIds.add(c.ContactId);
       }    
    List<OpportunityContactRole> oppList =  new List<OpportunityContactRole>([select ContactId,opportunityId,CreatedDate from OpportunityContactRole where IsPrimary = true and ContactId =: ContactIds order by CreatedDate desc  limit 1]);
    for(OpportunityContactRole cr :oppList)
       {
           oppIds.add(cr.opportunityId);
       } 
    if(!oppIds.isEmpty()){
    Opportunity op = [select StageName from opportunity where Id =:oppIds limit 1]; 
    List<Contact> contactToUpdate = new List<Contact>();
    for(Opportunity opp : trigger.new){
           for(OpportunityContactRole c :oppList){ 
                if(opp.AccountId != null){
                 contactToUpdate.add(new Contact(Id = c.ContactId, Most_recent_Opportunity_Stage__c=op.StageName)); 
               }
           }    
       }
       if (contactToUpdate != null && !contactToUpdate.isEmpty())
        {
            Update contactToUpdate;
        } 
     }
   }      
 }


TEST Class :

@isTest
public class TestUpdateMostRecentopportunityStage {
   static testMethod void TestUpdateStageOnContactTest()
    {   
        Account a = new Account(Name = 'TestUpdateStageOnContactTest');
        a.Type = 'Prospect';
        insert a;

        Contact newContact1 = new Contact(Lastname='TestUpdateStageOnContactTest1', AccountId = a.Id ,Email='mayanks+test1@webgility.com' );
        insert newContact1;
        
        Contact newContact2 = new Contact(Lastname='TestUpdateStageOnContactTest2', AccountId = a.Id ,Email='mayanks+test2@webgility.com' );
        insert newContact2;
    
      
        Opportunity o1 = new Opportunity(AccountId=a.Id, name='OPP test1', StageName='Demo', CloseDate = Date.today() );
       insert o1;
        OpportunityContactRole ocr1 = new OpportunityContactRole(OpportunityId = o1.Id, ContactId = newContact1.Id, Role='Decision Maker',Isprimary=true );
        insert ocr1;
        
          Opportunity o2 = new Opportunity(AccountId=a.Id, name='OPP test2', StageName='Open', CloseDate = Date.today() );
       insert o2;
        OpportunityContactRole ocr2 = new OpportunityContactRole(OpportunityId = o2.Id, ContactId = newContact2.Id, Role='Decision Maker',Isprimary=true );
        insert ocr2;
        
          Test.StartTest();
        o1.stageName='Demo';
        update o1;
        newContact1.Most_recent_Opportunity_Stage__c='Demo';
        update newContact1;
        
         o2.stageName='Open';
        update o2;
        newContact2.Most_recent_Opportunity_Stage__c='Open';
        update newContact2;
        
        Test.StopTest();
         
      }   
}


Thanks,
Mayank
Hi,

I have added a component in quick action button in lightning and this button show the standard modal.
And I want to remove/hide this standard modal, Is there any solution to remove the standard quick action modal.

Here is the code of component
<aura:component controller="somecontrollername" implements="flexipage:availableForRecordHome,force:appHostable,force:hasRecordId,force:lightningQuickActionWithoutHeader" access="global" >
<!-- Declared component attributes -->
<aura:attribute name="recordId" type="Id"/>
<aura:attribute name="message" type="String" default="false"/>
<lightning:notificationsLibrary aura:id="notifLib"/>

<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<lightning:spinner class="slds-show" variant="brand" size="small" aura:id="mySpinner" />
<!-- main div start -->

</aura:component>

User-added image
and this component is added on quick action button.
 

Hi, can somebody advice how to create test class for this pagination?

Controller:

public class ParseCSVController {
    
	public Blob csvFileBody{get;set;}
	public string csvAsString{get;set;}
	public String[] csvFileLines{get;set;}
	public List<Car_detail__c> DetailList{get;set;}
    public List<SelectOption> paginationSizeOptions{get;set;}
    public List<Car_Detail__c> showNow{get;set;}
	public List<NumRecOnPage__c> PageSize{get;set;} 
	public integer ResultSize{get;set;} 
	public integer PageNumber{get;set;} 
	public integer limitSize{get;set;}
    public Integer counter = 0;
	
public ParseCSVController(){

	csvFileLines = new String[]{};
    showNow = new List<Car_Detail__c>();
	DetailList = New List<Car_detail__c>();
        PageSize = NumRecOnPage__c.getAll().values(); 
        limitSize = PageSize[0].Number_Records__c.intValue() ;
        ResultSize = 0;
        PageNumber = counter;
  }
    
    
    public boolean getHasNext(){
        if(PageNumber<getNumPages())
            return true;
        return false;
    }
    public boolean getHasPrevious(){
        if(PageNumber>1)
            return true;
        return false;
    }
    public void Next(){
        showNow.clear();
        counter+=1;
        PageNumber += 1;
        
        integer i0 = counter * limitSize;

        for(integer i = i0 ;i<ResultSize;i++){
            if(i<(i0+limitSize)){
                showNow.add(DetailList.get(i));
            }else break;
        }
    }
    public void Previous(){
        showNow.clear();
        PageNumber = PageNumber-1;
        counter=counter-1;
        
        integer i0 = counter * limitSize;
        
        for(integer i = i0 ;i<ResultSize;i++){
            if(i<(i0+limitSize)){
                showNow.add(DetailList.get(i));
            }else break;
        }
    }
    public void reload(){
        showNow.clear();
        PageNumber = 1;
        counter = 0;
        integer i0 = counter * limitSize;
        for(integer i=i0;i<ResultSize;i++){
            if(i<i0+limitSize){
                showNow.add(DetailList.get(i));
            }else break;
        }  
    }
    public integer getNumPages(){
        integer ost = math.mod(ResultSize, limitSize);
        if(ost>0)
            return ResultSize/limitSize+1;
        return ResultSize/limitSize;
    }
    public void First(){
        counter = 0;
        PageNumber = 1;
        showNow.clear();
        for(integer i=0;i<ResultSize;i++){
            if(i<limitSize){
                showNow.add(DetailList.get(i));
            }else break;
        }  
    }
public void Last(){
	counter = getNumPages()-1;
	PageNumber = getNumPages();
	showNow.clear();
        
	integer i0 = counter*limitSize;
	for(integer i=i0;i<ResultSize;i++){
		if(i<(i0+limitSize)){
			showNow.add(DetailList.get(i));
            }else break;
        }  
    }
public integer getCounterValue(){
        return counter;
    }

Test class(that i have ATM):
@isTest
public class ParseCSVControllerTest {
static testMethod void getCustomSettings(){ 
	NumRecOnPage__c customSet = new NumRecOnPage__c(); 
	customSet.Name = '10'; 
	customSet.Number_Records__c = 10; 
	insert customSet; 

	Car__c[] TestCars = new Car__c[]{new Car__c(Name = 'Mersedes'), new Car__c(Name = 'Audi'), 
	new Car__c(Name = 'BMW')}; 

	insert TestCars; 
}  
}

 
Hi All,

Automatically created the 2 child records when parent(Account) record is created? Best approach (Process builder or Apex trigger)?


Thanks,
Malakondaiah
Hi guys, i have one visual force page that i have no idea how to edit. I need to add an additional field called 'Customer Ref' the API name is 'Customer_Ref__c"

The screen shot below shows the location on the page layout where i need to add it 
User-added image
 Below is the visualforce page and the section where i need to add that extra field. I need to add it after the booking type field
User-added image

Any help would be appreciated as i have no idea about visualforce pages. Also is this the only this required to add this to the page?
I have a VF page that creates a contact, but I want the form to redirect to a Thank You page rather than try to open the newly created contact in SF.  Here is my extension coding:

public class ContactSaveExtension {

    ApexPages.StandardController controller;

    public ContactSaveExtension(ApexPages.StandardController controller) {
        this.controller = controller;
    }

    public PageReference saveAndRedirect() {
        controller.save();
        PageReference redirect = new PageReference('ApexPage.Thank_You');
        redirect.setRedirect(true);
        return redirect;
    }

}

What am I missing?

Thank you!
trigger UpdateStage on Account (after insert, after update) {   // Performs Custom actions after Record gets saved.
   
    List<Id> accountId = new List<Id>(); // get the list of all Account's ID to be Updated.
    
    for(Account acc : Trigger.new)
    {
        if(acc.All_Opportunities_Won__c==True)   // Checks if the Condition is True. 
            accountId.add(acc.Id);
    }
    
    List<Opportunity> oppsToUpdate = new List<Opportunity>();
    
    for(Opportunity opp : [select id, StageName, Amount from Opportunity where AccountId in: accountId AND Amount != 0]) // used to get all records from above ID.
    {
        opp.StageName='Closed-Won';   //Update StageName in Opportunity
        oppsToUpdate.add(opp); 
    }
    
    update oppsToUpdate;   // Update all Opportunity in List.
}

 
trigger checkboxupdate on Opportunity (Before insert) 
{ if(trigger.isInsert)               // While entering a new record in Opp
   {  for(Opportunity acc:trigger.new)
      { acc.IsPrivate=True;}
 }

If above is my code. How will be 1% code coverage for the Trigger which does not have a helper class or method ?  Please suggest for my question.
Hi 

I have a REST Class exoposed from salesforce is used to create an Account and Contact from a web form elsewhere in the company. 

It was working fine until 2 days ago and now i have the error (in description). 

Can anyone please help me understabd why?

Thanks in Advance
Sri