• Linda 98
  • NEWBIE
  • 363 Points
  • Member since 2013

  • Chatter
    Feed
  • 8
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 167
    Questions
  • 258
    Replies

While coding I get double lines as shown:

User-added image

The further down the page I go the worse it is. Is there a fix for this that doesn't involve switching browsers, as I find Chrome useful. The further down the page of code I go, the worse it gets. I have tried increasing/decreasing font size, and that didn't work.

Hi

I am having an after update trigger which fires when a checkbox is set to true. It then creates records in the related object.
After creating(after trigger functionality is implemented), I want to make the checkbox again as false programmatically. How can I achieve this?
I tried to make it false after building the list, but I am facing Read only error.

Thanks
I am having a list of Occupations, Driver, Mechanic, Plumber, Carpenter, Chef.
I have contact records with above occupations. One contact can have multiple occupations too.
So I have a trigger which creates Opportunities with these contacts when another field is updated.
Currently i am creating only one opportunity for each contact, now I am trying to create one opportunity for each contact based on occupation. For instance,

contact 1 - name:contact1,occupation:chef,carpenter
contact 2-name:contact2,occupation:Chef,driver
contact 3 -name:contact3,occupation:driver,mechanic,Plumber

My occupation list contains :  Chef,Driver,mechanic

So it should create 5 opportunities( now it creates only 3 opportunities using 3 contacts) like
1.Name-opp1,contact(lookup)-contact1,Contact occ-chef
2.Name-Opp2,contact(lookup)-contact2,contact occu-Chef
3.Name-Opp3,contact(lookup)-contact2,contact occu-driver
4.Name-Opp4,contact(lookup)-contact3,contact occu-Driver
5.Name-Opp5,contact(lookup)-contact3,contact occu-mechanic
I have to iterate over the list of occupations,and create opportunity records.How can i get this change.Thanks all.
Hello all,
How can I include email service email when a customer replies to the email which is sent from custom record.??
When a customer (Contact in Salesforce) clicks Reply from his email id, it is only being sent to the sender so I am not able to get in my inbound email class. I am sure I have to include the email service email id when sending the email but not able to figure out how as I am sending email with template to the contact email using Workflow. How can I include?

Thank you,

 
I am having a Custom object which sends an email(Process builder does that) to the contact field on the record with a template.

I am trying to 
1. When the contact email clicks reply and fill the template, the response should be returned to the record and linked to the same record.
2. Parse the values in the template and update the record from which email is sent.
I am sure I have to use the inbound email service class but not able to figure on how it works and how to start with.
I had already read on email services and inbound email services but couldn't understand how can I implement that my particular req.

 
String level ='Top';
String query='select id,Custompicklist__c  from Contact';

 if(Roleslist.size() >0){
        for(Integer i =0; i<roles.size();i++){
            if(i==0){
             query +=' where account.Active__c=true and custompicklistfield__c=:level and roles__c INCLUDES (\''+roleslist[0]+'\'';    
            }else{
            query += ',\''+roleslist[i]+'\'';
            }
           } 
                query += ')' limit 3;     
        }
        c=database.query(query);


