• Rahul Chaudhary Official
  • NEWBIE
  • 95 Points
  • Member since 2018


  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 16
    Replies
Hello,

On my dashboard :
All the reports on dashboard are coming from only two Objects: Leads and Opportunity;
Presently it has a filter by date on the daashbaord (Q1 : How can i change it to some other field ? )

Lead
- Custom_field_X
Opportunity
- Custom_field_X

-Values possible for "Custom_field_X" are "abc" or "pqr"

- Field os of type text 
 
Q2) I am not able to see the field on the dashboard filter ?
I checked this link :
https://success.salesforce.com/answers?id=90630000000h3juAAA
but my field visibilitty is OK.

Q3) How can i detect if and the report is of custome repoort typeand my field is added to the report page layout ?

Q4) What is the difference between "set field level securiy" and "view field accesibility" for the field? 
my field is visible in "field level seting" but its hidden in "field accesibility" does it make the diffrence ?

Thank you for suggestion !
  • November 16, 2018
  • Like
  • 0
Hi,

The requirement is to pull data from PDF and storing it as the custom field on Account object?

Is it possible to parse the PDF using Apex? 

If Yes, please share the necessary documents.

If No, please share the alternative approach/solution.

Any help would be highly appreciated.

Thanks & Regards,
Harsha BR
I have an in-bedded visualforce page on an opportunity and when i click on the links ( the links are to related list records), the page opens within that visualforce area with the header and sidebar.  Does anyone know how to format the link so it will either open just the record detail page within that area, or open the record in a new browser window? 

User-added image 
  • November 15, 2018
  • Like
  • 0
Hi All,

I  need to write test class for apex class my code is here-
public class CommenttoEmail {
   
    public String Commentbody {get;set;}
    public String subject {get;set;}
    public String Set_to{get;set;}
    Public String Set_bcc{get;set;}
    public String Set_cc{get;set;}
    public List<String> SetTo {get;set;}
    public List<String> SetCC {get;set;}
    public List<String>  SetBCC{get;set;}
    Public String CaseId {get;set;}
   
    public  String Selec {get;set;}
    public List<String> liststatus {get;set;}
    public boolean flag {set;get;}
    public string Str2;
    
