• Keyur Modi
  • SMARTIE
  • 702 Points
  • Member since 2015
  • Salesforce Developer

  • Chatter
    Feed
  • 24
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 1
    Questions
  • 158
    Replies
public static void accountOptyCount(List<Opportunity> optyList){
        List<Account> accList=new List<Account>();
        Set<Id> optyIds = new Set<Id>();        
        For(Opportunity op:optyList){
           optyIds.add(op.AccountId);
           System.debug('optyIds List=======>: '+optyIds); 
        }
        accList=[SELECT Id,optyCount__c,(SELECT Id from Opportunities) from Account where Id in:optyIds];
        System.debug('accList List=======>: '+accList);
        For(Account a:accList){
            a.optyCount__c=a.Opportunities.size();
            System.debug('Opportunity count=======>: '+a.optyCount__c);
           /* Decimal sum=0;
            For(Opportunity opp:a.Opportunities){                
                sum=sum+1;
                System.debug('Sum=======>: '+sum);
            }
            a.optyCount__c=sum; */
        }
        update accList;
    }
===========
If(Trigger.isBefore && Trigger.isInsert){        
        Opportunity_Trigger_handler.accountOptyCount(Trigger.new);}
Hello everyone,

The SalesForce REST API doc is unclear about the usage of APIs to insert and update records in OpportunityLineItem. The standard fields in OLI include OpportunityId and Product2Id both of which I'm populating by retrieving the appropriate SalesForce IDs. I receive this error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY when I try to insert a record at this URI: /sobjects/OpportunityLineItem/.

Going through the flow: https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_erd_products.htm#topic-title, I'm assuming this (and also the cross-reference error) means that there is no direct relationship between OLI and Products.

Firstly, why is there a Product2Id field if the relationship doesn't exist?
Secondly, is the URI I'm using incorrect? If so, what is the correct one?
Thirdly, can this problem be solved using APIs at all?

Maybe I'm going about this in a completely inefficient manner. Any suggestions would be greatly appreciated.
Hi All,

Q). 3 users with same profile (R/W permissions), need to remove Read permission for one user, how can we achieve that?

Can anyone reply for this post...
Thanks in advance.
I want pull only the list of records that match the ones i'm getting through a JSON array list. The json array list string doesn't have the Salesforce record ID.The JSON string looks like below. I use the rcNumber, accountNumber and bankName  as a composite primary key and what's returned on unpaidCode as a condition for updating records.
{
    "bacctList": [{
        "rcNumber": "RC-2848323",
        "accountNumber": "12324434",
        "bankName" :  "NEDBANK",
        "unpaidCode" : ""
    },
    {
        "rcNumber": "RC-002274",
        "accountNumber": "1111111",
        "bankName" :  "FNB",
        "unpaidCode" : "99"
    }]
}
The Logic of the class works perfectly, I just want to bulkify it. Please help!...the fist for loop (line 27) with an inner loop, I think is not best practice.
 
@RestResource(urlMapping='/dosystem/bankaccounts2/*')
global with sharing class BankAccountWebservice2 {
       
    //Decorator class- Retured JSON mapping
    global class BankAccountsReturned{
        public String rcNumber;             
        public String accountNumber;  
        public String bankName;
        public String unpaidCode;
        
        public BankAccountsReturned(String rcNum, String accNum, String bName, String uCode){
            this.rcNumber = rcNum;
            this.accountNumber = accNum;
            this.bankName = bName;
            this.unpaidCode =uCode;
        }          
    } 
    
    @HttpPatch
    global static List<Bank_Account__c > updateDateProcessed(BankAccountsReturned [] bacctList) {
        
        //St
        List<String> rcNumbers = new List<String>{};  
           
        List<Bank_Account__c> BAccList  = new List<Bank_Account__c>{};
        
        for (integer i=0; i< bacctList.size(); i++) {                                                         
             for(Bank_Account__c j : [select id, Account__r.Name, Account__r.RC_Account_No__c,Bank__c,RC_Account_No__c,Unpaid_Code__c  
                                                         FROM Bank_Account__c where 
                                                         RC_Account_No__c =: bacctList[i].rcNumber AND 
                                                         A_c_Number__c =: bacctList[i].accountNumber AND 
                                                         Bank__c =: bacctList[i].bankName ]){

              // If unpaidCode is blank then deactive bank account, DO NOT create case 
              if(bacctList[i].unpaidCode == ''){                      
                  BAccList.add(new Bank_Account__c(Id = j.Id, Debit_Order_A_c__c = false, Unpaid_Code__c = bacctList[i].unpaidCode));
              }
              /* If the error code is populated with 99 the DO NOT deactivate the bank account BUT
               create an active ADHOC record with the current Debit Order amount on the bank account. DO NOT Create Case */
              else if(bacctList[i].unpaidCode == '99'){
                  rcNumbers.add(j.Account__r.RC_Account_No__c);
                  BAccList.add(new Bank_Account__c(Id = j.Id, Debit_Order_A_c__c = true, Unpaid_Code__c = bacctList[i].unpaidCode));                  
              }
              //If unpaid code is any other number beside 99, deactivate and create a case
              else{
                 
                  rcNumbers.add(j.Account__r.RC_Account_No__c); //<--Populates the list with ONLY RC Numbers we need to create cases for
                  BAccList.add(new Bank_Account__c(Id = j.Id, Debit_Order_A_c__c = false, Unpaid_Code__c = bacctList[i].unpaidCode));
              
              }
            }                                  
        }  
        
        update  BAccList;
        
        //Create Adhoc records
        List<Ad_hoc_Debit_Orders__c> adhocRecords = new List<Ad_hoc_Debit_Orders__c>();
        for(Bank_Account__c createActiveDO : [select id, Bank__c,Unpaid_Code__c,
                                            (select Id,Current_DO__c from Bank_Account__c.Debit_Orders__r where Active__c = true Order by CreatedDate Desc LIMIT 1)
                                              from Bank_Account__c where id in: BAccList and Unpaid_Code__c= '99']){
                                              
            Ad_hoc_Debit_Orders__c ad = new Ad_hoc_Debit_Orders__c(); 
            ad.Bank_ID__c = createActiveDO.id;
            ad.Custom__c = 'Adhoc';
            ad.Debit_Order_amount__c = createActiveDO.Debit_Orders__r[0].Current_DO__c;
            ad.Active__c = true;   
            adhocRecords.add(ad);     
        }
        insert adhocRecords;
        
        
        //Get more details about the deactivated bank account inoder to be populated when creating case.
        List<Case> createCase = new List<Case>();
        for(Account oUsr: [SELECT Id, Name, RC_Account_No__c,
                                    (select Id, Name, email, phone from contacts where Primary_contact_Indicator__c = true order by createddate desc Limit 1),
                                    (select Id, Name, Bank__c from Account.Bank_Accounts__r where Debit_Order_A_c__c = true Order by CreatedDate Desc LIMIT 1 )
                                     FROM Account WHERE RC_Account_No__c in: rcNumbers ]){
            Case u = new Case();            
            u.AccountId = oUsr.id;
            u.ContactId = oUsr.Contacts[0].Id;        
            u.Status = 'New';
            u.Origin = 'API Call';
            u.Subject = 'Deactivated Bank Account';
            u.Description = 'Bank Account Deactivated for '+oUsr.Name +' Account with  '+oUsr.RC_Account_No__c+' Number';             
            createCase.add(u);
        }
        insert createCase;
       
       return BAccList;
       }         
    }