THIS BRINGS CONTACT IDs of CONTACTS WHOSE LEVEL IS SET TO HIGH. BUT WHEN the field is set to a null or different value, then the query goes wrong and fetches 0 records.

 
Having a trigger to fire when a value is changed.
On update of the field, it should consider multi-select picklist values(List of roles-As it's multi-select datatype, may have one role is chosen or multiple chosen) and use them in a query to contact(Multi-select picklist field). Further, I would like to use those contact ids to create records in another custom object.
I saved the roles on record(trigger.new) into a list. But when I try to query to contact, I am not able to get the values.

For instance,
Values on Record 1-
checkbox -checked to true(which fires trigger)
Roles- Manager; Owner; Supervisor

Contact records-
contact 1-
Roles :Manager;Supervisor
Contact 2-
Roles-Owner
Contact 3:
roles-Manager;Architect
Contact 4-
Roles-Manager
Contact 5-
Roles: Analyst;Architech

In the above example, I would like to get all the contact IDs except contact 5. I even want Contact 3 even his roles include Architect which is not in our record roles list. As he is having a manager role, I would like to collect it too.

I used 
conroles=[select id,Roles__c,Title from contact where Roles__c IN :Roleslist];
Roleslist=List of roles on Record.
But its only fetching first roles contact's.

Split(',') doesn't seem to work, What am I doing wrong?
My use case- Custom object linkedcontacts__c with Master detail relations on contact and customobject2__c objects.
Having two multi-select picklist fields on both the objects, Named as Roles.
I am having a trigger on customobject2 which fires when a field is changed, then I am trying to get those multi-select field values(roles) and check against contact roles, and link the related contacts.
My major issue is as they are multi-select values if multiple roles are chosen then how can I achieve this??

For instance, if I am having a CB2 record with roles director; manager, I should be able to query those contacts whose roles are director or manager or director and manager(if any) and should relate by inserting record in the linkedcontact__c object. 
Please guide me.Thank you.
 
Created a custom object on record detail page.VF page will search records by using query in controller.
It has a input field and holds search text.I want to have more flexibity with the search text.It is being filled with value from record field.Like name of record.But i would like to give user to change the search text if he wants and still fit in the query.Like dynamic text field.
It has to work two ways,value from standard field and also should work if user chnages the value and give new value.Please help.
 
How can I change the location of error message.? I have a button which when clicked if required fields are not filled then I want to display error message above the button.

Now it's displaying on top of the page. I want to change the location of the error message. Changed in CSS to display bottom. Still no luck.Anything that I am missing.???
I have an apex class and apex trigger which calculates rollup fields.(6 fields) and updates total fields on the custom object from account object.

Everything works fine but now I want to move this to scheduler class as accounts update doesn't take place from UI and it only updates with a daily run.
So we are trying to write a scheduler class. Below is my apex class and trigger which works fine but when I try to move it to scheduler class and schedule it i am getting an error saying the list has no rows.

I don't want to trigger this class but schedule it to run every day 10 PM EST as my account update runs at 9 PM EST.
Public class rollupclass {
    Public static void totalRollup(List<Account> Acctlist){
        set<id> oppIds = new set<id>();
       
        double totalamt = 0;
       
        try {
                for (Account objacc : acclist){
                    oppIds.add(objacc.Values__c);  //Lookup relationship
               } 

          values__c objval = [SELECT Id,amttotal__c FROM values__c WHERE Id = :oppIds];
 
          List<Account> listAcc = [SELECT Id, amt1__c FROM Account WHERE values__c =:objacc.Id];
                
           for(Account Accounttotals : listAcc) {
                        totalamt += Accounttotals.amt1__c ;
                 }
               
                 objval.amttotal__c = totalamt;
                  update objval;   
            } 
        catch (Exception e) {
            }
    }
 }


 
I have a trigger to create a child, sub child records when status is changed.
like. Opportunity with line items and when  status changed then create customobject__c and its line items.
Everything works fine till here.
but when a field on opportunity line items called as 'numberoflines' is updated, I am trying to update 'totallines' field on customobject line items object
I created a trigger on Opplineitems,which when changed,have to update totallines field onn customobjectlineitems.
trigger totallineupdate on Opplineitem (before update) {

    Map<id,customobjectlineitem__c> newMap =new Map<id,customobjectlineitem__c>();
    
    for(Opplineitem Oli :trigger.new)
    {
        
        Opplineitem oldLi = Trigger.oldMap.get(Oli.id);
        
        if(Oli.Numberoflines != OldFL.Numberoflines){
                
            customobjectlineitem__c Coli =new customobjectlineitem__c(Opportunity__c=oli.Opportunity__c,Totallines=oLI.numberoflines);
            newMap.put(OLI.Opportunity__c,coli);         
      }
   }
   update newMap.values();   //id not specifed error here
   
}


What am I doing wrong?

I used opportunity, opportunity line items as examples as it explains relations.Thank you


 
I am changing one particular  field by checking lastmodifeddate in my code.All works fine but i am struck with test class.I am chnaging multiple records from multiple objects so my batch class looks like below.
 
global class editrecords implements Database.Batchable<string>, Schedulable{
global boolean bool = false;

global Iterable<string> start(Database.BatchableContext ctx) {
    return new list<String> { 'CO__c', 'CO2__c', 'CO3__c','CO4__c'};
}
global void execute(Database.BatchableContext ctx, list<string> listObj) {
    list<sObject> editrecords = new list<sObject>();
    for(string strObjName : listObj) {
        for(sObject objsObject : database.query('Select Id from ' + strObjName + ' where LastModifiedDate < LAST_N_DAYS:36')) {
                editrecords.add(objsObject);
            else {
                b = true;
                break;
            }
        }
    }
    update editrecords;
}
global void finish(Database.BatchableContext ctx) {

}        global void execute(SchedulableContext sc){
         Database.executebatch(new editrecords ());    
    }
}

my test class is as below which get 58% of coverage.How can i get lastmodified date and cover rest of code.please help.
 
@isTest
Public class testeditrecords{

    static testMethod void testMethod1(){

        CO__c CO =new CO__c(Name='testdata');
        insert CO;
        CO2__c co2 =new 
  co2__c(Name='testdata');
        insert co2;
        Co3__c co3 =new Co3__c(Name='test2');
        insert co3;

       for(CO__c c:[Select ID from CO__c where createddate=TODAY]){
        Test.startTest();
       
        editrecords obj = new editrecords();
        Database.executeBatch(obj);
        Test.stopTest();       
        }
   } 
}

 
we are using App from app exchange which is managed.
we are trying to edit VF page to display parent fields using field sets.we are not able to get them on to vf page.
What am i missing??

my VF page is as below.
 
<apex:page standardController="Childobject__c" extensions="managedapexclass" recordSetVar="CO">
  <script>
        window.onload = function(e) {
           var recordIds = '{!selected}';
           var Objectname = 'Childobject__c';
           var action = 'Edit';
           var fieldsetName = 'Myfieldset name';
           
          if(recordIds!='')
          {
              Redirect(recordIds,Objectname,action,fieldsetName);
          }
          else
          {
            alert('Please select a record.');
            window.history.back();
          }
            };
      </script>
 <apex:form >
 <apex:actionFunction action="{!Redirect}" name="Redirect" rerender="none">
   <apex:param name="recordIds" assignTo="{!recordIds}" value=""/>
   <apex:param name="Objectname" assignTo="{!objectName}" value=""/>
   <apex:param name="action" assignTo="{!action}" value=""/>
   <apex:param name="fieldsetName" assignTo="{!fieldsetName}" value=""/>

 </apex:actionFunction>
   

  </apex:form>
</apex:page>

 
I am trying to get the mid part of the string in my flow and use the string

Like    Hello:  Linda Klein :Thank you

I would like to get Linda Klein.As i am having other various conditions,I have to check if my string begins with Hello and contains thank you.
I have written it as below but i dont get value in my field update.
Where am i going wrong.


IF( AND( BEGINS(Info, 'Hello: ') ,(CONTAINS(Info, ':Thank you'))), MID(Info, FIND("Hello: ", info )+ 6 , 
(FIND(": Thank you", info )-11) - (FIND("Hello: - ",Info ))),info)

nO error..no value in field.I am struck.

Thanks!!
I am using a Workflow field update and having IF conditions in it.
I want to trim left(6) and right(20) parts
My example is

'You can call on: 123456789 -thank you'

this is my string of which i want  only 123456789

IF(BEGINS(Info,'You can call on:  '),RIGHT(info,LEN(info) -15),
info))

