• Sitanshu Tripathi
  • NEWBIE
  • 274 Points
  • Member since 2017
  • Software Engineer
  • CLOUDCENTRIC INFOTECH


  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 1
    Questions
  • 46
    Replies
Note : it requires SOSL
To pass this challenge, create an Apex class that returns both contacts and leads that have first or last name matching the incoming parameter.
The Apex class must be called ContactAndLeadSearch and be in the public scope
The Apex class must have a public static method called searchContactsAndLeads
The method must accept an incoming string as a parameter
The method should then find any contact or lead that matches the string as part of either the first or last name
The method should finally use a return type of List<List< SObject>>


below is my code
public class ContactAndLeadSearch {
    
    public static List<List< SObject>> searchContactsAndLeads(String x){
        
        List<List<sObject>> searchList = [FIND {x} IN ALL FIELDS 
                   RETURNING Lead(FirstName,LastName),Contact(FirstName,LastName,Department)];
        
        return searchList;
    }
}
Dears,

Is it possible to hide a currency symbol in detail page ??

1. I have a custom field with the name of amount .

2. This field is displaying a value with INR (For Example : INR 1000.00)

3. My Expectation is , need to display an amount without INR  (For Example : 1000.00)

Is That Possible in salesforce 

Regards,
Soundar.
Hello
I am new to writing test class. I need help in writing test class for the following code.
scenairo: when I create a new account from UI, a nee opportunity record gets created under the account.
public class CreateNewOpportunity
{
   public List<Opportunity> oppList=new List<Opportunity>();
   
   public void CreateOpportunity(List<Account> accList)
   {
     for(Account a:accList)
     {
       Opportunity o = new Opportunity();
       o.AccountID=a.ID;
       
       o.Name=a.Name;
       o.CloseDate=System.Today().addDays(3);
       
       o.StageName='Prospecting';
       
       oppList.add(o);
     }
     
     if (oppList.size() > 0)
         Database.Insert(oppList);
   }
}

trigger trg_createnewoppor on Account (after Insert,after update)
{
  if ((Trigger.isInsert) || (Trigger.IsBefore))
  {
    CreateNewOpportunity o = new CreateNewOpportunity();
    o.CreateOpportunity(Trigger.New);
  }
}


Thanks
smita
trigger trigger52 on India__c (after insert) {
  list<san_francisco__c> con =new list<san_francisco__c>();  

    for(India__c h : trigger.new){
     san_francisco__c s = new san_francisco__c();
      s.Name=h.Name;
        s.Company__c=h.Company__c;
        s.Mobile__c=h.Mobile__c;
           s.Email__c=h.Email__c;
        con.add(s);
        
        
    }
    insert con;
}
Hi All,

I want insert the same attachment of the Opportunity object to the Account object.
When I query to the attachment object and get the body of that file then I'm not able to convert the "Blob" format of that body.

Please give the correct tested solution (snippet code).

Thanks in Advance.
The current situation is like this:
When i click on the radiobutton it passes the corresponding accountId to the following function.
doUpdate: function(component,event){
        var action = component.get("c.doUpdate");
        action.setParams({req : 'test'});
        action.setCallback(this, function(response){ 
            var selectedRows = event.getParam('selectedRow');
            var navigateEvent = $A.get("e.force:editRecord");
            navigateEvent.setParams({ "recordId": selectedRow[0].Id  });
            navigateEvent.fire();
        });
         $A.enqueueAction(action);
    }

The code in the setCallback lets me popup the account edit screen successfully. The problem is that the popup loads the default recordtype layout. I am expecting the custom Lightning component to be loaded in the popup ( I could override the editbutton on customer page, but how to mimic this edit button click in code?).
 
Hello,

Need your suggestion if anybody faced smilar issue before.

Since the last couple of days facing an issue while validating changeset on production. I tried almost all ways from my end but not able to tackle the issue yet. Please share your suggestions, if any.

I have an apex class which is 96% cover without any failure on sandbox.
When I am trying to validate the same with its test class on the production I am getting an error like below:
User-added image

I am passing the Case Id to the method and used it to filter in the SOQL of its custom child object called "Service Report". This query results in empty using the 'Case Id' on Production only. I am not facing this issue in the sandbox.  
Production's overall coverage is 85%.

Debug from the production:
User-added image

Hopes to hear back from you!
Welcome to your suggestions!

Thanks,
Nilesh
 
Note : it requires SOSL
To pass this challenge, create an Apex class that returns both contacts and leads that have first or last name matching the incoming parameter.
The Apex class must be called ContactAndLeadSearch and be in the public scope
The Apex class must have a public static method called searchContactsAndLeads
The method must accept an incoming string as a parameter
The method should then find any contact or lead that matches the string as part of either the first or last name
The method should finally use a return type of List<List< SObject>>


below is my code
public class ContactAndLeadSearch {
    