I would like to use best practice. Because the json array string doesn't have the salesforce record Id, I want to select only the records is salesforce that = my composite primary key. and store them on a list as it will have the Record ID which will make it easier to do processing & updates.
I want to count how many Contact has value under description field using for loop. Similarly if Contact object has custom field then how to count those field which has some value
SELECT COUNT() Amo__c FROM Contact WHERE Description != null
The above query is not working
Hello everybody,
I am trying to display all child records related to a parent account, but I want to display it on the child visualforce page, not on the parent's.  Site Visit1 is the child and Account is the parent Object.          
Currently I am hard coding the account Id in my controller. But I would like to be able to somehow populate accountId here automatically.

When someone is on a siteVisit page, should see all the child of the same Account of which current site visit is a child of. Lets say We are looking at siteVisit A which has Account B, I wanted to show all the other children of Account B on the siteVisit A page. (I thought can be done by vf page) but cant figure out how to bind the id of account here. BTW doctor_office is the master field (Account) on the site visit object.Below is my code:
Controller extension

public class extendSiteVisit { public List<Site_Visit1__c> sites{get; set;} public extendSiteVisit(ApexPages.StandardSetController controller) { sites = [select id, Time_and_Date__c, name, AccountId__c from site_visit1__c where doctor_office__r.Id='0013600000EWmkB']; } }

Vf page

<apex:page standardController="Site_Visit1__c" extensions="extendSiteVisit" recordSetVar="sites">
<apex:pageBlock > <apex:pageBlockTable var="s" value="{!sites}"> <apex:column headerValue="Name of Visit"> <apex:outputField value="{! s.Name}"/> </apex:column> <apex:column headerValue="Date of Visit"> <apex:outputField value="{! s.Time_and_Date__c}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:page> 
Hello Everyone, 

I would like to strip the time of the dynamically referenced date field as shown below. Any help is appreciated. 

Controller: 

public class examschedule1_con {

   public exam_schedule__c es {get; set;}
   public list<exam_schedule__c> ess {get; set;}
   public map<string,list<date>> maplist{get; set;}
   
   public examschedule1_con()
   {
     es = new exam_schedule__c();
   }
   
   public void getdata()
   {
     maplist = new map<string,list<date>>();
     
     ess = [select name, startdate__c, enddate__c, starttime__c, endtime__c, year__c, examtype__c, 
           subject1__c, subject2__c, subject3__c, subject4__c, subject5__c, subject6__c, subject7__c 
           from exam_schedule__c where year__c = :es.year__c ];
           
     for(exam_schedule__c e : ess)
     {
        if(!maplist.containskey(e.examtype__c))
        maplist.put(e.examtype__c,new list<date>());
        maplist.get(e.examtype__c).add(e.subject1__c);
        maplist.get(e.examtype__c).add(e.subject2__c);
        maplist.get(e.examtype__c).add(e.subject3__c);
        maplist.get(e.examtype__c).add(e.subject4__c);
        maplist.get(e.examtype__c).add(e.subject5__c);
        maplist.get(e.examtype__c).add(e.subject6__c);
        maplist.get(e.examtype__c).add(e.subject7__c);
     }
   } 
}

VF Page: 

<apex:page controller="examschedule1_con" showHeader="false">
 <apex:form >
  <apex:pageBlock >
   <apex:pageblockSection title="Enter Exam Details">
    <apex:inputfield value="{!es.Year__c}"/>
    <apex:commandButton value="Submit" action="{!getdata}"/>
   </apex:pageblocksection>
  </apex:pageblock>  
  <table border="1" width="600" align="center">
  <th>Exam Type</th>
  <th>Subject1</th>
  <th>Subject2</th>
  <th>Subject3</th>
  <th>Subject4</th>
  <th>Subject5</th>
  <th>Subject6</th>
  <th>Subject7</th>
  <apex:repeat value="{!maplist}" var="key">
  <tr>
  <td>{!key}</td>
  <apex:repeat value="{!maplist[key]}" var="value">
  <td>{!value}</td>
  </apex:repeat>
  </tr>
  </apex:repeat>
  </table>
 </apex:form>
</apex:page>

My Output: 

User-added image

Thank you,
Satya
Hi guys,

Any ideas why the formatting of an HTML table looks fine in a PageBlock and all over the place in a pgaeblocksection?

PageBlock
User-added image

PageBlockSection
User-added image

I already have a pageblock you see and dont want another pageblock within a pageblock. 

Any advice would be greatly appreciated

Thanks

Adam
var k=[Ramesh~22~Hyderbad,Suresh~34~Bangalore,Rakesh~36~pune];
i want split below like this

var empname contains list of (Ramesh,Suresh,Rakesh)
var empno   contains list of (22,34,36)
var location contains list of (Hyderbad,Bangalore,pune)
Hi Developers, 

Need your assistance with the issue we have with email to case.

All communication made to us made by emails, but we are missing many aspects we can use having accounts.
once email send we want to have account info to be inherit by the new generated case.

If there is an option to create an account from new generated case i would like to know how to do it.

I was adviced that there is an option of creating a triger.

Will appreciate your assitance with the below.

Michael 
Hi All,

My requirement is I have 2 radio buttons byname Movies,Events and When i click on movies related Movielist dropdown should appear similarly for events.I have a submit button byname ClickMe,if i click that button i want to display selected movie or an event.

I have done it partially,i need any of ur help as i am new to salesforce i am not exposed to these kind of scenarios.So please help me out.
I am sharing my code.Thanks in advance.


The dropdown in red box should come only if select any of above radio button.The text in yellow box should come only after Clicking Click Me button.
*********Vfpage******************

<apex:page id="pp" title="Movie's Now" controller="Movies" showHeader="false">
  <Apex:form >
   <apex:pageBlock title="Welcome to MOvie Selection Process">
   
   <!--   For Selecting Movie and Play        -->
      <apex:selectRadio value="{!s}" rendered="true">
        <apex:selectOptions value="{!items}"/>
      </apex:selectRadio><p/>
         <apex:actionSupport event="onclick" action="{!Click}" ReRender="in" >
            <apex:param assignTo="{!s}" name="ss" value="{!Movies}" />
         </apex:actionSupport>
           <!--<apex:actionFunction action="{!MovieSelection}"  name="MovieLocked" /> 
           <apex:actionFunction action="{!EventSelection}"  name="EventLocked" />-->
           
           <!-- for dropdown list -->
            <apex:selectList size="1" value="{!newmovies}" multiselect="false" rendered="{!newMovies!=null}" onclick="MovieSelection">
                <apex:selectOptions value="{!Movies1}"/>
                <apex:actionSupport event="onchange" reRender="in" action="{!MovieSelection}"/>
            </apex:selectList>
        
        
         <apex:selectList size="1" value="{!newEvents}" multiselect="false" rendered="{!newEvents!=null}">
            <apex:selectOptions value="{!Events1}"/>
        </apex:selectList>
        
        <!-- command button -->
        <apex:commandButton value="$$Click Me$$" action="{!Click}" rerender="out" status="status"/>
   </apex:pageBlock>
   
   
   <apex:outputpanel id="in" rendered="{!lmve.size != 0 && newEvents!=null || newmovies!=null}">
    
                              <apex:actionSupport event="onchange" rerender="out" status="status"/>
                          
   </apex:outputpanel>
   
   
   
   <apex:outputPanel id="out" rendered="{!lmve.size != 0}">
           <apex:outputText value="{!lmve}">The selected option is "{!s}"</apex:outputText>
           <apex:outputText value="{!lmve}">The selected Movie is "{!Events}"</apex:outputText>
          
     </apex:outputPanel> 
  </Apex:form>
