• Harshit Garg 6
  • NEWBIE
  • 355 Points
  • Member since 2015

  • Chatter
    Feed
  • 11
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 4
    Questions
  • 102
    Replies
How can i get only text from words
EX:  Sultan Road
output : Road
Hi All, 

I have a VF page that is used by customers to upload documents to us, which create and attach themselves to a case. 
The name of the attachment is currently being set by the controller. 

I want the document name to include the value from a picklist on the page (Type_of_Document__c) however the the name is currently showing the field API name. 

Any thoughts on how to fix this?
insert objcase;
   
       System.debug('@@@@@objcase' +objcase);
        System.debug('@@@@@fileBody'+fileBody);     

        myAttachment  = new Attachment();

              Integer i=0;

              myAttachment.clear();

              myAttachment.Body = fileBody; 

              myAttachment.Name = 'Type_of_Document__c'+objcase.id+'.jpeg' ; 

              myAttachment.ParentId = objcase.id;             

              insert myAttachment;

 
I want to create a custom field that calculates the sum of all 'Amount' opportunity fields for same opportunity, so that I can bucket this field in my report. It seems that it cannot bucket if I just summarize the Amount field, so I'm assuming if I create a custom Amount Sum field, this would work.

So for one account, I have 3 same updated opportunities:

Bucket - Total Opportunities 3 or more : $500 - $1000
Org: John Smith
        Amount: $100
        Amount: $100
        Amount: $400
       >>New Sum Field: $600

How would I create this in apex class?
trigger

public class createoppojjb{

    public static void account(set<id> AcountID)
    {
      
 
  List<Opportunity> oppList = [Select id, Name, AccountId, Amount from Opportunity where AccountId IN : AcountID];
        
        Map<Id,List<Opportunity>> mapOpp = new Map<Id,List<Opportunity>>();
        
        for(Opportunity opp : oppList){
            if(mapOpp.containsKey(opp.AccountId)){
            
                List<Opportunity> oppAcountID = mapOpp.get(opp.AccountId);
                oppAcountID.add(opp);
                mapOpp.put(opp.AccountId,oppAcountID);
            }
            else{
                List<Opportunity> oppAcountID = new List<Opportunity>();
                oppAcountID.add(opp);
                mapOpp.put(opp.AccountId,oppAcountID);
            
            }
        
        }
        
        
        List<Opportunity> opp;
        Double Amount = 0;
        String Idd;
        
        for(Id oppId : mapOpp.keySet()){
            
            opp = mapOpp.get(oppId);
            System.debug(opp);
            
            for(Opportunity amt : opp){
                Amount += amt.Amount;
                System.debug(Amount);
            }
            
        }
        
        Boolean flag = true;
        List<Opportunity> names = new List<Opportunity>([Select Id, Name, Amount from Opportunity where Id IN : opp]);
        
        System.debug('names  '+names + ' ' + flag);
        
        for(Opportunity oppName : names){
            if(oppName.Name == 'Test'){
                System.debug(Amount);
            }
        }
        }
        }


class

trigger CreateOpp on Account (after update, after insert) {
  if((Trigger.IsAfter && Trigger.isUpdate)) {

  Set<Id> accID = new Set<Id>();
   for(Account acc:Trigger.New) {
            if(acc.Name != 'null') {
            accID.add(acc.id);
            }
        }
    if(accID.size()>0) {
            createoppojjb.Addaccopp(accID);
        }
   }     
}
Hi, 

Is anyone aware if it is possible to use a visualforce page, a a web form, to create a case and upload a file to the case at the same time?
challenge link : https://trailhead.salesforce.com/trails/force_com_dev_beginner/modules/business_process_automation/units/process_builder . 

 in trail heads i am getting the following message "An update to an account record failed to update the mailing address fields of all child contact records. Make sure that the process is correct and that it is activated."

but when i try to manually update the account address and then check with the related contact the process is working fine there is no problem . the issue is trailhead is not accepting this solution .
User-added imageUser-added image
P.S : i have tried deactivating all the triggers , flows , validation rules , all other stuff on both the objects . please help . !
 
Account and Contact has the lookup relationship. Now i want the rollup kind type of field in the Account page where i can show the count of my all contacts. I cannot change the relationship from Lookup to master- Detail.

How i will achieve this in the Account page in lookup relationship ?
When I log in to salsforce by my developer account,and study follow trailhead, I can complete Hands-on Challenge in my own personal Salesforce environment,is this personal Salesforce environment my org? If not, what is my org in salesforce?

What is the different between my org, sandbox and production envirnoment?

Is sandbox public for everyone? Or I have to apply for my sandbox?
How to add our custom field in Email Application Pane for salesforce for outlook?

Like - I want to add account custom field.

Please help me out in that. It's urgent
How to make convert lead button on contact. Please help me out on this.
How to add our custom field in Email Application Pane for salesforce for outlook?