This is giving me '123456789 -thank you'
I am struck with errors here.(If is not allowing me more than 3 conditions) Pointers please.
I am having a long text area field which has long information.
I am trying get one middle line,which is like this.

xxxxxxx
xxxxxxxx
xxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxx




salesforce office:Working hours 
XXXXXXXXXXXXXX
XXXXXXXXXXXXX
XXXXXXXXXXXXXXXX


So i want to get everything after 'salesforce office: '

output in this case= 'working hours' This is dynamic value.

and save that it another text field.I am able to get that everything after office: but its not recognizing line break.


thats were i am struck..I am having other reasons to use apex trigger.So workflow or Builder doesnt work for me.
Any help?Thanks!!


 
We are using professional org.
Having a process builder which updates a field on some condition with formula type.

this is how the formula is ,i am using & between them.

I am having datetime field which is used in the update field but the format is being changed 


"Start Date:" & TEXT(DATETIMEVALUE([Opportunity].Date_Time_Start__c )) &
"End Date:" &TEXT([Opportunity].Date_Time_End__c ) &

This is the format i am looking for 
2/27/2018 4:00 PM

but this is how i am getting

2017-02-27 21:00:00Z 

How can i get this fixed?? 
 
We are using professional org.
Having a process builder which updates a field on some condition with formula type.

this is how the formula is ,i am using & between them.

I am having datetime field which is used in the update field but the format is being changed 


"Start Date:" & TEXT(DATETIMEVALUE([Opportunity].Date_Time_Start__c )) &
"End Date:" &TEXT([Opportunity].Date_Time_End__c ) &

This is the format i am lookinh for 
2/27/2018 4:00 PM

but this is how i am getting

2017-02-27 21:00:00Z 

How can i get this fixed?? 

 
I am trying to get increase code coverage for this code which is part of unmanaged package.
I could get onlyy 12 lines out of 51 .Which is casuing for my other code to fail in deployment.

Please help me.