</apex:page>
 
************Controller class**********************


public class Movies
{

  public String s{get;set;}
  public String name{get;set;}

  public boolean Movieflag{get;set;}
  public boolean Eventflag{get;set;}
  public  List<Movie__c> lmve{Get;Set;}
  public String Events{get;set;}
  public String Movies { get; set; }
  public boolean displayflag{get;set;}
  public List<SelectOption> options1{get;set;}
  public List<SelectOption> options2{get;set;}
  
  
  String[] newmovies= new String[]{};
  
  public String[] getnewmovies() {
            return newmovies;
        }
            
        public void setnewmovies(String[] newmovies) {
            this.newmovies= newmovies;
        }


  String[] newEvents=new String[]{};
  
  public String[] getnewEvents() {
            return newEvents;
        }
            
        public void setnewEvents(String[] newEvents) {
            this.newEvents= newEvents;
        }
  
  public Movies(){
   System.Debug('Helllo');
  }
  
  
  public PageReference Click()
  {
   Eventflag=false;
   if(s!=null && s.equalsIgnoreCase(Movies)){
    Movieflag=true;
   }
   
   else if(s!=null &&s.equalsIgnoreCase(Events)){
   Eventflag=true;
   }
   
   List<Movie__c> lmve=new List<Movie__c>();
   if(s!=null)
   lmve=[SELECT Id,Cinemas__c,name__c,Price__c,Tickets__c from Movie__c];
   
   return null;
  
  }
  
  
   public pagereference MovieSelection() 
    {
        Events=null;
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.confirm,'You Selected a movie'));
        return null;  
    }
    
    
    public pagereference EventSelection() 
    {
        Movies=null;
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.confirm,'You Selected an Event'));
        return null;  
    }
  

   public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>(); 
        options.add(new SelectOption('Movies','Movies'));
        options.add(new SelectOption('Events','Events')); 
        return options; 
    }
    
    public List<SelectOption> getMovies1() {
            List<SelectOption> options1 = new List<SelectOption>();
            options1.add(new SelectOption('Bahubali','Bahubali'));
            options1.add(new SelectOption('Rangitaranga','Rangitaranga'));
            options1.add(new SelectOption('BhaiJan','BhaiJan'));
            return options1;
        }
    public List<SelectOption> getEvents1() {
            List<SelectOption> options2 = new List<SelectOption>();
            options2.add(new SelectOption('abc','abc'));
            options2.add(new SelectOption('def','def'));
            options2.add(new SelectOption('sss','sss'));
            return options2;
        }
    

}

 
I have created a trigger which will change the asset date field when contract date changes.
The test codes only worked with Account, Contacts and Assets.
At the Sandbox, everything works fine with a 96% coverage, but it fails badly in production

It says at deployment validation that:
Component Errors

 

API Name
Type
Line
Column
Error Message
0 0 TestCaseEscalationAndOthers.CaseEscalationTest(), Details: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please enter the Phone Number (Format : Std Code-Phone Number): [Phone] Class.TestCaseEscalationAndOthers.CaseEscalationTest: line 8, column 1
0 0 CaseUpdateJobScheduler.CaseUpdateJobScheduler1(), Details: System.AsyncException: The Apex job named "Case Subject Update" is already scheduled for execution. Class.CaseUpdateJobScheduler.start: line 7, column 1
0 0 ApexScheduledClass.testSchedule(); null, Details: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please enter the Phone Number (Format : Std Code-Phone Number): [Phone] Class.ApexScheduledClass.testSchedule: line 59, column 1; Average test coverage across all Apex Classes and Triggers is 27%, at least 75% test coverage is required.
0 0 updateCasesAfter60Mins.updateCasesAfter60Mins(), Details: System.DmlException: Update failed. First exception on row 122 with id 500w000000nwwg5AAA; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Contact does not belong to the specified Account: [ContactId] Class.updateCasesAfter60Mins.UpdateOpenCases: line 18, column 1 Class.updateCasesAfter60Mins.updateCasesAfter60Mins: line 25, column 1

Apex Test Failures

 

Class Name
Method Name
Error Message
ApexScheduledClass testSchedule System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please enter the Phone Number (Format : Std Code-Phone Number): [Phone] 
Stack Trace: Class.ApexScheduledClass.testSchedule: line 59, column 1
CaseUpdateJobScheduler CaseUpdateJobScheduler1 System.AsyncException: The Apex job named "Case Subject Update" is already scheduled for execution. 
Stack Trace: Class.CaseUpdateJobScheduler.start: line 7, column 1
TestCaseEscalationAndOthers CaseEscalationTest System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please enter the Phone Number (Format : Std Code-Phone Number): [Phone] 
Stack Trace: Class.TestCaseEscalationAndOthers.CaseEscalationTest: line 8, column 1
updateCasesAfter60Mins updateCasesAfter60Mins System.DmlException: Update failed. First exception on row 122 with id 500w000000nwwg5AAA; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Contact does not belong to the specified Account: [ContactId] 
Stack Trace: Class.updateCasesAfter60Mins.UpdateOpenCases: line 18, column 1 Class.updateCasesAfter60Mins.updateCasesAfter60Mins: line 25, column 1

Those components that failed were not what Iadded to my change sets for deployment.
Why do they show error here?

Any help is appreciated.

Ben
id(autogenerated)            name
---------------------------------------------
a-001                          aaa
a-002                          bbb
a-003                          ccc
-------------------------------------------
the above table i am delete  a002 and a003 records, again insert another record ,this time automatically start with  a002

how to write trigger  any one explain
HI everyone,

How  to send email to multiple recepients from vf page.
I have a template for a Custom Object Business_Trip__c with Child relationship to Event via Custom Lookup.
I want to show related meetings.

Template below:

    <p><b>Planned Meetings:</b></p>
    <table border="1" >
        
        <apex:repeat var="cx" value="{!relatedTo.Meetings__r}">
            <tr>
                 <td>Name: {!cx.WhoId}</td>
                 <td>Date: {!cx.ActivityDate}</td>
                 <td>Company: {!cx.Whatid}</td>
                 <td>Subject: {!cx.Subject}</td>
                 <td>Notes: {!cx.Comments_Summary__c}</td>
            </tr>
             
        </apex:repeat>                 
    </table>
    <p />

Provides indecipherable results:

Planned Meetings:
**Name: 003J000001EWnkiIAD**    Date: Thu Jul 09 00:00:00 GMT 2015    **Company: 001J000001btDA7IAM**    Subject: Quarter review

When what I want is:

**Name: Joe Conact** Date: Thu Jul 09 00:00:00 GMT 2015    **Company: AcmeWidgetCo**. Subject: Quarter review