    public static List<List< SObject>> searchContactsAndLeads(String x){
        
        List<List<sObject>> searchList = [FIND {x} IN ALL FIELDS 
                   RETURNING Lead(FirstName,LastName),Contact(FirstName,LastName,Department)];
        
        return searchList;
    }
}
Hello All.
I have a class that looks for existing Leads with the same email address. 
If the email address exist add a task to the existing Lead.  This works.
The issue is that is still allows the creation of the duplicate Lead.  I do not want to throw an error message since the Leads may be imported via data loader.  If its creating a task because the email address already exist it should not be creating the lead.
Thanks,
M
trigger LeadPreventDuplicate on Lead (before insert,before update) {

    Map<String, Lead> leadMap = new Map<String, Lead>();
    for (Lead lead : System.Trigger.new) {
        
       //  Make sure we don't treat an email address that isn't changing during an update as a duplicate.  
    
        if ((lead.Email != null) && (System.Trigger.isInsert ||
                (lead.Email != System.Trigger.oldMap.get(lead.Id).Email))) {
                leadMap.put(lead.Email, lead);
       }
    }
    
    List<task> addtask=New List<task>();
    for (Lead lead : [SELECT Email FROM Lead
                      WHERE 
                      Email IN :leadMap.KeySet()]) {
        Lead newLead = leadMap.get(lead.Email);
        
       // newLead.Email.addError('A lead with this email '
                        //       + 'address already exists.');
        addtask.add(new Task(
        WhoID =lead.id, 
        Status = 'Active',
        Subject = 'Test Task',
        ActivityDate = system.today()
        ));
        
       } 
         insert addtask;        
                                                            
}

 
I'm looking to create a user with very limited permissions. They only need to be able to create views in Leads and Contacts. So the most limited permissions with the ability to create views. Then I'd like to login as that user and test something out with the integration my Dev team has built. I know how to create a user but how do I limit their permissions?
Hi All,

I want insert the same attachment of the Opportunity object to the Account object.
When I query to the attachment object and get the body of that file then I'm not able to convert the "Blob" format of that body.

Please give the correct tested solution (snippet code).

Thanks in Advance.
I am having a junction object named "Assignemnt" which is having Lookup relationship to two objects "Project" and "Consultant".
Here My requirement is that same project can not assgned to a consultant which is having for same as for example:-

Niraj PHP
Niraj .Net
Then Again not should be
Niraj PHP

Please guide me......
Hi, 
I have Opportunity object and I want to show "Thank_You_Letter_Sent_Date" custom field in Related list. However, I can't find that custom field in Related List Properties. Can anyone suggest me how I can display this field in related list? 
User-added image
Thanks. 
A very simple question,

Suppose I send a request to oauth (part of my codes are shown here):
 
<html>

<head>
    <script type="text/javascript">
        function login() {

            alert("Now you are going to log into Salesforce...");
            // According to the client_id, client_secret, you can directly
            // go to the Salesforce

            window.open('https://test.salesforce.com/services/oauth2/authorize?response_type=code&client_id=xxxx&redirect_uri=https://www.getpostman.com/oauth2/callback&display=popup');
        }
    </script>
</head>

<body>
    <button onclick="login()">Login To Salesforce</button>
</body>

</html>

I want to make it a Modal Popup, so can this be done?
I have a Javascript button on our classic view that needs to be replaced in Lightning. I am not a developer, just Admin, and I need to make this button available in Lighning. Any help is very much appreciated.

Workflow will run when a new Opportunity record is created and edited and the hidden Send Employer Survey Email custom opportunity field checkbox is updated to TRUE. Custom opportunity button Send Employer Survey button will update it to TRUE.

Workflow Rule Detail  
Rule NameSend Employer SurveyObjectOpportunity
ActiveEvaluation CriteriaEvaluate the rule when a record is created, and any time it's edited to subsequently meet criteria
DescriptionWorkflow will run when a new Opportunity record is created and edited and the hidden Send Employer Survey Email custom opportunity field checkbox is updated to TRUE. Custom opportunity button Send Employer Survey button will update it to TRUE.
Rule CriteriaOpportunity: Employer Survey Email SentEQUALSTrue
 
Workflow Actions
Immediate Workflow Actions
Type/Description
Email AlertSend Employer Survey Email
Email AlertSent Employer Survey Notification to Opportunity Owner
Field UpdateSurvey Sent Date

Thank you!
Hello,

How can we send sms from salesforce ?
 
  • November 19, 2018
  • Like
  • 0
hi everyone,
 I would like to get the filed values of that we queried...below i would get the schema.sobjectfileds...
i have related object fileds in my query like account.name,account.type,account.industroy ,name,id from contact.
I would like store only above files and i wold like get the vaues respectively using schema.SobjectField 

private void discoverAccessibleFields(sObject newObj) {
32        list< Schema.SobjectField> accessibleScheama = new List< Schema.SobjectField>();
33        Map<String, Schema.SobjectField> fields =
34            newObj.getSObjectType().getDescribe().fields.getMap();
35        for ( Schema.SobjectField s : fields.values()) {
36            accessibleScheama .add(a)
38            }
39        }
40    }
  • November 19, 2018
  • Like
  • 0
hi,

i am faceing a probject for coverage a unit test code please help me ?