this is the apex class
public class CreateStatementPDFConroller{
public String todayDate {get;set;}
public  String ids {get;set;}
public Map<String,accountInDirectPrice> accountInDirectPriceMap{get;set;}

public Map< Account , List< AcctSeed__Billing__c > > accountBillingMap {get;set;}
    public CreateStatementPDFConroller(){
        
        accountInDirectPriceMap = new Map<String,accountInDirectPrice>();
        
        List<Account> accList = [Select Id,Name,Account_Code__c,AcctSeed__Billing_Contact__r.Email FROM Account WHERE Balance_Remaining__c > 0 AND RecordType.Name =: Label.SubAgentAccount];
        ids = '';                                             
        for(Account acc:accList) {
            ids += acc.Id + ',';
        }
        
        todayDate = Datetime.now().format('MM/dd/yyyy');
        accountBillingMap = New Map< Account , List< AcctSeed__Billing__c > >();
        // parameter ids 
             //ids = ApexPages.currentPage().getParameters().get('id');
        if( String.IsNotBlank( ids ) ){
            List< String > idLst = ids.split(','); 
            
            Map< Id , Account > accountMap = New Map< Id , Account >([SELECT Id, Account_Code__c, Name, BillingStreet, BillingCity, BillingState, BillingPostalCode, BillingCountry 
                                  FROM Account 
                                  WHERE Id IN : idLst]);
            // fill account to map                       
            for( Account ac : accountMap.values() ){
                accountBillingMap.put(ac , New List< AcctSeed__Billing__c >());
                accountInDirectPrice accval = new accountInDirectPrice();
                accountInDirectPriceMap.put(ac.id,accval);
            }   
                               
            List< AcctSeed__Billing__c > billing = [SELECT Id ,AcctSeed__Age__c ,Name, AcctSeed__Customer__r.Name,Insured__c,AcctSeed__Status__c,AcctSeed__Proprietary_Billing_Number__c,AcctSeed__Date__c,Policy__r.Billing_Company__r.Name,Policy__r.Effective_Date__c,Policy__r.Name,AcctSeed__Due_Date2__c,Policy__r.Name_Insured__c,Policy__r.Policy_Type__c,Policy__r.Status_Type__c,
                                          Sub_Agent_Percent__c,Sub_Agent_Commission_Total__c,Transaction__r.Transaction_Amount__c,Transaction__r.Account__r.Name,AcctSeed__Total__c,Transaction__r.Name,Amount_Due__c,Billing_Type__c,AcctSeed__Balance__c,AcctSeed__Received_Amount__c  FROM AcctSeed__Billing__c 
                                          WHERE AcctSeed__Customer__c IN : idLst  ];
            if( !billing.IsEmpty() ){
                for( AcctSeed__Billing__c ab : billing ){
                    if( accountMap.containsKey(ab.AcctSeed__Customer__c) && accountBillingMap.containsKey(accountMap.get(ab.AcctSeed__Customer__c) ) ){
                       
                        //ab.AcctSeed__Date__c = date.ValueOf(DateTime.newInstance(ab.AcctSeed__Date__c.month(),ab.AcctSeed__Date__c.day(),ab.AcctSeed__Date__c.year()).format('d-MM-YYYY'));
                        accountBillingMap.get(accountMap.get(ab.AcctSeed__Customer__c)).add(ab);
                    }
                    
                    if(accountMap.containsKey(ab.AcctSeed__Customer__c)){
                            
                            if(accountInDirectPriceMap.containsKey(ab.AcctSeed__Customer__c) && ab.AcctSeed__Age__c != null && ab.AcctSeed__Age__c != '' && ab.AcctSeed__Age__c != 'Closed'){
                                
                                accountInDirectPrice accval = accountInDirectPriceMap.get(ab.AcctSeed__Customer__c);
                                if(ab.AcctSeed__Age__c == '0-Current'){
                                    
                                    accval.currentPrice += ab.AcctSeed__Balance__c;
                                
                                } else if(ab.AcctSeed__Age__c == '1-30 Days'){
                                    
                                    accval.to30Days += ab.AcctSeed__Balance__c;
                                    
                                } else if(ab.AcctSeed__Age__c == '31-60 Days'){
                                    
                                    accval.to60Days += ab.AcctSeed__Balance__c;
                                    
                                } else if(ab.AcctSeed__Age__c == '61-90 Days'){
                                    
                                    accval.to90Days += ab.AcctSeed__Balance__c;
                                    
                                } else if(ab.AcctSeed__Age__c == 'Over 90 Days'){
                                                                    
                                    accval.over90days += ab.AcctSeed__Balance__c;
                                }
                                
                                accountInDirectPriceMap.put(ab.AcctSeed__Customer__c,accval);
                                
                                
                            }  
                     }
                }
            }
        }        
    }
    
    public class accountInDirectPrice{
      
      public Decimal currentPrice {get;set;}
      public Decimal to30Days{get;set;}
      public Decimal to60days{get;set;}
      public Decimal to90days{get;set;}
      public Decimal over90days{get;set;}
      
      public accountInDirectPrice(){
          
          currentPrice = 0;
          to30Days = 0;
          to60Days = 0;
          to90Days = 0;
          over90days = 0;
      }
    }
}

test class
 