    public String test;
    Public List<string> listall {get;set;} 
     public Attachment attachment {
  get {
      if (attachment == null)
        attachment = new Attachment();
      return attachment;
    }
  set;
  }
    public CommenttoEmail(apexpages.StandardController std)
    { 
        
                
        
        
        liststatus=new List<string>{'New','Working','Escalated','Closed Successful'};
       
        flag=false;
       CaseId=ApexPages.CurrentPage().getParameters().get('Id');
        listall=new List<String>();
        SetTo=new List<String>{};
        SetCC=new  List<String>{};
        SetBCC=new  List<String>{}; 
    }

   
public void senttoEmail()
{
    Case cse = [select id ,CaseNumber ,Status,ContactEmail,subject from case where id=:caseId]; 
   
  SetTo=Set_To.split(',');
 

    
public void bccEmail()
{
  SetBCC=Set_bcc.split(',');
}
    
public void ccEmail()
{
    SetCC=Set_cc.split(',');

    public void ss()
    {
        senttoEmail();
        bccEmail();
        ccEmail();
    }
public void attachemail()
{
  listall.addAll(SetTo);
  listall.addAll(SetBCC);
  listall.addAll(SetCC);
  
}
public pagereference  createCaseComment(){
    ss();
    upload();
attachemail();
sendingEmail();
ChangeStatus();

Case cse = [select id ,CaseNumber ,Status, Contact.name,Account.name,subject from case where id=:caseId];   
String ss=string.join(listall, ',');
String Str1='\n\n';
String Str0='[Recipients:' +ss+']';
String Str3=cse.Contact.name+',\n\n';
String  Reg='\n\n\n Sincerely,\n'+cse.Contact.name+'\n'+cse.Account.name;
   
Str2=Str0+Str1+Str3+Commentbody+Reg;

    
CaseComment cc = new CaseComment(ParentId = cse.Id,CommentBody = str2 , IsPublished=true);
insert cc;
  pagereference pg =new pagereference('/'+CaseId);

return pg;  
   
    }
    
public PageReference sendingEmail()
{
 upload();    
Case cse = [select id ,CaseNumber ,Status, Contact.name,Account.name,subject from case where id=:caseId];   
String ss=string.join(listall, ',');

String Str3=cse.Contact.name+',\n\n';
String  Reg='\n\n\n Sincerely,\n'+cse.Contact.name+'\n'+cse.Account.name;
   
Str2=Str3+Commentbody+Reg;
 List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();

for (Attachment a : [select Name, Body, BodyLength from Attachment where ParentId = :caseId]){

Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();

efa.setFileName(a.Name);
efa.setBody(a.Body);
fileAttachments.add(efa);
}



    try{
  
Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
semail.setToAddresses(SetTo); 
semail.setBccAddresses(SetBCC); 
semail.setCcAddresses(SetCC); 
semail.setSubject(cse.Subject); 
semail.setPlainTextBody(Str2);
semail.setFileAttachments(fileAttachments);   
   
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {semail}); 
    
    
    }catch(exception e)
    {}
    return null;

    
public pagereference redirectCasePage()
{

CaseId=ApexPages.CurrentPage().getParameters().get('Id');
pagereference pg =new pagereference('/'+CaseId);

return pg;   
}
    
    public void ChangeStatus()
    {
        
         List<Case> cse = [select id ,CaseNumber ,Status,subject from case where id=:caseId]; 
        for(Case c:cse){
            if(selec=='New')
            {
                c.Status='New';
            }
            
            if(selec=='Working')
            {
                c.Status='Working';
            }
            if(selec=='Escalated')
            {
                c.Status='Escalated';
            }
            if(selec=='Closed successful')
            {
                c.Status='Closed successful';
            }
            update c;
        }
           }
       
public List<SelectOption> getCaseStatus()
    {
         List<SelectOption> optlist=new List<SelectOption>();
         Case cse = [select id ,CaseNumber ,Status,subject from case where id=:caseId];
       optlist.add(new SelectOption(cse.Status,cse.Status));
        for(String s:liststatus)
        {
           optlist.add(new SelectOption(s,s));
       
        }    
     return optlist;
    }
    
   public PageReference upload() {
  
    attachment.OwnerId = UserInfo.getUserId();
    attachment.ParentId = CaseId;
    attachment.IsPrivate = true;
    attachment.ContentType = 'image/jpeg';
  
    try {
      insert attachment;
    } catch (DMLException e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
      return null;
    } finally {
      attachment = new Attachment(); 
    }
    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Attachment uploaded successfully'));
    return null;
  }
   
}
Hi everyone, I'm trying to set the Operating Hours, but I not able to see it. 
What can I do to set this Operating hour?
I was looking for in Setup and in the Tab but I could not see it. 
 
Hi,
i'm trying to get ip address of the client in a lightning component in a community but i receive Server error.
@AuraEnabled    
public static String GetUserIPAddress() {
string ReturnValue = '';
ReturnValue = ApexPages.currentPage().getHeaders().get('True-Client-IP');
if (ReturnValue == '') {
ReturnValue = ApexPages.currentPage().getHeaders().get('X-Salesforce-SIP');
} // get IP address when no caching (sandbox, dev, secure urls)
system.debug('USER IP ADDRESS: ' + ReturnValue);
return ReturnValue;
} // GetUserIPAddress

Any Ideas?
Can an object be created to link a case to other related cases based on a custom field, "Problem" which would be the common factor between the cases. Then any related case with the same problem could be displayed in the related cases. The idea is to group cases together based on a common problem faced by multiple customers.
Hello,

On my dashboard :
All the reports on dashboard are coming from only two Objects: Leads and Opportunity;
Presently it has a filter by date on the daashbaord (Q1 : How can i change it to some other field ? )

Lead
- Custom_field_X
Opportunity
- Custom_field_X

-Values possible for "Custom_field_X" are "abc" or "pqr"

- Field os of type text 
 
Q2) I am not able to see the field on the dashboard filter ?
I checked this link :
https://success.salesforce.com/answers?id=90630000000h3juAAA
but my field visibilitty is OK.

Q3) How can i detect if and the report is of custome repoort typeand my field is added to the report page layout ?

Q4) What is the difference between "set field level securiy" and "view field accesibility" for the field? 
my field is visible in "field level seting" but its hidden in "field accesibility" does it make the diffrence ?

Thank you for suggestion !
  • November 16, 2018
  • Like
  • 0
Hi everyone,

I am currently getting 68% test coverage. Please help!

