• Ashlekh
  • PRO
  • 3545 Points
  • Member since 2012

  • Chatter
  • 102
    Best Answers
  • 0
    Likes Received
  • 7
    Likes Given
  • 22
  • 800
Can you please help me to write the Test Class of the following Class?
public class LeadSearchController {
public Lead leadRecord {get; set;}
public List<Lead> leadList {get; set;}

public LeadSearchController(ApexPages.StandardController controller) {
leadRecord = new Lead();
leadList = new List<Lead>();

public void getLeadData() {
if(leadRecord.Rating != null){
leadList = [SELECT Id, Name, Email, Rating FROM Lead WHERE Rating != null AND Rating =: leadRecord.Rating];

Thanks in advance
I have a apex controller as followingly :
Public class datareturn{

    //public String lst { get; set; }
    Public class innerClass{
         Account acct {get; set;}
         Contact cont {get; set;}
         Opportunity opps {get; set;}
         public innerClass(){
             this.acct = new Account();
             this.cont = new Contact();
             this.opps = new Opportunity();
              Public List<innerClass> lstList{get;set;}
                Public datareturn(){
                lstList = new List<innerClass>();
                 List<Account> lstAccount = [Select Id, Name, (Select Id, Name, Email, Phone from Contacts), 
                                                (Select Id, Name, Amount, CloseDate from Opportunities) From Account];
                         for(Account acct:lstAccount){
                            ///lst.acct = acct;
                            List<Contact> contactlist = acct.Contacts;
                            List<Opportunity> opportunitylist = acct.Opportunities;
                               Integer contactsize = acct.Contacts.size();
                                Integer Opportunitysize = acct.Opportunities.size();
                                Integer n;
                               if(contactsize >Opportunitysize){
                                        n = contactsize;
                                       n = Opportunitysize;
                                for(Integer i = 0; i<n ; i++){
                                        innerClass lst = new innerClass();
                                           lst.acct = acct;
                                         lst.cont =  contactlist[i];
                                         lst.opps =  opportunitylist[i];
                             //   }
But I Have an error : System.ListException: List index out of bounds: 0
in the line 50. So that's why I want a help. 
Hi Guys.

I created a method that gets the number of weekend days between 2 dates.However when executing it, it throws a System.LimitException: Apex CPU time limit exceeded error. How can I solve this.. see code below. Thanks.
public static integer getNumberOfWeekendDaysPerMonth(Datetime startDate, Datetime endDate){
        integer i = 0;
        while (startDate < endDate) {
            if(startDate.format('E') == 'Sat' || startDate.format('E') == 'Sun') { // The line that throws the error.
                i += 1;
        return i;

1) What is a junction object?

a) A custom object with one lookup relationship and one master-detail relationship.
b) A custom object with two lookup relationships.
c) A custom object with any number of lookup and master-detail relationships.
d) A custom object with two master-detail relationships.

Ans:- d
2) What is the name of the standard relationship from Account down to Contact?

a) Contacts
b) Contact
c) Accounts
d) Account

Ans:- a
3) When running an Apex test, which type of Apex syntax in tested code is counted in the code coverage calculation?

a) A variable assignment.
b) A blank line.
c) A System.debug() statement.
d) A comment.

Ans:- a
4) Which method is defined in the StandardController class? Choose 2 answers

a) Undelete
b) Merge
c) Cancel
d) Save

Ans:- c and d
5) What is the return type of a SOSL search?

a) A list of sObjects.
b) A list of AggregateResults.
c) A list of lists of sObjects.
d) An sObject.

Ans:- c

Thanks and Regards,

I have piece of code like below
List<Account> accountList = [SELECT  Id, Name, Column1__c, Column2__c, Column3__c, ParentId
                             FROM Account 
                             WHERE Id = '001b000000r6WE3' LIMIT 1];