@isTest
public class CreateStatementPDFConrollerTest {
    @isTest
    public static void unitTest(){
        List<Account> accountLst = new List<Account>();
        Account accObj1 = new Account(Name='test',Balance_Remaining__c=20);
        accountLst.add(accObj1);
        Account accObj2 = new Account(Name = 'test',Balance_Remaining__c=23);
        accountLst.add(accObj2);
        insert accountLst;

        RecordType RecordType1 = [SELECT Id from RecordType where name='General Liability' and sobjecttype = 'Policy__c'];
        
        Policy__c policyObj = new Policy__c();
        policyObj.recordTypeId = RecordType1.Id;
        policyObj.Account__c = accountLst[0].Id;
        policyObj.Name = 'test';
        policyObj.Agency_Commission__c = 10.1;
        policyObj.Billing_Type__c = 'Agency Bill';
        policyObj.Billing_Company__c = accountLst[1].Id;
        insert policyObj;
        
        Transaction__c transObj = new Transaction__c();
        transObj.Account__c = accountLst[0].Id;
        transObj.Policy_Name__c = policyObj.Id;
        transObj.Transaction_Amount__c = 10;
        transObj.Tran_Code__c = 'Audit Premium- Add';
        transObj.Client_Type__c='Direct Insured';
        insert transObj;
        
        AcctSeed__Accounting_Period__c accountingPeriod = new AcctSeed__Accounting_Period__c();
        accountingPeriod.Name = '2016-12';
        accountingPeriod.AcctSeed__Start_Date__c = System.today().addDays(792);
        accountingPeriod.AcctSeed__End_Date__c = System.today().addDays(7888);
        accountingPeriod.AcctSeed__Status__c = 'Open';
        insert accountingPeriod;
        
        AcctSeed__Billing_Format__c billingformatObj = new AcctSeed__Billing_Format__c();
        billingformatObj.name = 'test';
        billingformatObj.AcctSeed__Type__c = 'Billing';
        billingformatObj.AcctSeed__Visualforce_PDF_Page__c = 'BillingActivityStatementPDF';
        billingformatObj.AcctSeed__Default_Email_Template__c = 'Activity_Statement_Email_Template';
        insert billingformatObj;
        
        AcctSeed__Billing__c billingObj = new AcctSeed__Billing__c();
        billingObj.AcctSeed__Status__c = 'In Process';
        billingObj.AcctSeed__Customer__c = accountLst[1].Id;
        billingObj.Transaction__c = transObj.Id;
        billingObj.Policy__c = policyObj.Id;
        billingObj.AcctSeed__Date__c = System.today().adddays(76);
        billingObj.AcctSeed__Accounting_Period__c = accountingPeriod.Id;
        billingObj.AcctSeed__Billing_Format__c = billingformatObj.Id;
        insert billingObj;
        
        ApexPages.currentPage().getParameters().put('id',accountLst[0].id);
        CreateStatementPDFConroller controllerObj = new 
        CreateStatementPDFConroller();
        
       

    }
}

 
My company has decided to move entire metadata and data to new org.(Due to some reasons)
So i am trying to start with that.Apart from data,we are having apps,installed packages,std objects,custom objects,community, and many more

So where should i start with?what should i transport first?
Any pointers please.
I am having a VF page and class and test class.I am getting 43% code coverage.How can i increae it?
Below is my aoex class which gets value from user on VF page and creates account.

When i debug the test classs,i am not getting account.name value even though i gave a.name='testaccount' in my test class.
So i am able to cover those lines of code.Please help me what am i missing.
 
public class new_classforpage {
    Public customobjectt__c pr{get;set;}
    
    Public string accountname{get;set;}
    public string contactname{get;set;}
    public string contactemail{get;set;}
   
    public Account account {get;set;}


    public new_classforpage(ApexPages.StandardController sc) {
    pr= (object__c )sc.getRecord();
    account=new account();
    }
    
    Public pagereference save(){
     upsert pr;

    if(accountname!= '' && accountname!= null){
      
        account.name=accountname;
       
        upsert account;
        
        contact c=new contact();
        c.accountid=account.id;
        c.lastName=contactname;
        c.Email=contactemail;;
        insert c;
            
        pr.account_Name__c=account.id;
        update Pr;
    }
    
   return new PageReference('/'+pr.Id+'/e?retURL=%2F'+pr.Id);   
    }
}

and this is my test class:
 
@istest
Public class test_classforpage{
    static testMethod void test(){
        test.startTest();        
        PageReference pref = Page.mypage;
        Test.setCurrentPage(pref);
        
        
        Account a =new account();

        a.name='accountname';
       
        if(a.name!= '' && a.name!= null){

        upsert a;
        
        contact c=new contact();
        c.lastname='test contact';
        c.accountid=a.id;
        c.email='testemail@gmail.com';
        insert c;
        
        Purchase_request__c pr =new Purchase_request__c();
        pr.account_Name__c=a.id;
        
        insert pr;
        
        update pr;

        // Instantiate standard Controller
        ApexPages.StandardController sc = new ApexPages.StandardController(pr);

        // Instantiate controller extension
        myclass  mc = new myclass (sc);
                
        mc.save();
           test.stopTest();
}
     }
}


 
Hi,

i had build the package and all and ran the retrieve from command prompt.
I want custom fields to be retrived.So i had explicitly mentioned custom fields name in my package.xml file.
Like custom fields on standard objects .
But when i look at my retrived data,i dont see anything like that.
I am not able to conform that i got fields backed up.

I am scared to deploy again as i may loose the data.
Where can i find those data?Please point me regarding this.

Thanks in advance!!

 
I have a custom button which when clickd will execute a apex class.The whole logic is like this:
http://wiki.developerforce.com/page/The_Get_Next_Button#Quickstart:_The_Get_Next_Case_and_Get_Next_Lead_Button

I had customized this and using as per my req.This works perfect in sandbox where i just have test data.When moved to production where i have 500k records/leads i get the error TOO MANY DML ROWS:10001

Can any one please tell me what am i missing?
Do i need to bulkify my class still?
Please help ..
Below is my apex code:

