• Dheeraj Chawla
  • NEWBIE
  • 54 Points
  • Member since 2015

  • Chatter
    Feed
  • 1
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 6
    Replies
how can I assign set & list values to map? and map values to set and list?
I have a requirement like there is a custom look field on my page. When I click on the look up field, a pop window will open which shows all records of account. I need to select one of the record. After clicking on one record, pop up window should be closed and that selected account record name will show on my look up field just like the standard look up.

I am able to pop up the new window but can not pass that record name on my look up field. Can anybody please help me...? 
What is the process to show custom look up field for Account object on visualforce page? Please Explain in simple language 
Can anybody help me... my test class does not showing 75% coverage. I write the class for trigger.
it does not cover line number 13, 14, 15 and 19. Can anybody please tell me where I am lacking.
MY trigger is----------

trigger TriggerOnLead on Lead (before insert, before update) 
{
    public List<lead_scoring_rule__c> obj=[Select active__c,rule_type__c,points__c, field_name__c,operator__c,value__c from lead_scoring_rule__c];
    public Map<String, Schema.SObjectType> leadMap = Schema.getGlobalDescribe();
    Schema.SObjectType leadSchema = leadMap.get('Lead');
    Map<String, Schema.SObjectField> leadfield = leadSchema.getDescribe().fields.getMap();
    for(lead l: trigger.new)
     {
          Double points=0;
          System.Debug('ttttttt');
       for(lead_scoring_rule__c ld:obj){
            System.Debug('lddddddddddd='    +    ld.field_name__c);
            System.Debug('fffffffffff='+l.get(ld.Field_Name__c));
            if(ld.active__c==true){
                if( l.get(ld.Field_Name__c)==ld.value__c){
                    points=points +ld.points__c;
                    System.Debug('Points Scored====='+ points);
                }
            }
            l.lead_score__c=points;
       }
     }
}
------------------------------------------------------------------------------------------------------------------------------------
And the test class is----




@isTest
private class TestTriggerOnLead {
    static testMethod void myUnitTest(){
        Lead_Scoring_Rule__c s=new lead_Scoring_Rule__c(Active__c=true, points__c=10,field_name__c='city',operator__c='==',value__c='Gurgaon');
        //List<lead> obj=new list<lead>();
            lead l=new lead(firstname='Test1',lastname='xyz',Company='Mansa', status='Not-Contacted',city='Gurgaon');
            insert l;
            insert s;
            lead ld=[select lead_score__c,city from lead where firstname='Test1' ];
            lead_scoring_rule__c nc=[select active__c, points__c,value__c from lead_scoring_rule__c where points__c=10]; 
            //System.Debug(ld.lead_score__c);
            if(nc.active__c==true){
                if(ld.city==nc.value__c){
                    ld.lead_score__c=nc.points__c;
                }
            }
            //System.assertEquals(l1.lead_Score__c,5);
            //System.assertEquals(l2.lead_Score__c,10);
    }
}

 
String objType=’Account’;
Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
Schema.SObjectType leadSchema = schemaMap.get(objType);
Map<String, Schema.SObjectField> fieldMap = leadSchema.getDescribe().fields.getMap();


 
Right now, I am using these line of code

Map<String, Schema.SObjectType> all_object = Schema.getGlobalDescribe();
Map<String,Schema.SObjectField> field = all_object.get(rule_type).getDescribe().fields.getMap();


but can't able to show the result on VF page....can anyone help me in this..?
Right now, I am using these line of code

Map<String, Schema.SObjectType> all_object = Schema.getGlobalDescribe();
Map<String,Schema.SObjectField> field = all_object.get(rule_type).getDescribe().fields.getMap();


but can't able to show the result on VF page....can anyone help me in this..?
Hi,
how to write test class for below coding.Plz help asap

global class Batch_to_SentEmailNotify implements Database.Batchable<sObject> 
 {
   global Database.QueryLocator start(Database.BatchableContext BC) 
    {
       string s='Blocked';
        String query = 'Select Resort_Master__r.Name,Executive_Name__r.Email__c,Name_of_the_Guest__c,Company_Name__c,Block_Release_Date__c,Check_In__c,Check_Out__c,Total_Number_of_Rooms_Booked__c,Booking_Status__c,Source__c,Market_Segment__c,Executive_Name__r.Name FROM Non_Member_Booking_Request__c where Booking_Status__c=: s';
        return Database.getQueryLocator(query);
    }
   
    global void execute(Database.BatchableContext BC, List<Non_Member_Booking_Request__c> scope) 
    {
         for(Non_Member_Booking_Request__c c : scope)
         {
           system.debug('++++++++++++++system.today ++++++++++++++'+system.today());
            string email = c.Executive_Name__r.Email__c;
            if(email !=null && (system.today() == c.Check_In__c))
            {
              Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
              mail.setUseSignature(false);
              mail.setToAddresses(new String[] { email});
              mail.setSubject('Booking Confirmation ');
              mail.setHtmlBody('Dear Team <br/>'+'Namaste !!!!<br/>'+'Please find the attached payment details of below room reservation.<br/>'+'Please check and confirm the CV with updated payment details.<br/>'
              );
              Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
              system.debug('@@@@@@@@@@@@@@@mail@@@@@@@@@@@@@@@'+mail);
            
           }
         }   
    }
    global void finish(Database.BatchableContext BC) 
    {
    }
}
Regards,
Hareesh
Hi,
I am trying to create a formula field on Case and I want an opportunity field in my formula but I do not have the option to choose opportunity object nor its fields. I understand I need to establish a relationship between Case and Opportunioty. Could someone tell me how I can do this? If the only way is creating a trigger then could you help me with how to create such a trigger as well please?  

Thanks, Jayashree
I've been working on an Org where a very large number (over 20,000) of Contacts have been deleted, then emptied from the Recycle Bin.

The Recycle Bin was emptied several days ago, but the Contacts are still visible with IsDeleted = true with an ALL ROWS SOQL query.

All the Salesforce documentation says is that the time to permanently delete emptied recycle bin records will be 'usually 24 hours but may be longer or shorter'. 

We have raised a Case with Salesforce Support, who suggested using the emptyRecycleBin method, but this has not worked as the Recycle Bin no longer contains the records in question.

Because we are using an ALL ROWS query in another part of our application these deleted records are causing problems - does anybody have any suggestions about how I can remove them?
how can I assign set & list values to map? and map values to set and list?
Hi, 

  We have a email field which is in firstname.lastname@domain.com format my requrement is to extract only the firstname from email field. please suggest me how to extract.

I tried below method which is returning firstname.lastname 
 
LEFT( Owner_Email__c,FIND( "@",Owner_Email__c ) - 1  )

Also when returning firstname can we keep the first letter as capital letter using formula please let me now

Thanks
Sudhir