• Lokesh Kumar
  • 1443 Points
  • Member since 2016
  • Salesforce Developer
  • Informatica

  • Chatter
  • 46
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 13
  • 386
Hello Everyone,

I am trying to create pdf file in salesforce. But I have image and need to put this image with zero margin in the left side . 

 @page {
            margin-left:  0cm;
            margin-right: 2.54cm;

I wrote this css style , it doesn't work.

Thank you .
I created a field that is dependent on a picklist. How do I make it required and show an error message when it is enabled but left blank? 
...and it sure looks like it's there to me.

I'm doing the tutorial on REST callouts, and the exit test calls for making a class called "AnimalLocator." I created the class, wrote the code for it per the instructions, and ran the tests. When check the challenge, though, I get an error message "Challenge Not yet complete... here's what's wrong: 
No Apex class named 'AnimalLocator' was found."

I've double checked my spelling and capitalization. What rookie mistake might I be making here?

Hi all, 

I made few changes to the  one of the Apex classes in UAT, I want to move same class into Production( already same class exist in Production) by useing change sets.

is it like same process adding classes and testclasses into change sets then validation and deploy?? 
why because same test class already exist in prodcution, so do i need to add again test class to the chang set??
which option is suitable during deployment to run test classes among four?? ..i dont want to run all the test classes in prodcution at this case  
Is it going to overwrite the exist class?? 
is there any possible errors can occur during deployment in this case?? 

Thanks in advance.
Hi Team,

I want to get opportunities that are related to case as a related list using VF page.

Can anyone help to fix this?

Thanks & Regards,
Karthikeyan Chandran
I have a trigger on the Opportunity that creates records on a custom object called the Opportunity_Revenue__c. It takes the revenue from the Opportunity and spreads it out over the quarters during the length of the deal. It works fine for insert triggers, I need to have the ability to let users re-create based on a changing contract length / deal length. 

So when the record is updated I want to delete all the records in the custom object Opportunity_Revenue__c that are related to the Opportunity and then run the insert code to create the new records for the Opportunity_Revenue__c object. But it is doubling the records because once it deletes the old records it see trigger as an update and an insert.

Can you help or suggest what I might do?

Here is the code:
public class OpportunityRevenueTrigger2 {

    public static void updateOpportuntityRev(List<Opportunity> trig){
         List<ID> opprtnyId = new List<ID>();
         Decimal totRev;
         Decimal totAllottedRev;
         Decimal mRev;
         for(Opportunity opp4: trig){
            if(Opp4.Auto_Generate_Quarterly_Forecast__c == 'Yes'){
         List<Opportunity_Revenue__c> deleteOR = [SELECT id
                                                 FROM Opportunity_Revenue__c 
                                                 WHERE Opportunity__c in: opprtnyID];
        if(deleteOR.size() != 0){
           Delete deleteOR;
        List<Opportunity_Revenue__c> oppr = new List<Opportunity_Revenue__c>();
        for(Opportunity opp : trig){
             if(opp.amount > 0 && opp.contract_length_Months__c > 0 
               && opp.Auto_Generate_Quarterly_Forecast__c == 'Yes' ){
                   Date sDate = opp.CloseDate;
                   Integer period = opp.Contract_Length_Months__c.intValue();
                   Integer period2 = period / 3;
                   totRev = opp.Amount;
                   mRev = totRev.divide(period2, 2);
                   for(Integer i = 1; i <= period2; i++) {
                   Opportunity_Revenue__c oppr2 = new Opportunity_Revenue__c();
                   oppr2.Account__c = opp.AccountId;
                   oppr2.Opportunity__c = opp.id;
                   System.debug('i '+ i);
                   oppr2.ProjectedRevenue__c = mRev;
                   oppr2.Month__c = sDate;
                       if(sDate.Month()== 1 || sDate.month()==2 || sDate.month() ==3){
                           oppr2.Quarter__c =  'Quarter 1, '+string.valueOf(sDate.Year());   
                       } else if (sDate.Month()== 4 || sDate.month()== 5 || sDate.month() == 6){
                           oppr2.Quarter__c =  'Quarter 2, '+string.valueOf(sDate.Year());
                       } else if (sDate.Month()== 7 || sDate.month()== 8 || sDate.month() == 9){
                           oppr2.Quarter__c =  'Quarter 3, '+string.valueOf(sDate.Year());
                       } else if (sDate.Month()== 10 || sDate.month()==11 || sDate.month() ==12){
                           oppr2.Quarter__c =  'Quarter 4, '+string.valueOf(sDate.Year());
                   sDate = sDate.addMonths(3);
        insert oppr;

trigger OpportunityRevenueTrigger on Opportunity (after insert, after update) {

Hello Developers!
I am trying to write trigger on opportunity which would sum the Amount field on Account.
This might be possiable via standard but I am trying to have similar trigger on different set of object and solving this would solve the other one as well.
trigger AmountRollup on Opportunity(After insert, After update, After delete, After undelete){
    Set<ID> accountIds = New Set<ID>();
    If(Trigger.IsInsert || Trigger.IsUpdate || Trigger.IsUndelete){
        For(Opportunity opp: Trigger.New){
        For(Opportunity opp: Trigger.Old){
    List<Account> AccountListToUpdate = New List<Account>();
    Double AmountTotal = 0.00;
    For(Account a : [Select id, total_opportunity_amount__c, 
                                (Select id, Amount FROM opportunities) 
                                FROM Account WHERE ID = :accountIds])
         For(Integer I = 0; I < a.opportunities.size(); I++)
             AmountTotal += a.opportunities.Amount; // Here I am trying add all amount sum into AmountTotal
             a.total_opportunity_amount__c = AmountTotal;
    update AccountListToUpdate;
    catch(Exception E){
        system.debug('Error thrown is: ' + E.getMessage());

Thank you for the help!
We are trying to install app from appexchange in sandbox and getting [Exception, DomainNotPropagated] error.

An error has occurred in the following section: [Exception, DomainNotPropagated]. Salesforce.com has been notified of this error.

How do we resolve? We have been on a custom domain for over a year in sandbox and production.
<apex:page standardcontroller="comingpeople__c"   sidebar="false" showHeader="false">
<apex:form >

<apex:pageBlock >
<apex:pageBlockSection title="OUTING PLAN">
<apex:inputField value="{!comingpeople__c.Employee_name__c}" /><br/>
<apex:inputField value="{!comingpeople__c.GID__c}" /><br/>
<apex:inputField value="{!comingpeople__c.coming_or_not__c}" /><br/>
<apex:inputField value="{!comingpeople__c.Transportation__c}" /><br/>
<apex:inputField value="{!comingpeople__c.Venue__c}" /><br/>

<apex:commandButton value="save" action="{!save}"  />

In Setup, I have so many apex classes or VF pages, I dont want to browse page by page to locate a class, I have used Quick Find/Search box to find a class but it returns 0 item.
I have to browse every page to find a class, it is very inconvenient.
Please tell me how to find quickly a class or Vf page.


I'm trying to build [Change] link next to record owner name on the lead VF page so that the user can re-assign the leads. My lead VF page is a completely custom build page. I'm expecting this functionality to work as in Standard page ie., when the user clicks the [Change] link he/she should be taken to the change ownership page from where he/she should re-assign the lead and the retUrl should take him/her back to the custom page.

I have used the below piece of code found in this forum - 
<apex:outputLink value="{!URLFOR($Action.Lead.ChangeOwner,Lead.id)}">[Change]</apex:outputLink>

But it's not working as expected. When I add this code and tested by clicking the output link [Change] it asks me to log in again and gives me an error as - 
Stale Session Exception
The page you submitted was invalid for your session. Please try your action again. 

Can I get some help here? 


We have created an apex class and 2 triggers which execute once a registration record is created/updated in order to update the record based on certain criteria.
From this we have noticed that in the mornings the registration process can be quite slow for some users and in some cases they will get the request timed out error message.
When a system admin tries it, sometimes its slow but most of the time we can create the registration fairly quickly.

Is there anything that I should check to maybe increase the request time of the users/triggers? I've never got an error like this and we never had the error in any of our sandboxes - it just appears to be production.
Does anyone know how to resolve this/had a similiar problem?



I have a VF text like below
<apex:outputText value="{!cObj.Type__c}" style="font-weight: bold;color: black;font-size: 160%;"/>

I want to control the CSS based on Type__c value
if(Type__c == XYZ)
    style="font-weight: bold;color: black;font-size: 160%;"
    style="color: black;"

Thanks for suggestion !
 I need a calculating field ---  calculate days taken to change from open to verified status.

There is a Lead Status picklist  on Account object   -- open ---> Verified.
Let me know if you need more info.

Some questions with respect to the Report module.  Here is a report that we have and it has the relationship like this.

Levels for the Reports

Question : In the above screenshot on the top it shows Opportunities (A). The other three are relationships are below that.
Can we have another relationship like Opportunities to a new relationship (E) and E is not related to B or C or D.   We need this new relationship for our project. Need to explore if this is possible or we have to do only by means of development ? 



When i search something in search box from Portal, i can see the people in the salesforce.
How can i block it ?

Thaks for suggestion !
Hi There, Does anybody knows if there is a way to create an opportunity directly when a customer order a service from our company website. Can you do process builder or need a Apex trigger ? Feel free to  direct me to a link with the process builder or trigger solution.
Im a newbie , On click of a custom button i need message to popup like xyz , but it shoul have ok or cancel.. If ok then it should proceed to the  operation , if cancell then just no action
Hello Geeks,

Wants to know more about how we can whitelist IP's at Profile Level instead of manually.
I want to know is there a way to add IP's Programmatically through API's.

Any suggestion appreciated 

Hello Geeks,

we have a requirement to do a call out whenever any deployment is happing in the Org,

Why Is it required?

We want to hit an URL if the deployment components having particular component only in Apex Class. URL is for executing the test cases in the third party system. 

So is there any way to look into the deployment Components programmatically. (API's)

Any Help much appreciated.

I am trying to pass Set of Ids in the where clause at the time of setEndPoint URL for more PFB.
Map<ID,ApexClass> apexclassName 		= new Map<Id,ApexClass>([select id,name from ApexClass where NamespacePrefix = null]);
        Map<ID,ApexTrigger> apexTriggerName 	= new Map<ID,ApexTrigger>([select id,name from ApexTrigger where NamespacePrefix = null]);
        Set<ID> apexandTriggerID = new Set<Id>();
        HttpRequest req = new HttpRequest();
        req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
        req.setHeader('Content-Type', 'application/json');
        Http h = new Http();
        HttpResponse res = h.send(req);

the value which is getting assigned is like.

21:08:27:041 USER_DEBUG [12]|DEBUG|***System.HttpRequest[Endpoint=https://informatica--Lokesh.cs41.my.salesforce.com/services/data/v37.0/tooling/query/?q=Select+ApexClassorTriggerId,NumLinesCovered,NumLinesUncovered,Coverage+from+ApexCodeCoverageAggregate+where+ApexClassorTriggerId+IN+(+{01p550000001F7QAAU, 01p550000001F7RAAU, 01p550000001F7SAAU, 01p550000001F7TAAU, 01p550000001F7UAAU, 01p550000001F7VAAU, 01p550000001F7WAAU, 01p550000001F7XAAU, 01p550000001F7YAAU, 01p550000001F7ZAAU, ...}), Method=GET]
can anyone help me how to pass return false; in the ng-click event while opening a PrimaryTab using salesforce service cloud console. This is to stop refreshing the main page after clicking on a link.
<tr ng-repeat="case in Caseinformation|orderBy:sortType:sortReverse |      filter:query " style="height:1px;" class="data-row">          
     <td style="text-align:left;"><a ng-href="/{{case.caseId}}" ng-click= "openPrimaryCaseTab(case.caseId,case.caseNumber);return false">{{case.CaseNumber}}</a></td>

$scope.openPrimaryCaseTab = function (recordID,caseNumber) {
    alert('open primary tab'+recordID);

Not able to pass this Challenge PFB screen shot.
My Save Method code.

public PageReference save(){
        PageReference savePage;
        if (Schema.SObjectType.Resource_Type__c.isCreateable()){

                insert rtype;

                String completion = ApexPages.currentPage().getParameters().get('finishURL');
        savePage = new PageReference('/'+completion);
        return savePage;

            }catch (exception e){
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, 'Unable to update requisitions.  Exception: ' + e.getMessage()));
                return null;
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, 'You do not have permission to update requisitions'));
            return null;

User-added image 
can anyone please help me here I am not able to solve this challenge.

User-added image
Can somebody please help me out here how to measure based on the sum of # instead of a count of rows or sum of the amount because on my case # is not appearing on the creating lens window Thanks in advance. PFB more details.

User-added image
can somebody help me her am not able to pass this module stuck in the last challenge for more details PFA.

User-added image

User-added image

We have a requirement to get the overall test class coverage and individual classes there in salesforce production org. automatically based on time interval. The challenge is how to execute it programmatically and get the latest coverage? 
 Thanks in Advance 
Create a dashboard named Sales Focus and add the reports you set up earlier in this module.
Add a component based on the Upgrades (Last Month) report as a gauge component.
Add a component based on the Key Accounts report as a horizontal bar chart component.
Check challenge

Challenge Not yet complete... here's what's wrong: 
There was an unexpected error while verifying this challenge.
Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: LNEWIXXM

User-added image
I am quering a name from the user object by providing in text box and displaying as dynamic record choice. but if the provided user is not exist i want to display a message that the requested user in not present. how to handle no result in visual flow dynamic record choice
currently we are running via manual clicking on the batches. could you please suggest an option to automate apttus job.

these are the apttus batch jobs update.
I want to create an app which update the user information like profile, email,license etc. and give it to service desk engineer so the can solve the ticket related to user detail modification by own.
For the above requirement modify-all permission is required, but i want to do this without any dependency of an logged-in user means in system-mode context.
Please suggest some ideas.

i tried visual flow and process-builder but i get to know that visual flow run's in a user-mode and process-builder doesn't support screen. only we can execute the auto-flow(which doesn't have screen to take the input from the user).
Can somebody please help me out here how to measure based on the sum of # instead of a count of rows or sum of the amount because on my case # is not appearing on the creating lens window Thanks in advance. PFB more details.

User-added image
I have 2 objects product(parent object) and price(child object) and the  relationship is lookup .
I have a field amount in child object and i want  the sum of  amont field  like Roll-up summery field.
How can i get this.
I need an anonymous suggestion box. Can suggestions to that box be submitted anonymously (within this demo) or is it possible with SalesForce at all?
Hi All, new to Salesforce Development

I'm trying to create an Apex Trigger in Task(Activity)/Event object.

1) Check a field in Account (Number Field A__c) if more than 100
2) Check a field in Account (Number Field B__c) if more than 50

Basically I have criteria above if not pass, prompt error message to users upon saving their Task/Event record.
 I created a batch apex and schedulable apex and scheduled apex to send emails to all contacts on an Account associated with an open case of a specific sub-category. The batch apex works but there are some batch failures, I am unable to know status of each record in a batch as to whom email was sent and not and the reason behind batch failure. On an average there are about 833 records processed in 85 batches out of which 52 batches got failed. Not sure how many records in each batch got failed and why. How can I get status of 833 records which ones got processed and which ones got failed? Below is my batch class and schedulable class.
Batch Apex:
global class CaseNotifications implements Database.Batchable<sObject>,Database.Stateful {
    global string contactIds;
    global integer count = 0;

      global Database.QueryLocator start(Database.BatchableContext BC)
          string subcategory1='Hardware';  
          string subcategory2='Software';
          return Database.getQueryLocator('select id from contact where accountId in (select accountId from case where Isclosed= false and (sub_category__c=\''+subcategory1+'\' or sub_category__c=\''+subcategory2+'\'))' );      
    global void execute(Database.BatchableContext BC, List<sObject> scopeList) {
     List<Messaging.SingleEmailMessage> emails = new list<Messaging.SingleEmailMessage>();
        List<Contact> toAddresses=new List<Contact> ([select email from contact where id in :scopelist]);
        system.debug('ContactIds size'+toaddresses.size());
         for(Contact c:toAddresses){

         Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
    global void finish(Database.BatchableContext BC){
        AsyncApexJob aaj = [Select Id, Status, NumberOfErrors, JobItemsProcessed, MethodName, TotalJobItems, CreatedBy.Email from AsyncApexJob where Id =:BC.getJobId()];
        // Send an email to the Apex job's submitter notifying of job completion.
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] {aaj.CreatedBy.Email};
        mail.setSubject('JOB Salesforce Send Notification Batch: ' + aaj.Status);
        String bodyText='Batches Processed ' + aaj.TotalJobItems + 'Total number of records processed ' + count+ 'with '+ aaj.NumberOfErrors + ' batch failures.\n';
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });


Schedulable Apex:
global class BackupCaseNotifications implements schedulable {
    global void execute(SchedulableContext ctx) {
        CaseNotifications b=new CaseNotifications();

I'm new to trailhead. From this URL https://trailhead.salesforce.com/projects/trailhead_on_mars/steps/trailhead_on_mars_step_1 I  just clicked Laundh You Hands on Org, and got this error:
This site can’t be reached
playful-goat-298999-dev-ed.lightning.force.com’s server DNS address could not be found.
Can you help?
Hello Everyone,

I am trying to create pdf file in salesforce. But I have image and need to put this image with zero margin in the left side . 

 @page {
            margin-left:  0cm;
            margin-right: 2.54cm;

I wrote this css style , it doesn't work.

Thank you .
I created a field that is dependent on a picklist. How do I make it required and show an error message when it is enabled but left blank? 
I am tryin to do a module and it is telling me to go to my trailhead playground and click the cog for me setup.....
A) How do I know that I am in the playground?
B) I've logged into trailhead but do not see a cog for setup?
C) How can I be sure I am not in production?
Hi All,

I have a requirement where i have created a custom button on the detail page of any record of a custom object. on click of the button a new window will be opeened with a VF page rendering as PDF. now my requirement is to download the page with out displaying the page. I mean on click of the button the VF page should be downloaded.

Please note the data is generated in the VF page based on the record id of the record which is being passed to page on click of the custom button.

BEst Regards,
Mohammad Yaseen