Like - I want to add account custom field.

Please help me out in that. It's urgent
Hi Team,

Greetings for the Day!
Scenario : How to track Visualforce page visitor name and time?
Please guide to me how to write the code for above scenario.


Regards
Lakshmi
Hello,

I have setup a new SalesForce environment and I have to transfer my Apex classes on it.

In order to deploy my code I use a test class with test methods.

A validation process is started when I try to deploy the changes.

This validation invokes all existing test methods and the environment throws the following exception:
System.LimitException: Apex CPU time limit exceeded

Oddly enough on the old environment there is no such exceptions

I'm sending you a method of my source code where the Apex CPU time limit exceeded is most likely to happen:
 
private List<LeadConversionContainer> checkByWebsite(Lead leadObj) {
        List<LeadConversionContainer> accountWebsites = new 
        List<LeadConversionContainer>();
        String website = leadObj.Website;
        String leadId = leadObj.Id;
        List<Account> accWebsiteList = [SELECT Website, Url__c, Status__c FROM 
        Account];
        if(website != null && !website.equals('') && accWebsiteList != null) {
            List<String> leadWebsites = extractWebsites(website);
            for (String leadUrl : leadWebsites) {
                String normWebsite = normalizeWebsite(leadUrl);
                String leadWebsite = normWebsite.trim();
                for(Account acc : accWebsiteList) {
                    String accountWebsite = acc.Url__c;
                    String accountId = acc.Id;
                    List<String> extractedAccountWebsite = 
                    extractWebsites(accountWebsite);
                    for(String accWebsite :extractedAccountWebsite) {
                        String accountSite = normalizeWebsite(accWebsite);
                        if(accountSite != null) {
                            List<String> leadSplitWebsitesList = leadWebsite.split('[,;\\s]');
                            for(String leadSplitUrls :leadSplitWebsitesList) {
                                if(accountSite.equals(leadSplitUrls)) {
                                    boolean isAccountStatusActive = isAccountActive(acc);
                                    boolean isMerchantApplication = 
                                    isMerchantApplicationsAttached(acc);
                                    if(isAccountStatusActive || isMerchantApplication) {
                                        String reasonToStopConversion = 'Lead Website coincide with 
                                        Account Website';
                                        LeadConversionContainer leadConvert = new 
                                        LeadConversionContainer(acc.Id, '', reasonToStopConversion);
                                        accountWebsites.add(leadConvert);
                                    }
                                }    
                            }
                        }
                    }
                }    
            }
        }
        return accountWebsites;
    }

Please advise how to solve the issue with my deploy and avoid such System.LimitException: Apex CPU time limit exceeded exception?
Hi All

How can i copy/insert record form multiple object to one custom object uisng batch process.I have created batch class but its bring data from one object to another object ..
global class CopyContact implements Database.Batchable<Contact> {

    global CopyContact (){}

    global List<Contact> start(Database.BatchableContext BC) {
        return [Select Name,Email,Phone,MobilePhone From Contact];
    }
    
    

    global void execute(Database.BatchableContext BC, List<Contact> scope) {
       List<Master_Data__c> lhList = new List<Master_Data__c>();
       for(Contact lh : scope){
           lhList.add(
               new Master_Data__c(
                  Name=lh.Name,Email__c=lh.Email,Phone__c=lh.Phone,Mobile__c=lh.MobilePhone
               )
           );
       }
       insert lhList;
    }

    global void finish(Database.BatchableContext BC) {}
}

 
Is there any way to add more than 4 column Dashboard layout and if so can someone point me in the right direction on how to do it?  
Hi Experts,
I want to create a trigger for following case:

Whenever a case is opened and closed for an account of particular region ( e.x. WE- West), the respective inside rep ( it's a sales rep) for that account should get email alert notification. What will be the trigger for this scenario?
 
How can i get only text from words
EX:  Sultan Road
output : Road
I have a custom button which has a URL link which I construct in Formula Editor. 

In the formula field I give \apex\AAAAAA?id=YYYYYY     where AAAAAA is the VF Page Name. YYYYYYY is the id of the record.  This works fine for standard user but does  not work for Partner (Community) User.   I am trying to see how I can constrcut the URL which can work for both standard and community user by constructing the user accordingly based on the logged in user.

Any help is appreciated.
Hi Expert,

I need a campaign id on a lead page, how i can do this. i am using formula but not getting camaign in formula list.
Please suggest.

Thanks
Mukesh

 
I want to write trigger to enable a checkbox in contact whenever its Account is modified(updated). 
I'm not able to put the condition for Account updated or not! Can you guys provide the logic?? 
 
  • April 12, 2017
  • Like
  • 1
Account and Contact has the lookup relationship. Now i want the rollup kind type of field in the Account page where i can show the count of my all contacts. I cannot change the relationship from Lookup to master- Detail.

How i will achieve this in the Account page in lookup relationship ?