global without sharing class RetrieveNextUtils {
    webService static Id retrieveNextLead(String userId){
  
    String RtID=null;   
    String query ='Select Id,Owner.name,status,Time_Zone__c from Lead where Status =\'new\' ';
    query=query+ ' and owner.Name= 'Queue'  FOR UPDATE';  //Locking statment as when two users click the button they are pulling same lead .
    try{
    List<Lead> leads = Database.Query(query); 
   
    for(integer i=0;i<leads.size();i++)
    {
        String tzname = leads[i].time_zone__c;
        String str_LeadCurrTime= DateTime.now().format('HHmm',tzname);
     
        if(str_LeadCurrTime >=  '0900' && str_LeadCurrTime <= '1145' || str_LeadCurrTime >= '1315' && str_LeadCurrTime <= '1700' )
        {   
             leads[i].OwnerId =UserInfo.getUserId();
             RtID=leads[i].Id;
             break;
         } 
   }
   update leads;
   return RtID;
   }
   Catch(exception ex){
        return RtID;
   }

}
}

Having a trigger to fire when a value is changed.
On update of the field, it should consider multi-select picklist values(List of roles-As it's multi-select datatype, may have one role is chosen or multiple chosen) and use them in a query to contact(Multi-select picklist field). Further, I would like to use those contact ids to create records in another custom object.
I saved the roles on record(trigger.new) into a list. But when I try to query to contact, I am not able to get the values.

For instance,
Values on Record 1-
checkbox -checked to true(which fires trigger)
Roles- Manager; Owner; Supervisor

Contact records-
contact 1-
Roles :Manager;Supervisor
Contact 2-
Roles-Owner
Contact 3:
roles-Manager;Architect
Contact 4-
Roles-Manager
Contact 5-
Roles: Analyst;Architech

In the above example, I would like to get all the contact IDs except contact 5. I even want Contact 3 even his roles include Architect which is not in our record roles list. As he is having a manager role, I would like to collect it too.

I used 
conroles=[select id,Roles__c,Title from contact where Roles__c IN :Roleslist];
Roleslist=List of roles on Record.
But its only fetching first roles contact's.

Split(',') doesn't seem to work, What am I doing wrong?
My use case- Custom object linkedcontacts__c with Master detail relations on contact and customobject2__c objects.
Having two multi-select picklist fields on both the objects, Named as Roles.
I am having a trigger on customobject2 which fires when a field is changed, then I am trying to get those multi-select field values(roles) and check against contact roles, and link the related contacts.
My major issue is as they are multi-select values if multiple roles are chosen then how can I achieve this??

For instance, if I am having a CB2 record with roles director; manager, I should be able to query those contacts whose roles are director or manager or director and manager(if any) and should relate by inserting record in the linkedcontact__c object. 
Please guide me.Thank you.
 
Created a custom object on record detail page.VF page will search records by using query in controller.
It has a input field and holds search text.I want to have more flexibity with the search text.It is being filled with value from record field.Like name of record.But i would like to give user to change the search text if he wants and still fit in the query.Like dynamic text field.
It has to work two ways,value from standard field and also should work if user chnages the value and give new value.Please help.
 
I am changing one particular  field by checking lastmodifeddate in my code.All works fine but i am struck with test class.I am chnaging multiple records from multiple objects so my batch class looks like below.
 
global class editrecords implements Database.Batchable<string>, Schedulable{
global boolean bool = false;

global Iterable<string> start(Database.BatchableContext ctx) {
    return new list<String> { 'CO__c', 'CO2__c', 'CO3__c','CO4__c'};
}
global void execute(Database.BatchableContext ctx, list<string> listObj) {
    list<sObject> editrecords = new list<sObject>();
    for(string strObjName : listObj) {
        for(sObject objsObject : database.query('Select Id from ' + strObjName + ' where LastModifiedDate < LAST_N_DAYS:36')) {
                editrecords.add(objsObject);
            else {
                b = true;
                break;
            }
        }
    }
    update editrecords;
}
global void finish(Database.BatchableContext ctx) {

}        global void execute(SchedulableContext sc){
         Database.executebatch(new editrecords ());    
    }
}

my test class is as below which get 58% of coverage.How can i get lastmodified date and cover rest of code.please help.
 
@isTest
Public class testeditrecords{

    static testMethod void testMethod1(){

        CO__c CO =new CO__c(Name='testdata');
        insert CO;
        CO2__c co2 =new 
  co2__c(Name='testdata');
        insert co2;
        Co3__c co3 =new Co3__c(Name='test2');
        insert co3;

       for(CO__c c:[Select ID from CO__c where createddate=TODAY]){
        Test.startTest();
       
        editrecords obj = new editrecords();
        Database.executeBatch(obj);
        Test.stopTest();       
        }
   } 
}

 
I am using a Workflow field update and having IF conditions in it.
I want to trim left(6) and right(20) parts
My example is

'You can call on: 123456789 -thank you'

this is my string of which i want  only 123456789

IF(BEGINS(Info,'You can call on:  '),RIGHT(info,LEN(info) -15),
info))