global class MatchingAddBatch Implements Schedulable, Database.Batchable<sObject>,Database.Stateful{
    Double failedUpdates;
    Id customerRecordType;
    global void execute(SchedulableContext sc) {
        Database.executeBatch(this);
    }
    
    global database.queryLocator start(Database.BatchableContext BC) { 
        customerRecordType = Schema.SObjectType.Account.RecordTypeInfosByName.get('Customer').RecordTypeId;
        
        return database.getQueryLocator([SELECT Id, Name FROM Account WHERE isPersonAccount=true AND RecordTypeId=:customerRecordType]);
    } // end of start
    
    
    
    global void execute(Database.BatchableContext BC, list<Account> scope) {
        
        failedUpdates=0;
        
        List<Account> acctInBatch = [SELECT Id,PersonMailingCity,PersonMailingStreet,PersonHomePhone, PersonMobilePhone(SELECT Id,Name,HomePhone__c, Organisation__c,addressLine2__c,addressLine1__c FROM Addresses__r
              where     sourceSystem__c!=NUll  and     sourceSystem__c!='wewe' and sourceSystem__c !='wewe'and sourceSystem__c!='eoei' and
             addressKey__c!=Null and Organisation__c != Null and Organisation__r.RecordTypeId=:customerRecordType and Organisation__r.Id != Null  )
              FROM Account
              WHERE Id IN :scope ];
        
        List <address__c> custMatch= new List <address__c>();
        Map<Id, Account> mapObj2=new Map<Id, Account>();
        
        for (Account acct : acctInBatch) {
            if (acct.Addresses__r.isEmpty()) //check if it empty
                continue;
            for (address__c a : acct.Addresses__r) {
               
                
                if(acct.PersonHomePhone!=a.HomePhone__c){
                    a.Postal_Code_No_Match__c=true;}
                else{a.Postal_Code_No_Match__c=false;}
                if(acct.PersonMailingStreet!=a.addressLine1__c){
                    a.AddressLine1NoMatch__c= true;}
                else{a.AddressLine1NoMatch__c=false;}
                if(acct.PersonMailingCity!=a.ZL_addressLine2__c){
                    a.Address_Line_2_No_Match__c= true;}
                else{a.Address_Line_2_No_Match__c=false;}
                
                
          
                custMatch.add(a);
            }// end of address__c loop
            
        }//end of Account For loop
        
       
        
        system.debug(custMatch.size());
        List<Database.SaveResult> dsrs = Database.update(custMatch, false);
        for(Database.SaveResult dsr : dsrs){
            if(!dsr.isSuccess()){
                failedUpdates++;
            }
            
        }     // end of database update loop
        
        
    } 
    
    global void finish(Database.BatchableContext BC) {
        
        AsyncApexJob a = [SELECT id, ApexClassId, 
                          JobItemsProcessed, 
                          TotalJobItems, 
                          NumberOfErrors, 
                          CreatedBy.Email 
                          FROM AsyncApexJob 
                          WHERE id = :BC.getJobId()];
        
        String emailMessage = 
            'Your batch job '
            + 'AccountCustomerMatchBathJob' 
            + ' has finished.  It executed ' 
            + a.totalJobItems +
            ' batches.  Of which, ' 
            + a.jobitemsprocessed 
            + ' processed without any exceptions' 
            + 'thrown and ' 
            + a.numberOfErrors +
            ' batches threw unhandled exceptions.'
            + '  Of the batches that executed without error' 
            + failedUpdates 
            + ' records were not updated successfully.';
        
        Messaging.SingleEmailMessage mail = 
            new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] 
        {a.createdBy.email, 'blala@yahoo.com'};
            mail.setToAddresses(toAddresses);
        mail.setReplyTo();
        mail.setSenderDisplayName('Batch Job Summary');
        mail.setSubject('Batch job completed');
        mail.setPlainTextBody(emailMessage);
        mail.setHtmlBody(emailMessage);
        Messaging.sendEmail(new 
                            Messaging.SingleEmailMessage[] { mail });
                            
                            
    @istest

public class MatchingAdd {
    
    
    static testMethod void testMatching(){
        MatchingAddBatch obj = new MatchingAddBatch();
        String RecTypeId = GlobalUitlity.getRecordTypeIdByName('Account','Customer');   
        String query = 'SELECT Id, Name FROM Account WHERE isPersonAccount=true ' +
            
            'WHERE Id NOT IN (SELECT Organisation__c FROM address__r)';
        
      
        
        List<Account> lstCustomerAccountOneMatch = new List<Account>();
        List<Contact> conList = new List<Contact>();
        List <address__c> custMatch= new List <address__c>();
        
        
        Account a = new Account(FirstName='Bla' , LastName = 'AccTwoEmailMatch', RecordTypeId = RecTypeId, PersonEmail = 'TwoMatch@mail.com', 
                                goneAway__pc=true ,PersonMailingPostalCode= 'abdewi', 
                                PersonMailingStreet = 'my house,21456', PersonMailingCity='town');
        lstCustomerAccountOneMatch.add(a); 
        system.debug(lstCustomerAccountOneMatch.size()); 
        system.debug(a.Name);
        
        insert lstCustomerAccountOneMatch;
        
        
        Contact con =new Contact( FirstName=a.FirstName, LastName=a.LastName
                                );
        conlist.add(con);   
        insert conList;
        system.debug(conList.size()); 
        system.debug(con.LastName);
        
        
        
        address__c addre = new address__c(  GoneAway__c=true, postalCode__c=a.PersonMailingPostalCode, Organisation__c=a.id, contact__c=con.id,
                                                addressLine1__c =a.PersonMailingStreet, addressLine2__c=a.PersonMailingCity
                                                
                                               );  
        custMatch.add(addre);  
        insert custMatch;           
      
         
         
       Test.startTest();
     //   obj.execute(null,[select id from account]);
      
        
        DataBase.executeBatch(obj, 200); 
        
       Test.stopTest();
    Integer listCont = [select COUNT() from address__c where Organisation__c = :a.id ];
    System.assertEquals(1, listCont); 
        
        
    }// end of test method
    
    
}// end of Class                        
                            
        
        
          
        
    } 
}
Hello,