if(accountList  !=  null && accountList .size() > 0){
    CustomObject1__c cObjRec = new CustomObject1__c();
	cObjRec.Name = accountList[0].Name;
	cObjRec.Column1__c = accountList[0].Column1__c;
	cObjRec.Column2__c = accountList[0].Column2__c;
	cObjRec.Column3__c = accountList[0].Column3__c;  
       cObjRec.Parent_Account__c = 'a008E000001Vzxq';

       insert cObjRec;

In above code, I copy an account record (001b000000r6WE3) to new object CustomObject1__c.

How can i mass update (many accounts) at one time ?
Also what will be the limitations ?
I was planning to specify in where clause Record type = XYZ but this give 20000 records, so i need a solution.

Thank you for sugggesting
  • January 26, 2016
  • Like
  • 0
How to check Cloak of Adventure sweatshirt is available for my account.

I have completed the challeges and got 6 badges.Compass of Wisdom badge is showing in my profile.

But where to check Cloak of Adventure sweatshirt available or not for my profile .


Here is the Code.

public class actionFunctionController {
    public Account acc{get;set;}
    public Boolean showPhone{get;set;}
    public actionFunctionController(){
        acc = new Account();
        showPhone = false;
    public PageReference priorityChanged(){
        if(acc.CustomerPriority__c == 'High'){
            showPhone = true;
            showPhone = false;
        return null;
public with sharing class leadConvert {

    public Account acc { get; set; }
     public Lead  led{ get; set; }

public leadConvert(){

 led= new Lead();


public List<Account> acclist{get;set;}
  public void accounts()
      Lead l=new Lead();
      insert l;
            Database.LeadConvert lc = new Database.LeadConvert();

          LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
Database.LeadConvertResult lcr = Database.convertLead(lc);
 public PageReference redirect(){
            PageReference pageRef = new PageReference('https://www.google.co.in/?gfe_rd=cr&ei=o96dVtK-BujI8AeDzoWYAw&gws_rd=ssl');
            // pageRef.setRedirect(true); 

            return pageRef;


  I wrote a below trigger on lead only for condition 

if ( !gzip.isEmpty() && !gcountry.isEmpty() && !gstate.isEmpty()) it is getting fired it is not getting fired for next else if condition any thing wrong in my trigger code please suggest me. Also this is making a lookup everytime when user make a change on fields 

trigger territory_lookup on Lead (Before Insert, Before Update) 
 List<Territory_Lookup__c> territoryLookupList = null;  
 List<Integer> gzip = new List<Integer>(); // we need a list so that we can sort it.
 set<String> gstate = new set<String>();
 set<String> gcountry = new set<String>(); 
 for(Lead l :   Trigger.new){
   if ( l.postalcode != null)

 if ( !gzip.isEmpty() && !gcountry.isEmpty() && !gstate.isEmpty()) 
 territoryLookupList =  [select Theater__c,Region__c,Area__c,User__c FROM Territory_Lookup__c
                           where  Zip_Start__c <= :gzip and Zip_End__c >=:gzip 
                                  limit 1]; 

else if ( gzip.isEmpty() && !gcountry.isEmpty() && !gstate.isEmpty()) 
 territoryLookupList =  [select Theater__c,Region__c,Area__c,User__c FROM Territory_Lookup__c
                           where  State__c = :gstate and
                                  Country__c = :gcountry
                                  limit 1]; 

else if ( gzip.isEmpty() && !gcountry.isEmpty() && gstate.isEmpty()) 
 territoryLookupList =  [select Theater__c,Region__c,Area__c,User__c FROM Territory_Lookup__c
                           where  Country__c = :gcountry
                                  limit 1]; 

else if ( gzip.isEmpty() && gcountry.isEmpty() && !gstate.isEmpty()) 
 territoryLookupList =  [select Theater__c,Region__c,Area__c,User__c FROM Territory_Lookup__c
                           where  State__c = :gstate
                                  limit 1]; 

  for(lead uld : Trigger.new){
   Territory_Lookup__c tl =   getTerritoryLookup(uld);
   if(tl !=null){
     uld.Territory_Area__c = tl.Area__c;
     uld.Territory_Region__c = tl.Region__c;
     uld.Territory_Theater__c = tl.Theater__c;
 public Territory_Lookup__c getTerritoryLookup(Lead lead){
  if(territoryLookupList == null)
    return null;
  Territory_Lookup__c temp = null;
  for(Territory_Lookup__c territoryLookup : territoryLookupList){
      temp =  territoryLookup;
  return temp;



I am new to salesforce. I tried to use the standard list controller. I used teh belwo code but did not get any record on page.


<apex:page standardController="Account" recordSetVar="accounts" sidebar="false">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!Accounts}" var="a">
<apex:column headerValue="Account Name"/>
<apex:outputField value="{!a.Name}"/>
<apex:pageBlockButtons location="bottom" >
<apex:commandButton value="First" action="{!first}"/>
<apex:commandButton value="Last" action="{!last}"/>
<apex:commandButton value="Next" action="{!next}"/>
<apex:commandButton value="previous" action="{!previous}"/>
Hi there!

I am new to Apex, but would like to deploy the following Apex code to my org.  The issue however is that I don't know how to write unit tests.  Can anyone assist?
trigger UpdateCaseCommentFields on FeedItem (after insert) {
    List<Case> updates = new List<Case>();
    for (FeedItem fi : Trigger.new) {
        if (fi.ParentId.getSObjectType() == Case.SObjectType && fi.Visibility == 'InternalUsers') {
            updates.add(new Case(
                    Id = fi.ParentId,
                    Last_Internal_Comment__c = fi.Body
        else if (fi.ParentId.getSObjectType() == Case.SObjectType && fi.Visibility != 'InternalUsers') {
            updates.add(new Case(
                    Id = fi.ParentId,
                    Last_External_Comment__c = fi.Body
    update updates;


If i create a report with report type "tasks and events", and If i create with report type "Activities with contats", i get different number of results.

what is reason ?
  • December 15, 2015
  • Like
  • 0
Hello guys 
can you please solve my problem, I'm not able get <apex:detail/> tag properly, It is not working and here my code is :
<apex:page standardController="Account" >
<apex:pageBlock title="Account Info">
    <apex:pageblockSection title="Details">
         <apex:detail /> 
Thx in advnce
for(Contact c: contactList){
            for(Addresses__c a: addressList){
                if(a.Contact__c == c.Id){
values---------->  conZipMap.put(a.Contact__c ,  zipcodeMap.get(string.valueOf(a.Zip_Code__c+''+c.Firm_Channel__c)));                        
                        system.debug('&&&&&' + conZipMap);
                        system.debug('&&&&&' + a.Zip_Code__c+''+c.Firm_Channel__c);                        
        for(Contact c: contactList){
                if((c.Firm_Channel__c != null)&&(c.Firm_Channel__c != contactOldMap.get(c.Id).Firm_Channel__c)){                    
     -------->         c.Zip_Code__c = conZipMap.get(c.Zip_Code__c);-----------> how can i  call the above map and assigned that zipcode here 
                    system.debug('&&&&&&&' + c.Zip_Code__c);
                    system.debug('&&&&&&&' + conZipMap.get(c.Zip_Code__c).Id);
  • December 09, 2015
  • Like
  • 0
please suggest me , how to get this account from client org to my org using rest api through '/services/data/v35.0/query' endpoint?
Account accounts = [SELECT id from Account where Name ='sree'];
    req.setHeader('Authorization' , 'Autorization: Bearer' + accessToken);
    req.setHeader('Content-Type','application/json; charset=utf-8' );
    Http http2 = new Http();
    HTTPResponse res2 = http2.send(req);   
    System.debug('****************res2.getbody(): '+res2.getbody());
  • December 07, 2015
  • Like
  • 0

I'm trying to create a VisualForce page listing all clients who are due for a meeting.  I have created a Controller class and VF page using Eclipse.  When I try to save the VF page to the server, I receive the following error:

Save error:  Unknown property 'DueForReview.getAccounts'

Here is my code

public class DueForReview 
	private final List<Account> accounts =[select Id,  
                                           from   Account];
	List<Account> DueForReview;

    public DueForReview()
        for(Integer i=0; i<=accounts.Size()-1; i++)
        	if(accounts[i].Review_Frequency__c == 'Quarterly' && accounts[i].Last_Review_Meeting__c <= Date.newInstance(System.today().year(),System.today().month()-3,System.today().day()))
        	if(accounts[i].Review_Frequency__c == 'Semi-Annually' && accounts[i].Last_Review_Meeting__c <= Date.newInstance(System.today().year(),System.today().month()-6,System.today().day()))
        	if(accounts[i].Review_Frequency__c == 'Annually' && accounts[i].Last_Review_Meeting__c <= Date.newInstance(System.today().year()-1,System.today().month(),System.today().day()))
    public List<Account> getAccounts() 
        return DueForReview;

VF Page
<apex:page controller="DueForReview">
    <apex:pageBlock title="Clients Due For Review">
        <apex:pageBlockTable value="{!getAccounts}" var="account">
            <apex:column value="{!account.name}"/>
            <apex:column value="{!account.Review_Frequency__c}"/>
            <apex:column value="{!account.Last_Review_Meeting__c}"/>

Please help!
i am a developer beginner and i heard Dev401 is no longer available.Which is the basic certification for a developer beginner?
Is certification mandatory for applying jobs in salesforce? 
while sending emails to contacts i get single email limit exceed error. governer limit for sending single mail is 1000 per profile.
code is 
public class emailsender{

public void sendyourmail(){

  List<Messaging.SingleEmailMessage> mails = 
  new List<Messaging.SingleEmailMessage>();
 list<contact> li = [select id, name , email from contact limit 50];
  for (contact myContact :li) {
    if (myContact.Email != null && myContact.Name != null) {
        Messaging.SingleEmailMessage mail =   new Messaging.SingleEmailMessage();


Hi I created a visualforce page for selecting certain recordtypes to over write standard record type selecting page. For that controller I got stuck with writing test class. Please help anybody for this.
public with sharing class SelectSORRecordTypeCntrl{
Public List<RecordType> RecList{get; set;}
public Id recordTypes1{get;set;}
public string AcName{get; set;}
public string AcId{get; set;}

    public SelectSORRecordTypeCntrl() {
RecList=[SELECT id,Name, DeveloperName FROM RecordType 
                        WHERE DeveloperName in('Address_Changes_MMI','Billing_Terms_ETS','Billing_Terms_MMI','Billing_Terms_WMI8Credits_ETS','Credits_MMI','Credits_WMI','Customer_Service_General_ETS','Customer_Service_General_MMI','Customer_Service_General_WMI','Insurance_Forms_ETS','Insurance_Forms_MMI','Insurance_Forms_WMI','Lein_Release_Request_ETS','Lein_Release_Request_MMI','PO_Request_MMI','Pickup_Request_MMI','Tax_Exemption_MMI')];
AcName = ApexPages.currentPage().getParameters().get('Name');
AcId = ApexPages.currentPage().getParameters().get('id');
String[] ps= new String[]{};
 public String[] getrecordTypes() {
    return ps;

  public void setrecordTypes(String[] ps) {
    this.ps = ps;

  public List<SelectOption> getItems() {
    List<SelectOption> op = new List<SelectOption>();
    for(RecordType p : [SELECT id,Name, DeveloperName FROM RecordType 
                        WHERE DeveloperName in('Address_Changes_MMI','Billing_Terms_ETS','Billing_Terms_MMI','Billing_Terms_WMI8Credits_ETS','Credits_MMI','Credits_WMI','Customer_Service_General_ETS','Customer_Service_General_MMI','Customer_Service_General_WMI','Insurance_Forms_ETS','Insurance_Forms_MMI','Insurance_Forms_WMI','Lein_Release_Request_ETS','Lein_Release_Request_MMI','PO_Request_MMI','Pickup_Request_MMI','Tax_Exemption_MMI')])
    op.add(new SelectOption(p.Id, p.Name));
    return op;
  public Pagereference navigate()
   Pagereference  p = new Pagereference('/a0d/e?retURL=%2Fa0d%2Fo&ent=01I80000000lLBL&RecordType='+recordTypes1+'&CF00N80000004mJY7='+AcName);
   return p;
public Pagereference NavBack()
   Pagereference  b = new Pagereference('/apex/AccountDashboard?id='+AcId);
   return b;

Thanks in Advance
  • November 17, 2015
  • Like
  • 0
Hi ,
I am having one condtion in trigger like :
if(trigger.isUpdate && trigger.isAfter)
 how to satisfy the above if condition to cover the code inside if condition .

Hi All,

I've a requirement to put a custom LWC in Utility Bar (in footer). When user click on LWC component a default pop-up or container open by salesforce standard and our custom component populate in that pop-up or container. 

In my component I've provided a button to user to click and redirect to new custom url, but after once user redirected I want to close that pop-up or container should close automatically or implicit. User don't need to click to close this.

Anyone has achieved this than pls help me. 

In Auro component we have this $A.get("e.force:closeQuickAction"); function but for LWC I don't know.

Ashlekh Gera
Hi All,

I've create a my own community template (Custom) and created a package. When I install a package in another org and creating a new community.

While creating a community I am able to see my custom Template with other templates (Nipile, Account protal etc). When I select my own the template type and providing the name and URL suffix. I am getting below error.

User-added image
Please provide me the solutions.

Ashlekh Gera


I have an requirement which is below.

I've created a managed packaged and it is password proctected. 
If someone try to install this package then it ask for password to install so on that time I want to get an email and want to know who is trying to install this package.

How can I do this?

Ashlekh Gera
Hi All,

I need a small suggestion from your side for below scenario.

I've two objects X and Y both are in Look-up relationship. X(Parent) and Y(Child).

I need to calcualte the total childs (y records for a particular x record and on Y object there is field call price and I need to calcualte average of price and save on X (parent) record.

This is a like custom Roll up fields so we need to write a trigger to handle all cases like insert, update delete and undelete.

But my question is which approach we need to take to accomplish this.

1 Approch ) Fire a Aggregate query on Y records and group by X record in the trigger of Y object on above mentioned events. ( Put where condition to get only those parent X recs which are present in y object records in trigger)
2 Approch) Get all those X record which are present in list of y records in trigger and then do +1 or -1 to current present value of x count field and and save.

Which approch is good and why. Please keep in my that data may be in bulk.

Ashlekh Gera
Hi All,

I am trying to move custom metadata records from one org to another org.

In Org I have one custom metadata and some recrods which I have fetched in eclipse and try to move to another org B.

But facing "custom metadata type component type not permissible in destination" issue.

Could you please help me on this.

Ashlekh Gera
Hi All,

I've created an application in which I need to use jquery and need to use REST API.

In Jquery when I am trying to hit or create a ajax request then facing below issue.

Issue -XMLHttpRequest cannot load https://ap2.salesforce.com/services/data/v37.0/query?q=select+id,name+from+apexclass&_=1476807054409. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://c.ap1.visual.force.com' is therefore not allowed access.

my code is 
                     type: 'GET',
                     url : "https://ap2.salesforce.com/services/data/v37.0/query?q=select+id,name+from+account",
                     crossDomain : true,
                   beforeSend: function (xhr) {
                     xhr.setRequestHeader('crossDomain', true);
                     xhr.setRequestHeader('Authorization', "Bearer " + accessToken);
                     xhr.setRequestHeader('Accept', "application/json");

                       success : function(response){

Could you please help me on this.

Ashlekh Gera
Hi All,

I want to know that which trigger will fire if there are more than one trigger has written on opporutnity?

Trigger first was written in 2014 and Trigger second was written in 2015 on opportunity.

Ashlekh Gera
Hi All,

I've Scenario and I need a good way to achieve this.

Scenario - When the value of Stage field on Opportunity is 'Open' then need to show Standard Layout of opportunity, and if the value of stage is Closed then need to show custom Visual force page.

I know one approch - Which is below, if there is any other then please let me know.

Approch - Create Custom VFP and override the Standard View button. In the controller of this VFP page will check the value of Stage. If the value is Open then redirect to "http://Instance url/id?nooverride=1" url else stay on custom visual force page for Closed Stage.

Let me know if there is any other approach.

Hi Team,

I am tring to change the owner of the opportunity from A to B but I am facing below issue.

"Error :Intrastate functionality must be answered upon opportunity creation"

Please help me to know why this message is populating and how we can resolve this.

Ashlekh Gera

I need some basic code snippt to get all the label or workflows which are present in my salesforce org through METADATA (WSDL) in Java.

I've downloaded the MetaData WSDL and converted into Jar file and included these Jar file in my Java project. Now I need to know how I can get the all Custom Labels and Workflows are presend in my salesforce.

Hope I am cleared with question.

Ashlekh Gera
Hi All,

I want to found some record in my ORG.

Actually in my org Multi Currency is enabled. Default currencty is USD for ORG. On my user or for me default currency is GBP.

So when every I see the price or cost of on Account, it is populating in GBP.

I want to write a query to fetch only those records whose value is greater than 200 USD.

Please let me know the query.

Ashlekh Gera

I've an issue with Heap Size.

Basically I've a project there is a functionality in which many records are updating and many new records are creating on single event.

In my org I am near to hit SOQL limit so that I fetch all the records of A object in one time and it is almost 15K records which are maintaining in the list and it consume 4Mb of heap. 

If I write some other functions and will try to fetch some more data from other object than my code will cross the heap size limit.

Some one told me that why you are fetching the data of A object (!5K). instead of this you can query on Object A when you need data for this. 
but in that case I was facing SOQL limit and that data is required for some other code in the context because 
I need to update some other records bases on value in A object records.

Can some will provide a better approach to reduce the heap size?

All my code is running in the trigger.

-Advance Thanks
Ashlekh Gera

I've to know that if I create a new profile. And edit this proflie and change the some object permission like uncheck the delete checkbox for a custom object. Then If I send this profile to production then that custom object will have checked or unchecked delete check box or not.

Ashlekh Gera
Hi All, I want to learn Salesforce1 and lighting. I want to know that what should be my first step to learn this and where from I can get good material as I know that there I trailhead and some online pdf but your suggestion will help me to select good way.

Please suggest
  • September 22, 2015
  • Like
  • 0
Hi Folks,

I am stuck in reports. 

I need to create a report in which I need to show some fields data of opportunity. One of the field is "NextStep" (standard field on oppty)  which I am not able to drop this field in report. 

User-added image
Please help me on this. Reply ASAP.

Hi Folks,

I need help on S3 amazon integration.

I need help on : How can I create a bucket in S3 by Rest API version 4.(Using version 4 authentication header).

I need to follow steps to create a bucket but getting forbidden problem.

1) Please let me know which header I need to include in Request.
2) How create Signature in request.
For Signature I know that I need to create signature to follow below format.
StringToSign  =
Algorithm + '\n' +
RequestDate + '\n' +
CredentialScope + '\n' +

But I not get success. Please some help by step by step or I some give me a code to create bucket then it will be great 


  • September 20, 2014
  • Like
  • 0
Hi Folks,

I want to know about Service Cloud and Sales Cloud. I went through the links which I found on google to read about this, But If some provide me a pdf link which explain about both clouds and their services with object schema. If some give me some understanding how to related these clouds to each other then good for me.

Advance thanks
I can't show opportunity tab to customer community and customer community licenses users. And on the profile level there is no any option for this.

I read the documents and type of licenses and according to them opportunity is not available for user which these type of licenses.

But here I've two doubts

1) Here I have a controller and apex page. In controller I can get all the opportunities and all fetched opportunities are saved in wrapper class and then using a this wrapper class I can show opportunity and it is running successfully.

2) Here I have a controller and apex page. In controller I can get all the opportunities and saved in list and this list is a type of opportunity eg List<Opportunity> x. When I try to display oppty (using X) I got exception.

I am access my apex page from community portal.

My question if opportunity is not accessible to Customer portal and C Portal Licenses user the how can controller fetch the opportunities data ans show through the wrapper class and not opportunity type list

I need a signature for my first request to twitter :


My code create a Post request to this end Url https://api.twitter.com/oauth/request_token and I have to set a header which is mention below in which I


need signature.


I have only call back Url, consumer_key. I have created nonce and timestamp. I need signature


Authorization Header:
OAuth oauth_nonce="XXXXXXXXX", oauth_callback="XXXX", oauth_signature_method="HMAC-SHA1", oauth_timestamp="XXXXXX", oauth_consumer_key="XXXXXX", oauth_signature="HOW I CREATE THIS", oauth_version="1.0"

urgent for me. 


How to hit first request I also want to know?


Hi All,

I need a small suggestion from your side for below scenario.

I've two objects X and Y both are in Look-up relationship. X(Parent) and Y(Child).

I need to calcualte the total childs (y records for a particular x record and on Y object there is field call price and I need to calcualte average of price and save on X (parent) record.

This is a like custom Roll up fields so we need to write a trigger to handle all cases like insert, update delete and undelete.

But my question is which approach we need to take to accomplish this.

1 Approch ) Fire a Aggregate query on Y records and group by X record in the trigger of Y object on above mentioned events. ( Put where condition to get only those parent X recs which are present in y object records in trigger)
2 Approch) Get all those X record which are present in list of y records in trigger and then do +1 or -1 to current present value of x count field and and save.

Which approch is good and why. Please keep in my that data may be in bulk.

Ashlekh Gera
Hi All,

I am trying to move custom metadata records from one org to another org.

In Org I have one custom metadata and some recrods which I have fetched in eclipse and try to move to another org B.

But facing "custom metadata type component type not permissible in destination" issue.

Could you please help me on this.

Ashlekh Gera
Hi All,
I have created the formula field for calculating the hours between two datetime fields ........But it not showing exact hrs......My Piece of code
TEXT(DATEVALUE (Closed) - DATEVALUE (Open)- 0.2916)
Floor(DATEVALUE (closed)-DATEVALUE (open))*24)>9
(Floor((DATEVALUE (closed)-DATEVALUE (open))*24)),
"0"& TEXT(Floor((DATEVALUE (closed)-DATEVALUE (open))*24))

I tried both .......bt i couldn't get it

Pls suggest me

  • October 13, 2016
  • Like
  • 1
    I got below error and i have given trigger and also test class , could you please suggets me 
System.DmlException: Update failed. First exception on row 0 with id a0i4E000000t7jmQAA; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, cus: execution of AfterUpdate
caused by: System.NullPointerException: Argument cannot be null
Trigger.cus: line 10, column 1: [] 
Stack Trace Class.Testcus.testingCus: line 40, column 1 

trigger cus on Sample_Transaction__c(after update) {
    Call2__c Objopp;
    Map<Id,Sample_Transaction__c> o = new Map<Id,Sample_Transaction__c>();
    o = trigger.oldMap;
        for (Sample_Transaction__c objCustomer: Trigger.new) {
       if (objCustomer.Status__c== 'Active') {
       if(objCustomer.Status__c!= o.get(objCustomer.Id).Status__c) {
       List<String> s = new List<String>{objCustomer.Call_ID__c};
        ApexPages.StandardController controller = new ApexPages.standardController(Objopp);
     UnlockRecordDuringApprovalCon ObjUnlock= new UnlockRecordDuringApprovalCon(controller);
                      for(Call2__c c: [SELECT id FROM Call2__c WHERE Name IN :s]){
                                     ObjUnlock.processRecord(c.id );

test class

private class Testcus {
    static testMethod void testingCus(){

Account TestOpp=new Account();
        insert TestOpp;
        Call2__c Testcall =new Call2__c();
        insert Testcall ;
        Address__c testadd = new Address__c();
        insert testadd;

        Sample_Lot__c testsample=new Sample_Lot__c();

          insert  testsample;
        Product__c testprod = new Product__c();
        insert testprod;
            Sample_Transaction__c testapp1 = new Sample_Transaction__c();
           testapp1.Account_ID__c =TestOpp.id;
       testapp1.Address_ID__c= testadd.id;
testapp1.Product__c= testprod.id;

insert testapp1;
        testapp1.Status__c = 'Saved';
        update testapp1 ;

You guys rock!  Hopefully, you can help me with a simple Apex Class and VF page that I'm having trouble getting to work.

It works fine when i try to create one record, but the point of this page is to create multiple records.  Here is the error I am receiving:
Insert failed. First exception on row 0 with id a00410000029Ep0AAE; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]
Error is in expression '{!saveHours}' in component <apex:commandButton> in page addmultiplehours2: Class.AddmultipleHours.saveHours: line 21, column 1

An unexpected error has occurred. Your development organization has been notified.

My Apex Class:
public class AddmultipleHours {
 Hours__c hrs = new Hours__c();

 public list < Hours__c > listHours {

 public AddmultipleHours() {
  listHours = new list < Hours__c > ();

 public void addHoursRow() {
  Hours__c hours = new Hours__c();
 public PageReference saveHours() {
  for (Integer i = 0; i < listHours.size(); i++) {
   insert listHours;}
  return Page.AddmultipleHours;


My VF Page:
<apex:page Controller="AddmultipleHours">
  <apex:form >
    <apex:pageBlock >
      <apex:pageBlockTable value="{!listHours}" var="hours">
        <apex:column headerValue="Client Name">
          <apex:inputField value="{!hours.Client_Name__c}"/>
        <apex:column headerValue="Hours">
          <apex:inputField value="{!hours.Hours__c}"/>
        <apex:column headerValue="Type">
          <apex:inputField value="{!hours.Type__c}"/>
      <apex:pageBlockButtons >
        <apex:commandButton value="Add Hours Row" action="{!addHoursRow}"/>
        <apex:commandButton value="Save Hours" action="{!saveHours}"/>

Your help is much appreciated!!
Hello, our organization has many E2C (email to case), so i'm trying to create a email tab to see all the emails.
I created an apex page with this code:

<apex:page >
   <apex:enhancedList type="EmailMessage" height="600" />

After that, I created a Visual Force tab. But, the solution didn't work.
Can you help us?
I have created a workflow so that specific users can have tasks created and emailed to them every time they create an opportunity with specific criteria. I have added the field criteria into the task creation and all is working fine, but I also want the subject field of each task to populate with the opportunity name that created it.
How do I do this?
I am updating a picklist value through API 37.0 using .net c#
It works fine, but if the user select another value in the picklist, the value I added is gone.

I can't find a property to save the value.

any suggestions ?
  • September 30, 2016
  • Like
  • 0
Hi All,

we are construting an URL and using a window.open() method to open up a pop up window.
But when we are checking the URL on pop up window, it is coming in lowercase. but we are creating the URL in a cross cases.

we are also checking the URL just before it is entering into window.open() and found out URL is correct.
can anyone came acorss such situation and let me know how they had came out of it.

Thanks in advace !
  • September 30, 2016
  • Like
  • 0
Please suggest me if any one knows the below code pass in test class.

for (Accounts__c acc : (List<Accounts__c>)Trigger.New)
            if((String.isNotBlank(acc.Billing_Country__c) && trigger.isInsert) || ((String.isNotBlank(acc.Billing_Country__c) && trigger.isUpdate && ((Map<Id, Accounts__c>)Trigger.oldMap).get(acc.Id).Billing_Country__c != acc.Billing_Country__c)))
Yoga is extremely beneficial for pregnant women as it helps to strengthen the muscles which is essential during the time of labour and delivery. If you’re a mum-to-be looking to do yoga, Zaazen Wellness Centre in Delhi has prenatal exercise classes and yoga for pregnant women which have greatly helped these ladies through their pregnancies as well as in the post delivery period.
Hi I want to to display a click me link in a coulmn of table and on click of the link information specific to(service number) should display below the table, how to achieve it in lightning.

User-added imageUser-added image

Hi i have to give sharing rules to different users and groups for an object.

I want give them using apex managed sharing rules.



i have used this links as reference and i have listened that using apex we shouldnt write sharing rules.

is this right way to write criteria based sharing rules using apex, anyone please let me know.

Thanks in Advance,
Vamsi Varma.

Hi All,

Is it possible to use a vf component on a dashboard with lightning experience . Please let me know if it is possible.



Hi all,

we have developed from since almost a year ago a visualforce page leveraging on Lightning. And using it in all our development, full sandbox, and production environment.
today in our full sandbox environment it has appeared the following error message:
Something has gone wrong. Action failed: c$MatchComponent$controller$init [Cannot read property 'Yb' of undefined] Failing descriptor: {c$MatchComponent$controller$init}. Please try again.
the really strange fact is that all the enviromnts are alligned in terms of code for page and classes.

is there anyone who have experienced somithing similar?

Dear all,

We're looking at the various options of using Salesforce mobile (Salesforce1 application, SF1 Browser, Salesforce Classic in the browser) and are finding limitations with each:

Salesforce 1
  • Overriding the "View" action on an SObject appears to have no effect at all in SF1 and the standard page is displayed
  • The lack of ability to override the Edit action and then return to the normal edit page if the override logic requires it
What have people done to fix their existing overrides when they move to SF1?
Salesforce Classic in Mobile
  • If you direct to the full Salesforce classic site in mobile (i.e. switching off the "Enable the Salesforce1 mobile browser app" setting), the UIThemeDisplayed variable still seems to think that the user is in SF1
Lightning Experience
  • With Lightning Experience switched on and "Enable the Salesforce1 mobile browser app" switched off, the user cannot log-in on mobile
  • With Lightning Experience switched on and "Enable the Salesforce1 mobile browser app" switched on, the user is directed to SF1, despite Lightning Experience being responsive to different screen sizes, etc.
Does anybody have any advice, answers or workarounds to these questions? It makes mobile development very difficult when the navigation behaviours/capabilities in the desktop and mobile version differ so wildly.

With thanks,
HI Everyone, 

I'm testing something and it noticed that i was able to merge accounts, contact and leads via Apex even when the users executing these statements doesn't have delete rights. 

The Salesforce documentation is pretty clear on this, you need Delete rights. 

I've created my own test page to show this. 

Apex Code
public with sharing class aMerge {
    public pageReference doMergeLead() {

        Lead l1 = new Lead(Company = 'Test', LastName = 'Test', FirstName = 'Test');
        Lead l2 = new Lead(Company = 'Test', LastName = 'Test', FirstName = 'Test');
        insert l1;
        insert l2;
        merge l1 l2;
        return null;
    public pageReference doMergeAccount() {
        Account l1 = new Account(Name = 'Test');
        Account l2 = new Account(Name = 'Test');
        insert l1;
        insert l2;
        merge l1 l2;
        return null;
    public pageReference doMergeContact() {
        Account a1 = new Account(Name = 'Test');
        insert a1;
        Contact l1 = new Contact(AccountId = a1.Id, LastName = 'Test', FirstName = 'Test');
        Contact l2 = new Contact(AccountId = a1.Id, LastName = 'Test', FirstName = 'Test');
        insert l1;
        insert l2;
        merge l1 l2;
        return null;


Visualforce page
<apex:page controller="aMerge">
    <apex:form >
    <table width="100%" border="1">
            <td><apex:commandButton action="{!doMergeLead}" value="test"/></td>
            <td><apex:commandButton action="{!doMergeAccount}" value="test"/></td>
            <td><apex:commandButton action="{!doMergeContact}" value="test"/></td>

Test Screen Shot
User-added image

In the screenshot you can see that my user doesn't have delete rights on all three objects. However when i execute the test button it creates two records and merges them afterwards without any issue. 

When i try to open the Salesforce Merge UI i directly see the error message that i'm not allowed to merge these records. 

So my question; did i hit a security bug or is the database.merge function not sticking to the security controls?



Hi Experts,

I need to change the status when i check the checkbox, i need to amend in the code . could you anyone help me

Please call this new field “Defect_on_Hold__c” - checkbox. When checked, the Activity Status(Activity_Status__c) needs to change from "INTrR" to "HOLD". 

trigger tRIIO_Calc_Activity_Status_And_Fields on tRIIO_Activity__c (before update, before insert) {
    //To calculate Reinstatement Status
        Boolean isActivityWithoutOM  = false;
        Boolean isAnyOMWithoutFM = false;
        Boolean doesAnyFMHaveInterimDate = false;
        String Status = ''; 
        Integer countInterimDate = 0;
        for(tRIIO_Reinstatement_FM__c fm:[SELECT Id, Interim_Date__c FROM tRIIO_Reinstatement_FM__c WHERE Activity__c =: trigger.new[0].id]){
            if(fm.Interim_Date__c != null)
        List<tRIIO_Reinstatement_OM__c> OM = [select id, name,FM__c from tRIIO_Reinstatement_OM__c where Activity__c =: trigger.new[0].id ];
        Boolean isNotWithOutOM = false;
        Boolean isAnyOMWOFM = false;
        Boolean doesNiFMHaveInterimDate = false;
        String NGA_Work_Status_Text = '';
        if (OM.size()==0) {
            isActivityWithoutOM = true;
        } else {   
            //Loop for all OMs and if any OM is without FM then set the flag
            for(tRIIO_Reinstatement_OM__c a : OM) {
                if (a.FM__c!=true) {
                    isAnyOMWithoutFM = true;
           if (countInterimDate > 0) {
               doesAnyFMHaveInterimDate = true;
        //if there are no Original Measures for Notice set Status to 'Schld'
        if (isActivityWithoutOM == true) {
            Status = 'Schld';
        } else {
            //if any original measures is without a final measures set status to 'InPrg'
            if (IsAnyOMWithoutFM == true) {
                Status = 'InPrg';
            } else {
                //if any final measures have an interim date set status to 'InPrg' else set to 'IntReinst'
                if (DoesAnyFMHaveInterimDate == true) {
                    Status = 'IntrC';
                } else {
                    Status = 'PermC';
        trigger.new[0].Status__c = Status;
    //To calculate Activity Status
    if(Trigger.isInsert || Trigger.isUpdate){
        String ActivityStatus = '';
        tRIIO_Activity__c [] ActivityNew;
        ActivityNew = trigger.new;
        for( tRIIO_Activity__c Nots : ActivityNew){
            if(Nots.Activity_Status__c != 'IntrR(S)'){
                Nots.Clk_Int_Perm__c = false;
        Profile p = [SELECT Id,Name FROM profile WHERE id=:Userinfo.getProfileId()];
        String currentProfile = p.Name;
        String readOnlyProfiles = 'NG Read-Only';//Add other read-only profiles here seperated by ,
        if (readOnlyProfiles.indexOf(currentProfile) > -1){
            ActivityNew[0].addError('You do not have sufficient privilages to add or modify records.');
        for(tRIIO_Activity__c activity : ActivityNew){
            if ((activity.Activity_Status__c != 'IntrR(S)')&&(activity.Activity_Status__c != 'Cancelled') ) {
                if (activity.Abandoned__c == true){
                    if(activity.Hit_Int_Perm__c == true){
                        ActivityStatus = 'Awaiting Notice';
                    } else{
                        ActivityStatus = 'Abandoned';
                  //If Works Close Date AND Registration Date exists AND Reinstatement Status = "Schld" then "Nil Reinstatement"
                  if ((activity.Works_Close__c != null) && (activity.Registration__c != null) && (activity.Status__c == 'Schld'))
                      ActivityStatus = 'Nil Reinstatement';
                  //If Works Close Date AND Registration Date exists AND Reinstatement Status = "PermC" then "PermR"
                  else if ((activity.Works_Close__c != null) && (activity.Registration__c != null) && (activity.Status__c == 'PermC'))
                      ActivityStatus = 'PermR';
                  //If Works Close Date exists AND Registration Date does not exist AND Reinstatement Status = "PermC" then "PermC"     
                  else if ((activity.Works_Close__c != null) && (activity.Registration__c == null) && (activity.Status__c == 'PermC'))
                      ActivityStatus = 'PermC';
                  //If Works Close Date AND Registration Date exists AND Reinstatement Status = "IntrC" then "IntrR" 
                  else if ((activity.Works_Close__c != null) && (activity.Registration__c != null) && (activity.Status__c == 'IntrC'))
                      ActivityStatus = 'IntrR';
                  //If Works Close Date exists AND Registration Date does not exist AND Reinstatement Status = "IntrC" then "IntrC"  
                  else if ((activity.Works_Close__c != null) && (activity.Registration__c == null) && (activity.Status__c == 'IntrC'))
                      ActivityStatus = 'IntrC';
                  //If Actual Start Date exists then "InPrg
                  else if ((activity.Actual_Start__c != null))
                      ActivityStatus = 'InPrg';
                  //If Works Start Date exists then "Notice Raised" 
                  else if ((activity.Works_End_Date__c != null))
                      ActivityStatus = 'Notice Raised';
                      ActivityStatus = 'Awaiting Notice';                    
               activity.Activity_Status__c = ActivityStatus;
               //If this is a new record then default reinstatement status to 'Schld'
                   activity.Status__c = 'Schld';
            //when Reinstatement status changes to a status that is not 'PermC'or 'IntrC'then deattach Activity from closure report
            //so that it can can be added to next batch
            if ((activity.Status__c != 'PermC')&&(activity.Status__c != 'IntrC')){
                activity.Closure_Report__c = null;
                Map<Id,Double> mapCounts = tRIIO_QuotationAttachment.ValidateNotice(ActivityNew);
                for(tRIIO_Activity__c activity_Quotation: Trigger.new){                
                    if(activity_Quotation.Works_Order__c != null){
                        if(mapCounts.get(activity_Quotation.Works_Order__c) != null && mapCounts.get(activity_Quotation.Works_Order__c) != 0.0){
                            activity_Quotation.addError('Notice already generated for this Quotation'); 
Below is my code

global with sharing class REST_AccountService_V1 {
global static Account doGet() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
Account result = [SELECT Id, Name, Phone, Website, BillingState FROM Account WHERE External_Id__c = :accountId];
return result;

When I try to test the above Rest service in SOAPUI Tool
I am getting an error as below:

[ERROR:]Service not found at: /services/apexrest/AccountRaw ResponseHTTP/1.1 404 Not Found Date: Fri, 30 Oct 2015 06:35:33 GMT Set-Cookie: BrowserId=-MDkUrODQ_K2MkY-SmGwqw;Path=/;Domain=.salesforce.com;Expires=Tue, 29-Dec-2015 06:35:33 GMT Expires: Thu, 01 Jan 1970 00:00:00 GMT Content-Type: application/json;charset=UTF-8 Transfer-Encoding: chunked
[ { "errorCode" : "NOT_FOUND", "message" : "Could not find a match for URL /Account" } ]

Do I need to create a Remote site URL also ?How does it help? 
My requirement is user can login from facebook into the salesforce customer portal.
I followed th instruction given in the URL below.
user not created in salesforce.
help me any one please.
I have a checkbox field named primary_contact__c in the Contact object. I want an individual contact to be the only primary contact for any given account. hence once the checkbox field is checked for an individual account i want to prevent any other individual contact from having the same field checked for the same account. an attempt to do this should result in an error. 
Can somebody please help with this. I'M thinking the only way to do this is with a trigger
During deploying my App from sandbox to production environment I have got 1 error message that there is a duplication of Workflow field update data type ( see attached screenshot).

What I should do next? Delete this Change set in production environment and the same on sandbox and start again from the scrutch without adding this one field update? Or is there a way to remowe this component from change sets component list and try again?

Thanks for any help.

LukaszDeployment failure details view.