This is giving me '123456789 -thank you'
I am struck with errors here.(If is not allowing me more than 3 conditions) Pointers please.
I am having a long text area field which has long information.
I am trying get one middle line,which is like this.

xxxxxxx
xxxxxxxx
xxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxx




salesforce office:Working hours 
XXXXXXXXXXXXXX
XXXXXXXXXXXXX
XXXXXXXXXXXXXXXX


So i want to get everything after 'salesforce office: '

output in this case= 'working hours' This is dynamic value.

and save that it another text field.I am able to get that everything after office: but its not recognizing line break.


thats were i am struck..I am having other reasons to use apex trigger.So workflow or Builder doesnt work for me.
Any help?Thanks!!


 
We are using professional org.
Having a process builder which updates a field on some condition with formula type.

this is how the formula is ,i am using & between them.

I am having datetime field which is used in the update field but the format is being changed 


"Start Date:" & TEXT(DATETIMEVALUE([Opportunity].Date_Time_Start__c )) &
"End Date:" &TEXT([Opportunity].Date_Time_End__c ) &

This is the format i am lookinh for 
2/27/2018 4:00 PM

but this is how i am getting

2017-02-27 21:00:00Z 

How can i get this fixed?? 

 
I am trying to get increase code coverage for this code which is part of unmanaged package.
I could get onlyy 12 lines out of 51 .Which is casuing for my other code to fail in deployment.

Please help me.

this is the apex class
public class CreateStatementPDFConroller{
public String todayDate {get;set;}
public  String ids {get;set;}
public Map<String,accountInDirectPrice> accountInDirectPriceMap{get;set;}

public Map< Account , List< AcctSeed__Billing__c > > accountBillingMap {get;set;}
    public CreateStatementPDFConroller(){
        
        accountInDirectPriceMap = new Map<String,accountInDirectPrice>();
        
        List<Account> accList = [Select Id,Name,Account_Code__c,AcctSeed__Billing_Contact__r.Email FROM Account WHERE Balance_Remaining__c > 0 AND RecordType.Name =: Label.SubAgentAccount];
        ids = '';                                             
        for(Account acc:accList) {
            ids += acc.Id + ',';
        }
        
        todayDate = Datetime.now().format('MM/dd/yyyy');
        accountBillingMap = New Map< Account , List< AcctSeed__Billing__c > >();
        // parameter ids 
             //ids = ApexPages.currentPage().getParameters().get('id');
        if( String.IsNotBlank( ids ) ){
            List< String > idLst = ids.split(','); 
            
            Map< Id , Account > accountMap = New Map< Id , Account >([SELECT Id, Account_Code__c, Name, BillingStreet, BillingCity, BillingState, BillingPostalCode, BillingCountry 
                                  FROM Account 
                                  WHERE Id IN : idLst]);
            // fill account to map                       
            for( Account ac : accountMap.values() ){
                accountBillingMap.put(ac , New List< AcctSeed__Billing__c >());
                accountInDirectPrice accval = new accountInDirectPrice();
                accountInDirectPriceMap.put(ac.id,accval);
            }   
                               
            List< AcctSeed__Billing__c > billing = [SELECT Id ,AcctSeed__Age__c ,Name, AcctSeed__Customer__r.Name,Insured__c,AcctSeed__Status__c,AcctSeed__Proprietary_Billing_Number__c,AcctSeed__Date__c,Policy__r.Billing_Company__r.Name,Policy__r.Effective_Date__c,Policy__r.Name,AcctSeed__Due_Date2__c,Policy__r.Name_Insured__c,Policy__r.Policy_Type__c,Policy__r.Status_Type__c,
                                          Sub_Agent_Percent__c,Sub_Agent_Commission_Total__c,Transaction__r.Transaction_Amount__c,Transaction__r.Account__r.Name,AcctSeed__Total__c,Transaction__r.Name,Amount_Due__c,Billing_Type__c,AcctSeed__Balance__c,AcctSeed__Received_Amount__c  FROM AcctSeed__Billing__c 
                                          WHERE AcctSeed__Customer__c IN : idLst  ];
            if( !billing.IsEmpty() ){
                for( AcctSeed__Billing__c ab : billing ){
                    if( accountMap.containsKey(ab.AcctSeed__Customer__c) && accountBillingMap.containsKey(accountMap.get(ab.AcctSeed__Customer__c) ) ){
                       
                        //ab.AcctSeed__Date__c = date.ValueOf(DateTime.newInstance(ab.AcctSeed__Date__c.month(),ab.AcctSeed__Date__c.day(),ab.AcctSeed__Date__c.year()).format('d-MM-YYYY'));
                        accountBillingMap.get(accountMap.get(ab.AcctSeed__Customer__c)).add(ab);
                    }
                    
                    if(accountMap.containsKey(ab.AcctSeed__Customer__c)){
                            
                            if(accountInDirectPriceMap.containsKey(ab.AcctSeed__Customer__c) && ab.AcctSeed__Age__c != null && ab.AcctSeed__Age__c != '' && ab.AcctSeed__Age__c != 'Closed'){
                                
                                accountInDirectPrice accval = accountInDirectPriceMap.get(ab.AcctSeed__Customer__c);
                                if(ab.AcctSeed__Age__c == '0-Current'){
                                    
                                    accval.currentPrice += ab.AcctSeed__Balance__c;
                                
                                } else if(ab.AcctSeed__Age__c == '1-30 Days'){
                                    
                                    accval.to30Days += ab.AcctSeed__Balance__c;
                                    
                                } else if(ab.AcctSeed__Age__c == '31-60 Days'){
                                    
                                    accval.to60Days += ab.AcctSeed__Balance__c;
                                    
                                } else if(ab.AcctSeed__Age__c == '61-90 Days'){
                                    
                                    accval.to90Days += ab.AcctSeed__Balance__c;
                                    
                                } else if(ab.AcctSeed__Age__c == 'Over 90 Days'){
                                                                    
                                    accval.over90days += ab.AcctSeed__Balance__c;
                                }
                                
                                accountInDirectPriceMap.put(ab.AcctSeed__Customer__c,accval);
                                
                                
                            }  
                     }
                }
            }
        }        
    }
    