trigger on inforamtionManagement on informationManagement__c(After insert) {
    for(informationManagement__c infoobj:trigger.new){
    
    if(infoobj.canclae_Event__c== False && infoobj.Target_People__c=='Person'){
        Resitration_from__c rsfobj=new Resitration_from__c();
        rsfobj.Record_type='new';
        rsfobj.Account_Name=infoobj.lead_Name__c;
        rsfobj.start_date__c=infoobj.start_date__c;
        isnert(rsfobj);
    
    
    
    
    }
    
    
    
    }

}
  • November 19, 2018
  • Like
  • 0
 i used below query in start method
select id,firstname,account.name,account.type ,accountd from contact
but i when i debugged the Scope records, am able to see  only id,firstname,accoundid data,
it is saying account.name is invalid filed...

any suggess please
  • November 19, 2018
  • Like
  • 0
Hi. I'm having trouble with one of the exercises in the Get Started with Apex Triggers module, where you call a Class Method from a Trigger.

Here is the trigger I created. 


trigger ExampleTrigger on Contact (after insert, after delete) {
    if (Trigger.isInsert) {
        Integer recordCount = Trigger.New.size();
        // Call a utility method from another class
        EmailManager.sendMail('dtcarney08@gmail.com', 'Trailhead Trigger Tutorial', 
                              recordCount + ' contact(s) were inserted.');
    }
    else if (Trigger.isDelete) {
        // Process after delete
    }
}

This calls on this public class called EmailManager

public with sharing class EmailManager{
    public static void sendMail(String[] addresses, String[] subjects, String[] messages) {
        Messaging.SingleEmailMessage [] emails = new Messaging.SingleEmailMessage[]{};
        Integer totalMails = addresses.size();
        for(Integer i=0; i < totalMails; i++){
            Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
            email.setSubject(subjects[i]);
            email.setToAddresses(new List<String> { addresses[i] });
            email.setPlainTextBody(messages[i]);
            emails.add(email);
        }
        Messaging.sendEmail(emails);
    }
}

However, there is a problem that shows up in the Developer Console that says “Method does not exist or incorrect signature: void sendMail (String, String, String) from the type EmailManager. I thought that I made the method static and I'm not sure what's wrong now. Any ideas of what's wrong?
Hello all, 
I am really having trouble for the past week and have not gotten any solutions thus far.

I wrote a trigger to send an email every time a file is uploaded, 
It has 100% coverage and from the log it is apparent that the email is sent out
The setting for deliveribilty is set to all emails, and I tested deliveribility with success.
And yet I am not getting the email

Can anybody help me figure out why??

This is the code
trigger NewFileAlert on ContentDocument (after insert) 
{
// Step 0: Create a master list to hold the emails we'll send
  List<Messaging.SingleEmailMessage> mails = 
  new List<Messaging.SingleEmailMessage>();
  
  for (ContentDocument newDoc : Trigger.new) 
  {
     // Step 1: Create a new Email
          Messaging.SingleEmailMessage mail = 
          new Messaging.SingleEmailMessage();
    
          // Step 2: Set list of people who should get the email
          List<String> sendTo = new List<String>();
          sendTo.add('test@gmail.com');
....
          mail.setToAddresses(sendTo);
    
          // Step 3: Set who the email is sent from
          mail.setReplyTo('me@gmail.com');
          mail.setSenderDisplayName('Aidel Bruck');
    
       
          // Step 4. Set email contents - you can use variables!
          mail.setSubject('New Document Added');
          String body = 'Please note: A new document has been added/n  ';
          body += 'File name: '+ newdoc.title+'/n' ;
          body += 'Created By: '+ newdoc.createdbyid+ '/n';
          body += 'Created Date: '+ newdoc.CreatedDate+ '/n';
          body += 'link to file: '+ System.URL.getSalesforceBaseUrl().getHost()+newdoc.id;
          mail.setHtmlBody(body);
    
          // Step 5. Add your email to the master list
          mails.add(mail);
    }
    
  // Step 6: Send all emails in the master list
   Messaging.SendEmailResult[] results = Messaging.sendEmail(mails);
 if (results[0].success) {
    System.debug('The email was sent successfully.');
 } else {
    System.debug('The email failed to send: '
          + results[0].errors[0].message);
 }
  
}


Thanks!
how to know which line of code we stopped and how to set debug points and logs 
  • November 17, 2018
  • Like
  • 0
trigger trigger52 on India__c (after insert) {
  list<san_francisco__c> con =new list<san_francisco__c>();  

    for(India__c h : trigger.new){
     san_francisco__c s = new san_francisco__c();
      s.Name=h.Name;
        s.Company__c=h.Company__c;
        s.Mobile__c=h.Mobile__c;
           s.Email__c=h.Email__c;
        con.add(s);
        
        
    }
    insert con;
}
trigger trigger52 on India__c (after insert) {
  list<san_francisco__c> con =new list<san_francisco__c>();  

    for(India__c h : trigger.new){
     san_francisco__c s = new san_francisco__c();
      s.Name=h.Name;
        s.Company__c=h.Company__c;
        s.Mobile__c=h.Mobile__c;
           s.Email__c=h.Email__c;
        con.add(s);
        
        
    }
    insert con;
}