How do I get the names - the Contact and Account names -  from the relation? thanks!

I have tried:

<td>Name: {!cx.Who}</td> - Causes big error on test send

<td>Name: {!cx.WhoId.name}</td> - gets Error: Unknown property 'String.name'    

<td>Name: {!cx.WhoId__r.name}</td> 

and
<td>Name: {!cx.Who__r.name}</td>

Both get -     Error: Invalid field WhoId__r for SObject LookedUpFromActivity    
How to underline or highlight the selected radio button in vf page.
Hi, 

I am trying to display the account record details as well as the related contacts and opportunities for a selected account record through lookup.
I am stuck at the point where I am unable to obtain the record id for the selected account record.
Below is my code. Any help is appreciated. 

VF Page:

<apex:page controller="accountdisplay">
    <apex:form>
        <apex:pageBlock title="Display Account Details">
            <apex:outputText value="Select Account: " />
            <apex:inputField value="{!con.accountid}"/>
            <apex:commandButton action = "{!getdetails}" value='Submit' />
            <apex:pageBlockSection title="Account Details">
                <apex:outputtext value="{!acc.name}" />
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller:

public class AccountDisplay {

    public account acc {get; set;}
    public contact con {get; set;}
        
    public pagereference getdetails(){
        acc = [select id, name from account where id = :con.AccountId]; 
        return null;
    }
}

Thank You,
Satya
<!---Page---->
<apex:page standardController="account" sidebar="false" showHeader="false">
<!----- Form --->
    <apex:form id="ChangeStatusForm">
        <apex:pageBlock >
                <!----PAGE BLOCK ONE ------->
                <apex:pageBlockSection title="ACCOUNT DETAILS">
                <apex:inputField value="{!account.name}"/>
                <apex:inputField value="{!account.accountnumber}"/>
                <apex:inputField value="{!account.rating}"/>
                <apex:inputField value="{!account.industry}"/>
                </apex:pageBlockSection>
                
                <!---- PAGE BLACK TWO ------>
                <apex:pageBlockSection title="Category Details">
                <apex:inputField value="{!account.type}"/>
                <apex:inputField value="{!account.annualrevenue}"/>
                </apex:pageBlockSection>
            </apex:pageBlock>
        
                <!---- BUTTON ------->
                <div align="Center" draggable="false" >
                    <apex:commandButton value="SAVE" action="{!SAVE}"/>
                            </div>
    </apex:form>
</apex:page>
User-added image
When I am saving the account it's move to account object
I dont Want to move the account object. when i am saving the to stay the same page
How Plz Help....




 
  • July 08, 2015
  • Like
  • 0