    public class accountInDirectPrice{
      
      public Decimal currentPrice {get;set;}
      public Decimal to30Days{get;set;}
      public Decimal to60days{get;set;}
      public Decimal to90days{get;set;}
      public Decimal over90days{get;set;}
      
      public accountInDirectPrice(){
          
          currentPrice = 0;
          to30Days = 0;
          to60Days = 0;
          to90Days = 0;
          over90days = 0;
      }
    }
}

test class
 
@isTest
public class CreateStatementPDFConrollerTest {
    @isTest
    public static void unitTest(){
        List<Account> accountLst = new List<Account>();
        Account accObj1 = new Account(Name='test',Balance_Remaining__c=20);
        accountLst.add(accObj1);
        Account accObj2 = new Account(Name = 'test',Balance_Remaining__c=23);
        accountLst.add(accObj2);
        insert accountLst;

        RecordType RecordType1 = [SELECT Id from RecordType where name='General Liability' and sobjecttype = 'Policy__c'];
        
        Policy__c policyObj = new Policy__c();
        policyObj.recordTypeId = RecordType1.Id;
        policyObj.Account__c = accountLst[0].Id;
        policyObj.Name = 'test';
        policyObj.Agency_Commission__c = 10.1;
        policyObj.Billing_Type__c = 'Agency Bill';
        policyObj.Billing_Company__c = accountLst[1].Id;
        insert policyObj;
        
        Transaction__c transObj = new Transaction__c();
        transObj.Account__c = accountLst[0].Id;
        transObj.Policy_Name__c = policyObj.Id;
        transObj.Transaction_Amount__c = 10;
        transObj.Tran_Code__c = 'Audit Premium- Add';
        transObj.Client_Type__c='Direct Insured';
        insert transObj;
        
        AcctSeed__Accounting_Period__c accountingPeriod = new AcctSeed__Accounting_Period__c();
        accountingPeriod.Name = '2016-12';
        accountingPeriod.AcctSeed__Start_Date__c = System.today().addDays(792);
        accountingPeriod.AcctSeed__End_Date__c = System.today().addDays(7888);
        accountingPeriod.AcctSeed__Status__c = 'Open';
        insert accountingPeriod;
        
        AcctSeed__Billing_Format__c billingformatObj = new AcctSeed__Billing_Format__c();
        billingformatObj.name = 'test';
        billingformatObj.AcctSeed__Type__c = 'Billing';
        billingformatObj.AcctSeed__Visualforce_PDF_Page__c = 'BillingActivityStatementPDF';
        billingformatObj.AcctSeed__Default_Email_Template__c = 'Activity_Statement_Email_Template';
        insert billingformatObj;
        
        AcctSeed__Billing__c billingObj = new AcctSeed__Billing__c();
        billingObj.AcctSeed__Status__c = 'In Process';
        billingObj.AcctSeed__Customer__c = accountLst[1].Id;
        billingObj.Transaction__c = transObj.Id;
        billingObj.Policy__c = policyObj.Id;
        billingObj.AcctSeed__Date__c = System.today().adddays(76);
        billingObj.AcctSeed__Accounting_Period__c = accountingPeriod.Id;
        billingObj.AcctSeed__Billing_Format__c = billingformatObj.Id;
        insert billingObj;
        
        ApexPages.currentPage().getParameters().put('id',accountLst[0].id);
        CreateStatementPDFConroller controllerObj = new 
        CreateStatementPDFConroller();
        
       

    }
}

 
My company has decided to move entire metadata and data to new org.(Due to some reasons)
So i am trying to start with that.Apart from data,we are having apps,installed packages,std objects,custom objects,community, and many more

So where should i start with?what should i transport first?
Any pointers please.