I'm trying to bind inputText from visualfroce page to my wrapper class. I have multiple products selected by one wrapper, and on second vf i want to take some inputText .After that i want to bind those inputText with selected products. and then on button click Im generating pdf for the same. But the can not able to bind the input string properly. 

can anyone can share some sample logic for this? 
Hi,

The requirement is to pull data from PDF and storing it as the custom field on Account object?

Is it possible to parse the PDF using Apex? 

If Yes, please share the necessary documents.

If No, please share the alternative approach/solution.

Any help would be highly appreciated.

Thanks & Regards,
Harsha BR
Hi All,

A senario:
I have a contact object and case object and i have a checkbox field in the contact object so when the checkbox is checked in the contact object  a vf page with some detail in the page should show in the case record for the contact type= employee. how can i build is logic in salesforce. your help will be much appreciated. thanks in Advance. 
Hi All,

I was just told by a Salesforce rep that this is possible, desipite all documentation saying that it is not.  Our current code creates the email in Content Builder and returns the ID to be used in a SOAP call that creates an Email Send Definition.

I get an error from this because from my understanding, SOAP cannot communicate with Content Builder.  The exact same request works when I generate the email in Classic Content and return the email ID from there.

Is there a workaround for sending Content Builder emails via the SOAP api?
I need to prevent an Apex Trigger from firing during the cloning of a record.  Can I use the value of a checkbox to prevent the trigger from firing?
I have an in-bedded visualforce page on an opportunity and when i click on the links ( the links are to related list records), the page opens within that visualforce area with the header and sidebar.  Does anyone know how to format the link so it will either open just the record detail page within that area, or open the record in a new browser window? 

User-added image 
  • November 15, 2018
  • Like
  • 0
Hello,

Brand new to Apex  - Day 1. I wanted to create a job to bulk load data into SF. But I am getting this error when creating the job in workbench:

 Response
[ {
  "errorCode" : "API_ERROR",
  "message" : "Unexpected character ('-' (code 45)) in numeric value: expected digit (0-9) to follow minus sign, for valid numeric value at [line:1, column:3]"
} ]

Here is the request header:
Content-Type: application/json; charset=UTF-8
Accept: application/json

and here is the request body:
--BOUNDARY
Content-Type: application/json
Content-Disposition: form-data; name="job"

{
  "object":"Contact",
  "contentType":"CSV",
  "operation": "upsert"
  “lineEnding”: “CRLF”

}

--BOUNDARY
Content-Type: text/csv
Content-Disposition: form-data; name="content"; filename="content"

FirstName,LastName,Title,Description
Tom,Jones,Senior Director,Self described as the top branding guru on the West Coast
Ian,Dury,Chief Imagineer,World renowned expert in fuzzy logic design
Tom Jr,Jones,Director, branding guru on the West Coast
Ian Jr,Dury,Imagineer,learn from dad  in fuzzy logic design
--BOUNDARY--

Any pointer on what exactly is it complaining about?

Thanks much
  • November 15, 2018
  • Like
  • 0