Dear all, I need help with pop up window. Requirement is that everytime Opportunity Close Date is changed on edit page, pop should appear with a notificaton and then allow users to save the record. I`m new to VF and Apex. Can someone please help me with VF code or Jscript that works?

Any help is appreciated. Thanks!
Hi all,
I'm looking for a help with creating formula field based on four number fields (Qty1_c, Qty2_c, Qty3_c, Qty4_c) :

If Qty1_c > 0
and Qty2_c = no value
return ashould be = Qty1_c

if Qty2_c > 0
and Qty3_c = no value
return shoudl be = Qty2_c

if Qty3_c > 0
and Qty4_c = no value
return shoudl be = Qty3_c

if Qty3_c > 0
and Qty4_c > 0
return shoudl be = Qty4_c

Thanks for help.

 

Hi All, 

in chatter settings there is one field called "Recieve Email" if user unchecked this field then through trigger or through any imidiate action I want to checked that check box. 

This is the field which I mentioned above. Please zoom the Image to see that properly  

public static void accountOptyCount(List<Opportunity> optyList){
        List<Account> accList=new List<Account>();
        Set<Id> optyIds = new Set<Id>();        
        For(Opportunity op:optyList){
           optyIds.add(op.AccountId);
           System.debug('optyIds List=======>: '+optyIds); 
        }
        accList=[SELECT Id,optyCount__c,(SELECT Id from Opportunities) from Account where Id in:optyIds];
        System.debug('accList List=======>: '+accList);
        For(Account a:accList){
            a.optyCount__c=a.Opportunities.size();
            System.debug('Opportunity count=======>: '+a.optyCount__c);
           /* Decimal sum=0;
            For(Opportunity opp:a.Opportunities){                
                sum=sum+1;
                System.debug('Sum=======>: '+sum);
            }
            a.optyCount__c=sum; */
        }
        update accList;
    }
===========
If(Trigger.isBefore && Trigger.isInsert){        
        Opportunity_Trigger_handler.accountOptyCount(Trigger.new);}
Hi,

I have added dynamic table supporting nice in visual force page , now i need to modift rgem to support in lightning too 
Visual force Page 
<apex:page controller="DynamicTableController" showHeader="false" sidebar="false" lightningStylesheets="true">
    <html lang="en">

    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    </head>
<apex:pageBlock >
    <apex:form >
        <apex:actionFunction name="ObjectFileds" action="{!ObjectFields}"/>
        
        <apex:commandButton value="Show Table" action="{!ShowTable}"/>
        
        <apex:pageBlockSection >
            <apex:pageBlockSectionItem >
                <apex:outputLabel value="Select Object" id="obj"/>
                <apex:selectList multiselect="false" size="1" value="{!SelectedObject}" onchange="ObjectFileds();">
                    <apex:selectOption itemLabel="--None--" itemValue="--None--"/>
                    <apex:selectoptions value="{!supportedObject}" />
                </apex:selectlist>
            </apex:pageBlockSectionItem>
            
            <apex:pageBlockSectionItem >
                <apex:outputLabel value="Select Field" rendered="obj"/>
                <apex:selectList multiselect="true" size="5" value="{!SelectedFields}">
                    <apex:selectOption itemLabel="--None--" itemValue="--None--"/>
                    <apex:selectoptions value="{!fieldLableAPI}" />
                </apex:selectlist>
            </apex:pageBlockSectionItem>
            
            <apex:pageBlockTable rendered="{!IF(ObjectList.size > 0 , true , false)}" value="{!ObjectList}" var="rec">
                <apex:column value="{!rec.Id}" rendered="{!IF(SelectedFields.size == 0 , true, false)}"/>
                <apex:repeat value="{!SelectedFields}" var="FieldLable">
                    <apex:column value="{!rec[FieldLable]}" rendered="{!IF(FieldLable != '--None--' , true, false)}"/>
                </apex:repeat>
            </apex:pageBlockTable>
            
            <apex:outputPanel rendered="{!IF(ObjectList.size < 1 , true , false)}">
                <apex:pageMessage severity="ERROR" summary="No records to display"/>
            </apex:outputPanel>
            
        </apex:pageBlockSection>
        
    </apex:form>
</apex:pageBlock>
</html>
</apex:page>

Controller
 
public class DynamicTableController
{
    //List displayed on UI
    public List<selectoption> supportedObject {get; set;}
    
    //Selected Object
    public String SelectedObject {get; set;}
    
    //Global describe
    Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
    Set<String> objectKeys = gd.keySet();
    
    //Field Select List
    public List<SelectOption> fieldLableAPI {get; set;}
    
    //Selected fields to be displayed in table
    public List<String> SelectedFields {get; set;}
    
    //List to maintain dynamic query result
    public List<sObject> ObjectList {get; set;}
    
    
    //Constructor
    public DynamicTableController()
    {
        //Initialize
        supportedObject = new List<selectoption>() ;
        SelectedObject = '' ;
        fieldLableAPI = new List<SelectOption>() ;
        SelectedFields = new List<String>() ;
        ObjectList = new List<sObject>() ;
        
        //Get only reference to objects
        for(Schema.SObjectType item : ProcessInstance.TargetObjectId.getDescribe().getReferenceTo())
        {
            //Excluding custom setting objects
            if(!item.getDescribe().CustomSetting)
            {
                //Adding to list
                supportedObject.add(new SelectOption(item.getDescribe().getLocalName().toLowerCase() , item.getDescribe().getLabel() ));
            }
        }
        
    }
    
    //Get fields of selected object
    public void ObjectFields()
    {
        if(SelectedObject != '--None--')
        {
            //Creating sObject for dynamic selected object
            Schema.SObjectType systemObjectType = gd.get(SelectedObject);
            //Fetching field results
            Schema.DescribeSObjectResult r = systemObjectType.getDescribe();
                
            Map<String, Schema.SObjectField> M = r.fields.getMap();
            //Creating picklist of fields
            for(Schema.SObjectField fieldAPI : M.values())
            {
                fieldLableAPI.add(new SelectOption(fieldAPI.getDescribe().getName() , fieldAPI.getDescribe().getLabel())) ;
            }
        }
    }
    
    public void ShowTable()
    {
        //Creating dynamic query with selected field
        String myQuery = 'Select Id ' ;
        
        for(String field : SelectedFields)
        {
            if(field.toLowerCase() != 'id' && field.toLowerCase() != '--none--')
            myQuery += ','+ field + ' ' ;
        }
        
        //Limit is 100 for now you can change it according to need
        myQuery += ' from ' + SelectedObject + ' LIMIT 100' ;
        
        //Executing the query and fetching results
        ObjectList = Database.query(myQuery) ;
    }
}

I have tried to move into lightning functions are not working fine  stuck with script
 
<apex:page controller="DynamicTableController" showHeader="false" sidebar="false" lightningStylesheets="true">
    <body>
        <apex:form >
        <div class="slds-form-element" style="text-align;" id="myBtn">
            <apex:commandButton styleClass="slds-button slds-button_neutral" value="Back"/>
        </div>
        <div class="container">
            <div class="panel panel-default">
                <div class="panel-heading">Choose an Object</div>
                <div class="panel-body">
                    <div class="row">
                        <div class="form-group">
                            <div class="col-sm-6">
                                <select class="form-control" id="meal">
                              <option value="" selected="true">--Select--</option>
                           </select>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
        </div>
        <!-- Second Section -->
        <div class="container">
            <div class="panel panel-default" id="panel_2">
                <div class="panel-heading">
                    Choose Set of Fields (hold shift to select more than one):
                </div>
                <div class="panel-body">
                    <div id="pickList_2">
                    </div>
                </div>
            </div>
        </div>
        
        <!-- Third Section -->
        <div class="container">
            <div class="panel panel-default" id="panel">
                <div class="panel-heading">
                    Choose Unique Identifier1 (hold shift to select more than one):
                </div>
                <div class="panel-body">
                    <div id="pickList">
                    </div>
                </div>
            </div>
        </div>        
        </apex:form>
    </body>
    </html>
</apex:page>

 
Hi All,
I have written a apex class to send email. I am new to test classes. I want to write test class for this. Please suggest how to cover my apex class.
This is my code.
public class UtilityCont{
    
    public static List<cotacts1__c> PSEContacts = new List<cotacts1__c>();
  
    public static void EmailtoSRRTTeam(Instal_Prod__c IP) {
        try{
            
            User usr = [select Id, username from User where Id = :UserInfo.getUserId()];
            Account acc = [Select ShippingCountry from Account where id =: IP.Company__c];
            PSEContacts = [Select Id,Email__c from cotacts1__c where Countries_in_Cluster__c =: acc.ShippingCountry];
            
            EmailTemplate templateId = [Select id from EmailTemplate where name = :System.Label.SRRTEmailTemp];
            
            if(usr!=null) {
                
                Messaging.Singleemailmessage mail = new Messaging.Singleemailmessage();
                
                list<String> toEmailIDs = new list<String>();
                Integer i=0;
                for (cotacts1__c singleCCEmail: PSEContacts) {
                    toEmailIDs.add(singleCCEmail.Email__c);
                    
                    mail.setTargetObjectId(userinfo.getUserId());
                    
                    mail.setToAddresses(toEmailIDs);
                    mail.setTreatTargetObjectAsRecipient(false);
                    mail.setTemplateID(templateId.Id); 
                    mail.setWhatId(IP.Id);
                    mail.setSaveAsActivity(false);
                    
                }
                Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
                
            }
        } catch(Exception ex) {

        }
    }
    public static String getUserContactNumber(){
        
        ContactNumber__mdt record;
        try {
          
            String userLocale = UserInfo.getLocale();
            String countryCode=  userLocale.substring(3,5);
            record= [SELECT MasterLabel,DeveloperName,ContactNumber__c FROM ContactNumber__mdt where DeveloperName=:countryCode]; 
        } catch(Exception ex) {
         
        }
        return record.ContactNumber__c;
    }
    
}

Thanks in Advance
Please help me​
Hi,

I have two DateTime fields ApprovedAt, SubmittedAt.

What I am trying to do is I would like to calculate turn around time by using this -> (ApprovedAt - SubmittedAt)

How we can do that in APex trigger? And what should be the type of field TurnAroundTime

I appreciated your help.
When a case is created from email to case i want to find the from which routing address was the case created. Is it possible to do that. If yes please do let me know how to do that.
Hi all
Scenario : while sending Member ID/ Caller ID, need to fetch details like contact channel, contact subscriber......details from Custom object (custom obj : for example ABD)
Could you please proivide sample code for above requiremnet and what API details i need to provide to third party application ?

Thanks
Sekhar
  • April 09, 2018
  • Like
  • 0
HI All I have created a Page for custom prodcut display with images .but here i am struggling for record is not showing .Like below.Can any body corect me.

User-added image
 
public class ProductSearchController {

  // the soql without the order and limit
    private String soql {get;set;}
    public Boolean showPageBlock{get;set;}
    // the collection of products to display
    public List<Product__c> products {get;set;}
    Integer counter = 0;//TO track the number of records parsed
    Integer limitSize = 20;//Number of records to be displayed
    Integer totalSize =0; //To Store the total number of records available
    public List<Product__c> ProductsToShow{get;set;}
    // the current sort direction. defaults to asc
    public String sortDir {
        get  
        { 
            if (sortDir == null) 
            {  
                sortDir = 'asc'; 
            } 
            return sortDir;  
        }
        set;
    }

  // the current field to sort by. defaults to last name
    public String sortField {
        get  
        { 
            if (sortField == null) 
            {
                sortField = 'Name'; 
            } 
            return sortField;  
        }
        set;
    }

  // format the soql for display on the visualforce page
    public String debugSoql {
        get 
        { 
            return soql + ' order by ' + sortField + ' ' + sortDir; 
        }
        set;
    }

    // init the controller and display some sample data when the page loads
    public ProductSearchController() {
        showPageBlock = true;
       
        productsToShow = new list<Product__c>();
        soql = 'select Name,Product_Type__c,Tag_Price__c,Photo__c,Image__C,Stock__c,ImageUrl__c,PictureUpload__c,Metal__c,Collection_Name__c,Stone_Shape__c,Centre_Stone_Weight__c,Clarity__c,Certificate_Type__c,Stone_Type_From_Stone_Detail__c,Stone_Shape_From_Stone_Detail__c,Color_Center_From_From_Stone_Details__c,Color_Center_To_From_Stone_Details__c,Certificate_Type_From_Stone_Details__c,Clarity_Center_From_From_Stone_Details__c,Clarity_Center_To_From_Stone_Details__c,Stone_Weight_From_Stone_Details__c,Semi_Precious_From_Stone_Details__c,Stone_Other_From_Stone_Details__c,Center_Other_From_Stone_Details__c from Product__c Where Name != null';
        
        
        runQuery();
    }

    // toggles the sorting of query from asc<-->desc
    public void toggleSort() {
        // simply toggle the direction
        sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
        // run the query again
        runQuery();
    }

    // runs the actual query
    public void runQuery() {
   
   
    productsToShow = new list<Product__c>();
    
        
      }
        
     
    

    // runs the search with parameters passed via Javascript
    public PageReference runSearch() {
        String Name= Apexpages.currentPage().getParameters().get('Name'); 
        String productType = Apexpages.currentPage().getParameters().get('productType'); 
        String imageUrl = Apexpages.currentPage().getParameters().get('imageUrl');  
        String metal = Apexpages.currentPage().getParameters().get('metal');
        String collectionName = Apexpages.currentPage().getParameters().get('collectionName');
        String stoneType = Apexpages.currentPage().getParameters().get('stoneType');
        String semiPrecious = Apexpages.currentPage().getParameters().get('semiPrecious');
        String stoneOther = Apexpages.currentPage().getParameters().get('stoneOther');
        String centerOther = Apexpages.currentPage().getParameters().get('centerOther');
        String stoneShape = Apexpages.currentPage().getParameters().get('stoneShape');
        String stoneWeight = Apexpages.currentPage().getParameters().get('stoneWeight');
        String centerFromColor = Apexpages.currentPage().getParameters().get('centerFromColor');
        //String centerToColor = Apexpages.currentPage().getParameters().get('centerToColor');
        String clarityCenterFrom = Apexpages.currentPage().getParameters().get('clarityCenterFrom');
        //String clarityCenterTo = Apexpages.currentPage().getParameters().get('clarityCenterTo');
        String certificateType = Apexpages.currentPage().getParameters().get('certificateType');
        String fromTagPrice = Apexpages.currentPage().getParameters().get('fromTagPrice');
        String toTagPrice = Apexpages.currentPage().getParameters().get('toTagPrice');
       
        
        soql = 'select Name,Product_Type__c,Tag_Price__c,Photo__c,Image__C,ImageUrl__c,Stock__c,PictureUpload__c,Metal__c,Collection_Name__c,Centre_Stone_Weight__c,Clarity__c,Certificate_Type__c,Stone_Type_From_Stone_Detail__c,Stone_Shape_From_Stone_Detail__c,Color_Center_From_From_Stone_Details__c,Color_Center_To_From_Stone_Details__c,Certificate_Type_From_Stone_Details__c,Clarity_Center_From_From_Stone_Details__c,Clarity_Center_To_From_Stone_Details__c,Stone_Weight_From_Stone_Details__c,Semi_Precious_From_Stone_Details__c,Stone_Other_From_Stone_Details__c,Center_Other_From_Stone_Details__c from Product__c Where Name != null';
       
        if (!productType.equals(''))
            soql += ' and Product_Type__c LIKE \''+String.escapeSingleQuotes(productType)+'%\'';
      
        if (!imageUrl.equals(''))
            soql += ' and ImageUrl__c LIKE \''+String.escapeSingleQuotes(imageUrl)+'%\''; 
        
        if (!metal.equals(''))
            soql += ' and Metal__c LIKE \''+String.escapeSingleQuotes(metal)+'%\'';
        
        if (!collectionName.equals(''))
            soql += ' and Collection_Name__c LIKE \''+String.escapeSingleQuotes(collectionName)+'%\''; 
        
        if (!stoneWeight.equals(''))
            soql += ' and Stone_Weight_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(stoneWeight)+'\')';
        
        if (!centerFromColor.equals(''))
            soql += ' and Color_Center_From_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(centerFromColor)+'\')';  
        /*
        if (!centerToColor.equals(''))
            soql += ' and Color_Center_To_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(centerToColor)+'\')';
        */
        if (!clarityCenterFrom.equals(''))
            soql += ' and Clarity_Center_From_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(clarityCenterFrom)+'\')';
        /*       
        if (!clarityCenterTo.equals(''))
            soql += ' and Clarity_Center_To_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(clarityCenterTo)+'\')';
        */
        if (!certificateType.equals(''))
            soql += ' and Certificate_Type_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(certificateType)+'\')';
        
        if (!fromTagPrice.equals(''))
            soql += ' and Tag_Price__c >= '+String.escapeSingleQuotes(fromTagPrice)+'';
            
        if (!toTagPrice.equals(''))
            soql += ' and Tag_Price__c <= '+String.escapeSingleQuotes(toTagPrice)+'';
        
        if (!stoneType.equals(''))
            soql += ' and Stone_Type_From_Stone_Detail__c INCLUDES (\''+String.escapeSingleQuotes(stoneType)+'\')';  
            
        if (!semiPrecious.equals(''))
            soql += ' and Semi_Precious_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(semiPrecious)+'\')';
        
        if (!stoneOther.equals(''))
            soql += ' and Stone_Other_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(stoneOther)+'\')';
            
        if (!centerOther.equals(''))
            soql += ' and Center_Other_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(centerOther)+'\')';  
        
        
        if (!stoneShape.equals(''))
            soql += ' and Stone_Shape_From_Stone_Detail__c INCLUDES (\''+String.escapeSingleQuotes(stoneShape)+'\')';
            
        // run the query again
        runQuery();

        return null;
      }
      
    public List<String> listProductTypes{
    get {
       
            listProductTypes = new List<String>();
            Schema.DescribeFieldResult field = Product__c.Product_Type__c.getDescribe();
            
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listProductTypes.add(f.getLabel());
         
         return listProductTypes;          
         }
    set;
    }
    
    public List<String> listMetal{
    get {
        if (listMetal == null) {
            listMetal = new List<String>();
            Schema.DescribeFieldResult field = Product__c.Metal__c.getDescribe();

            for (Schema.PicklistEntry f : field.getPicklistValues())
                listMetal.add(f.getLabel());
            
        }
        return listMetal;          
    }
    set;
    }
    
    public List<String> listCollectionTypes{
    get {
        if (listCollectionTypes == null) {
            listCollectionTypes = new List<String>();
            Schema.DescribeFieldResult field = Product__c.Collection_Name__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
              listCollectionTypes.add(f.getLabel());
        }
        return listCollectionTypes;          
    }
    set;
    }
    
    public List<String> listStoneTypes{
    get {
        if (listStoneTypes == null) {
            listStoneTypes = new List<String>();
            Schema.DescribeFieldResult field = Stone_Details__c.Stone_Type__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listStoneTypes.add(f.getLabel());
    
        }
      return listStoneTypes;          
    }
    set;
    }
    
    
    /*
    public List<String> listSemiPrecious{
    get {
        if (listSemiPrecious == null) {
            listSemiPrecious = new List<String>();
            Schema.DescribeFieldResult field = Stone_Details__c.Semi_Precious__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listSemiPrecious.add(f.getLabel());
    
        }
      return listSemiPrecious;          
    }
    set;
    }
    */
    
    public List<String> listStoneShapes{
    get {
        if (listStoneShapes == null) {
            listStoneShapes = new List<String>();
            Schema.DescribeFieldResult field = Stone_Details__c.Stone_Shape_Center__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listStoneShapes.add(f.getLabel());
    
        }
        return listStoneShapes;          
    }
    set;
    }
    /*
    public List<String> listColors{
    get {
        if (listColors == null) {
            listColors = new List<String>();
            Schema.DescribeFieldResult field = Product__c.Color__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listColors.add(f.getLabel());
    
        }
        return listColors;          
    }
    set;
    }
    */
    
    public List<String> listCenterFromColors{
    get {
        if (listCenterFromColors == null) {
            listCenterFromColors = new List<String>();
            Schema.DescribeFieldResult field = Stone_Details__c.Color_Centre_From__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listCenterFromColors.add(f.getLabel());
    
        }
        return listCenterFromColors;          
    }
    set;
    }
    /*
    public List<String> listCenterToColors{
    get {
        if (listCenterToColors == null) {
            listCenterToColors = new List<String>();
            Schema.DescribeFieldResult field = Stone_Details__c.Color_Centre_To__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listCenterToColors.add(f.getLabel());
    
        }
        return listCenterToColors;          
    }
    set;
    }
    */
    /*
    public List<String> listClarities{
    get {
        if (listClarities == null) {
            listClarities = new List<String>();
            Schema.DescribeFieldResult field = Product__c.Clarity__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listClarities.add(f.getLabel());
        }
        return listClarities;          
    }
    set;
    }
    */
    public List<String> listCenterFromClarity{
    get {
        if (listCenterFromClarity == null) {
            listCenterFromClarity = new List<String>();
            Schema.DescribeFieldResult field = Stone_Details__c.Clarity_Center_From__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listCenterFromClarity.add(f.getLabel());
        }
        return listCenterFromClarity;          
    }
    set;
    }
    /*
    public List<String> listCenterToClarity{
    get {
        if (listCenterToClarity == null) {
            listCenterToClarity = new List<String>();
            Schema.DescribeFieldResult field = Stone_Details__c.Clarity_Center_To__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listCenterToClarity.add(f.getLabel());
        }
        return listCenterToClarity;          
    }
    set;
    }
    */
    public List<String> listCertificateTypes{
    get {
        if (listCertificateTypes == null) {
            listCertificateTypes = new List<String>();
            Schema.DescribeFieldResult field = Stone_Details__c.Certificate_Type__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listCertificateTypes.add(f.getLabel());
        }
        return listCertificateTypes;          
    }
    set;
    }
    
    public void beginning(){
   
        productsToShow.clear();
        counter=0;
        if((counter + limitSize) <= totalSize){
       
            for(Integer i=0;i<limitSize;i++){
                productsToShow.add(products.get(i));
            }   
           
        } else{
       
            for(Integer i=0;i<totalSize;i++){
                productsToShow.add(products.get(i));
            }       
           
        }
    }
    
    public void next(){
   
        productsToShow.clear();
        counter=counter+limitSize;
       
        if((counter+limitSize) <= totalSize){
            for(Integer i=counter;i<(counter+limitSize);i++){
                productsToShow.add(products.get(i));
            }
        } else{
            for(Integer i=counter;i<totalSize;i++){
                productsToShow.add(products.get(i));
            }
        }
    }
   
    public void previous(){
    
        productsToShow.clear();
    
        counter=counter-limitSize;       
       
        for(Integer i=counter;i<(counter+limitSize); i++){
            productsToShow.add(products.get(i));
        }
    }
    
    public void last (){
   
        productsToShow.clear();
       
        if(math.mod(totalSize , limitSize) == 0){
            counter = limitSize * ((totalSize/limitSize)-1);
        } else if (math.mod(totalSize , limitSize) != 0){
            counter = limitSize * ((totalSize/limitSize));
        }
       
        for(Integer i=counter-1;i<totalSize-1;i++){
                productsToShow.add(products.get(i));
        }
       
    }
    
    public Boolean getDisableNext(){
   
        if((counter + limitSize) >= totalSize )
            return true ;
        else
            return false ;
    }
    
    public Boolean getDisablePrevious(){
   
        if(counter == 0)
            return true ;
        else
            return false ;
    } 
}
HI I need help in improving the code coverage for the below class.
public  class GSDAccountteammembercontroller {


public list<HPE_Account_Team__c> listofrecords{get;set;}
public Boolean TabToBeClosed {get;set;}
    
public PageReference SaveRecords() 
{
    string parentrecordid = ApexPages.currentPage().getParameters().get('Account__c');
    list<HPE_Account_Team__c> insertlist = new list<HPE_Account_Team__c>();  
    for(HPE_Account_Team__c acctem :listofrecords)
    {
        system.debug('acctem.Name__c'+acctem.Name__c);
        system.debug('parentrecordid'+parentrecordid);
        system.debug('listofrecords'+listofrecords);
        if(acctem.Name__c!=null)
        {
          if(parentrecordid != null && parentrecordid != '')
          acctem.Account__c = parentrecordid ;
          insertlist.add(acctem);
        
        }              
       
    }
        try{
        insert insertlist;
        }
        catch(Exception ex){
         ApexPages.addMessages(ex);
         return null;
        }       
        if(listofrecords!=null){
        listofrecords.clear();
        }
        TabToBeClosed = true;
        return null;

}

public GSDAccountteammembercontroller(ApexPages.StandardController controller){
 HPE_Account_Team__c HPEAccountTeam=(HPE_Account_Team__c)controller.getrecord();
 system.debug('HPEAccountTeam'+HPEAccountTeam);
TabToBeClosed = false;

listofrecords = new list<HPE_Account_Team__c>();
    
    for(Integer i=0; i<5; i++){   
         HPE_Account_Team__c gsdaccteam = new HPE_Account_Team__c();
         gsdaccteam.Account__c=HPEAccountTeam.Account__c;        
         gsdaccteam.Name__c=null;
         gsdaccteam.Role_Scope_Description__c='';
         gsdaccteam.Role__c='';
                 
         listofrecords.add(gsdaccteam);
    
         }
     
} 
  
}

My test class is as below.I am not able to cover the code few lines of the main class, thos lines area as below, find the attachement of screenshot.Screen shot taken from developer console.

 if(acctem.Name__c!=null)
        {
          if(parentrecordid != null && parentrecordid != '')
          acctem.Account__c = parentrecordid ;
          insertlist.add(acctem);
        
        }   
@isTest
public class GSDAccountteammembercontrollerTest{
    private static testMethod void SaveRecordTest(){
        account acc = new account();
        acc.name='test';
        insert acc;
        
        contact con = new contact();
            con.email = 'test@yahoo.com';
            con.Phone__c = '5423515415';
            con.LastName ='last Name';  
        insert con;
        system.debug('con'+con);
        
        HPE_Account_Team__c hpeAccountTeam = new HPE_Account_Team__c();
            hpeAccountTeam.Account__c = acc.id;
            hpeAccountTeam.Name__c = con.id;
            hpeAccountTeam.Role__c = 'Other';
            hpeAccountTeam.Role_Scope__c = 'Global';
            hpeAccountTeam.Role_Scope_Description__c = 'testing';
            hpeAccountTeam.Unique_Key__c = 'dfaafs';
            
            insert hpeAccountTeam;
    
  
        user u = [select id from user where id=:userInfo.getUserId()];
        
        System.runAs(u){
            ApexPages.StandardController con1 = new ApexPages.StandardController(hpeAccountTeam);
            GSDAccountteammembercontroller  teamMemberController = new GSDAccountteammembercontroller(con1);
            teamMemberController.SaveRecords();   
                

        }              
    }
}
Hi there,

I have a list of companies from a database on our website which are also in our salesforce (2400 of them).  I need to get their company ideas from salesforce using the export function on dataloader.io.  I obviously don't want to go through on the export screen and select every single one of the 2,400 companies using the filter as this will take forever (please see the screen shot below for a visual).  I'm wondering if there is a quick way I can get dataloader to recognise the 2,400 I want the ids for (I have a CSV file with all the companies from our website).  I hope this makes sense

User-added image

Thanks in advance,

Callum
If either Statement 1 or Statement 2 is true then red, else green

Statement 1
IF( 
AND( 
Owner.LastName <> "Partners", RecordType.DeveloperName = "Phase 4" ),

OR

Statement 2
IF( 
AND( 
NOT(ISBLANK(Under_Current_Contract_Until__c)), Under_Current_Contract_Until__c>=TODAY(), 
Owner.LastName <> "Partners" ),

IMAGE("/img/samples/color_red.gif", "red", 30, 30),
IMAGE("/img/samples/color_green.gif", "green", 30, 30)
Hello everyone,

The SalesForce REST API doc is unclear about the usage of APIs to insert and update records in OpportunityLineItem. The standard fields in OLI include OpportunityId and Product2Id both of which I'm populating by retrieving the appropriate SalesForce IDs. I receive this error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY when I try to insert a record at this URI: /sobjects/OpportunityLineItem/.

Going through the flow: https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_erd_products.htm#topic-title, I'm assuming this (and also the cross-reference error) means that there is no direct relationship between OLI and Products.

Firstly, why is there a Product2Id field if the relationship doesn't exist?
Secondly, is the URI I'm using incorrect? If so, what is the correct one?
Thirdly, can this problem be solved using APIs at all?

Maybe I'm going about this in a completely inefficient manner. Any suggestions would be greatly appreciated.
scheduled class that is sending birthday wishes email to lead records that email is sent using template the template has subject "Happy Birthday" the problem is that emails go 2 times a day  6am and once in evening we need to stop 6am delivery
Hi Guys please help me!

I have a custom picklist field in PRODUCT OBJECT. Which I want to show in my OPPORTUNITY PRODUCT OBJECT.

I tried cross object formula - TEXT(field.name) but its not working nor the workflow rule.

I dont want to use any code or trigger plz help me through formula. Please help me guys i really need help!!
Hi,
When I am try solving this challenge for Opportunity Checkbox , I get this error.
The validation rule is right no error. I also followed  the answers provided in the solution. Everything seems to be good.Pls lmk 
what debugging can be done.

There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, t2: execution of BeforeInsert caused by: System.NullPointerException: Argument cannot be null. Class.trigger_class.check_opp: line 13, column 1 Trigger.t2: line 2, column 1: []
Hi Experts,

When we use bulk query to extract the records from tables below is the process. (assuming PK chunking is not enable)
1. create a job
2. submit qury in batch
3. check the status of the batch
4. get the result list
5. iterate through result list to get the records from result

I am aware of the limitation mentioned here. like max file size (in one batch) could be of 1gig etc.

What I want to know when we retrieve the records from Result (individual result from result list, step #5 from above) what is the maximum # of records in one result?
 
Hi Guys.

Struggling to find a code that will work, i have an object called "Sales_Visits__c" and i would like to set some criteria to show all Sales_Visits in the past 30 days on a map. On the sales visit record is a geolocation.

I can add a map to the record layout however this will only show the single address not multiple on a criteria.

Any thoughts on how i would do this?

Nick

public class MedalliaIntegrationHelper {
    
    public class NPSInviteWrapper {
        //Transaction/Order Attributes
    public String Invite_Type  {set; get;}
    public String Invoice_Date  {set; get;}
    public String Invoice_No  {set; get;}
    public String Shopping_Amount  {set; get;}        
    public String Branch_Code  {set; get;}
    public String Tag  {set; get;}
    public String Customer_Idnt  {set; get;}        
        //Customer Attributes
    public String Amber_Idnt  {set; get;}
    public String Tiername  {set; get;}
    public String Title  {set; get;}
    public String First_Name  {set; get;}
    public String Last_Name  {set; get;}
    public String Mobilenumber  {set; get;}
    public String Sms_Market  {set; get;}
    public String Postbox  {set; get;}
    public String City  {set; get;}
    public String Country  {set; get;}
    public String Email_Address  {set; get;}
    public String Gender  {set; get;}
    public String Age_Group  {set; get;}
    public String Ethnic_Group  {set; get;}
    public String Birth_Date  {set; get;}
    public String Tenure  {set; get;}
        //Location Attributes
    public String Brand_Name  {set; get;}
    public String Branch_Name  {set; get;}
    public String Mall_Name  {set; get;}
    public String Store_City  {set; get;}        
    }
}
I have a controller variable of time datatype.
public Time startTime{get;set;}

startTime = Time.newInstance(12,0,0,0);
Rendering the variable as is on visualforce will output as 12:00:00.000Z

I want to display this on a visualforce page in a proper time format using the outputText parameter passing technique.
I tried 
 
<apex:outputText value="{0, time, h:mm a}">
     <apex:param value="{!slot.startTime}" /> 
</apex:outputText>
I'm getting a compile time error "The value attribute on <apex:outputText> is not in a valid format. It must be a positive number, and of type Number, Date, Time, or Choice.". Anybody knows the correct syntax to get this working.

I know we can convert this variable as a datetime variable and use that instead, but wondering why Time variable does not work.

 
Hi.

In the VF I used the date format as YYYY-MM-dd in the 
<apex:outputText value="{0,date,YYYY/MM/dd}">
Before the last week of the year it was OK. When the new year falls in the  last week of Decemeber comes the issue.
For example
2014:
S   M  T  W Th F Sat
28 29 30 31 1   2 3

In the above calendar 1st Jan of 2015 falls in the Thurusday.So when I viewd the records of 28,29,30 of December 2014 It showed as
2015-12-28
2015-12-29
2015-12-30
2015-12-31

After that I came to know that
@"YYYY" is week-based calendar year.
@"yyyy" is ordinary calendar year.
http://realmacsoftware.com/blog/working-with-date-and-time

cheers
suresh