• Krishna_225
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 4
    Replies
Hello Developers, 
I have a code which executes when a new contact is inserted or updated. But when i tried to insert bulk contacts through data loader, the system is throwing following error "ContatctoAccount: System.LimitException: Apex CPU time limit exceeded".
Below is my code
trigger ContatctoAccount on Contact (after insert, after update) {

    list<Contact> Cont = new list<Contact>();
  list<Account> Acc = [select id,Account_code__c from Account where Account_code__c != Null];
    for(Contact Cnt : trigger.new){        
        if(Acc.size()>0){
            for(Account a : Acc){
                for(Contact c: trigger.new){
                    if(c.Account_code__c == a.Account_code__c){
                     c.AccountID = a.id;
                        }
                    Cont.add(c);
                }
            }
        }
    }
}

Can anyone from here please help me solving this error.
Thank you in advance
Krish
I have a requirement where the child object i.e student__c should be displayed when parent object i.e class__c is searched via lookup. Below is my code.
public class AttendenceController {
    public Class__C selectedUser { get; set; }
    public student__c stu {get; set;}

    public class StudentWrapper {   
        public Student__c student {get; set;} 
        public Boolean absent {get; set;}

        public StudentWrapper() {
            this.absent = false;
        }

        public StudentWrapper(Student__c student) {
            this();
            this.student = student;
        }
    }

    public List<StudentWrapper> students {get; set;}

    Date day = Date.today();

    public AttendenceController() {
        students = new List<StudentWrapper>();

        for (Student__c student : [select Name, Class__c from Student__c WHERE Class__C!= Null]) {
            students.add(new StudentWrapper(student));
        }
    } 

    public PageReference submit() {
        List<Attendance_Tracker__c> attendance = new List<Attendance_Tracker__c>();

        for (StudentWrapper wrapper : this.students) {
            attendance.add(new Attendance_Tracker__c(
                Date__c = this.day,
                Student__c = wrapper.student.Id,
                Present_Today__c = wrapper.absent
            ));
        }

        if (!attendance.isEmpty()) {
            insert attendance;
        }

        return null;
    }

}

and visualforce page
<apex:page controller="AttendenceController">
<apex:form >
    <apex:pageBlock >
        <apex:pageBlockTable value="{!students}" var="wrapper">
            <apex:column value="{!wrapper.student.Name}" />
            <apex:column >
                <apex:facet name="header">Present Today</apex:facet>
                <apex:inputCheckbox value="{!wrapper.absent}" />
            </apex:column>
        </apex:pageBlockTable>
    </apex:pageBlock>
    <apex:commandButton action="{!submit}" value="Submit" onComplete="window.location.reload();"/>
</apex:form>

when a class is searched from lookup, the related students under the class should show in the page and should be saved after the submission. But as of now, I can only able to display all the students irrespective of class. Code is working fine but I need an extra option of adding the lookup


Any help would be highly helpful.
Thankyou in advance
Krish
I have a requirement where I need to store values in currency field as $2,00,000/$3,00,000. Basically, that field will be used to denote limits. I cannot do that using a currency field. WHen I tried to do that using text field, I am not recieving $ symbol(which is mandatory for both upper and lower limits) as the data is bulk uploaded using Data loader. Can anyone please help me with this requirement.
Thank you in advance.
Krish
Hello Admins/Developers,
I have a requirement where a checkbox is to be checked if a record is created by a specific profile this week. So, I got the following formula: IF(CreatedBy.Profile.Name = "Territory Sales Manager" && DateValue(CreatedDate) =  THIS_WEEK  , True, False).
In the above formula, THIS_WEEK is not working in formula field. I'm recieving " Error: Incorrect parameter type for operator '='. Expected Date, received Text" error. 
Can anyone help me out with this createdDate issue so that I can extract this week's record along with the profile name.

Reagrds,
Krishna
Hello Develpers,
I have a requirement where the Account's field should be updated by Order__C which is a child object.
I have a formula field on Order__C which is 
IF( (Account.First_Purchase_Date__c = Order_Date__c) && Account.First_Purchase_Year__c = '2018' , Order_CC__c , 0)
There is a field on Account Object which is updated by Order_CC__c by trigger
The problem here is, if we enter another order with same date and year as previous order, the new value is updating. I only need the first value to be populated in the Account's field from Order.
Please help me solving out this puzzle.

Thank you in advance
Krish
Hello Admins and Developers,
I need to build a formula or process builder on Order object where the Order date is less than all other orders.
I know how to compare between two date fields but I'm bit confused here as we need to compare same date field between multiple records.
Can anyone please help me in this issue?

Thank you in advance,
Krish
Hi Developers,
I have a requirement where the details of a custom object should populate based on the name searched(field of this object) using lookup.
When the name is searched using lookup, the details of that record should display below and should commit to the database on submission.
Can anyone please help me with this?

Thanks,
Krish
hello developers...
I'm a salesforce newbie. I have a requirement where I need to replace standard new button on lead object with a vf page. Below is my vf code...
<apex:page standardcontroller="Lead" tabstyle="Lead" extensions="ExtensionClass">
 
 <apex:form>
 
 <apex:sectionheader title="Lead Edit" subtitle="{!if(Lead.Id==null,'New Lead',Lead.Name)}"></apex:sectionheader>
 
 <apex:pageblock mode="edit" id="leadPB" title="Lead Edit">
 
 <apex:pageblockbuttons>
 <apex:commandbutton action="{!save}" value="Save"></apex:commandbutton>
 <apex:commandbutton action="{!cancel}" value="Cancel"></apex:commandbutton>
 </apex:pageblockbuttons>
 
 <apex:pagemessages></apex:pagemessages> <!-- displays all message generated by the component -->
 
 <apex:pageblocksection id="LeadInformationPBS" title="Lead Information">
 <apex:inputField value="{!Lead.OwnerId}"/> 
 <apex:inputfield value="{!Lead.Phone}"></apex:inputfield>

 <apex:pageblocksectionitem>
 <apex:outputlabel value="{!$ObjectType.Lead.Fields.FirstName.label}"></apex:outputlabel>
 <apex:outputpanel>
 <apex:inputfield value="{!Lead.Salutation}"></apex:inputfield>
 <apex:inputfield value="{!Lead.FirstName}"></apex:inputfield>
 </apex:outputpanel>
 </apex:pageblocksectionitem>
 <apex:inputfield value="{!Lead.MobilePhone}"></apex:inputfield>
 
 <apex:inputfield value="{!Lead.LastName}"></apex:inputfield>
 <apex:inputfield value="{!Lead.Fax}"></apex:inputfield>
 
 <apex:inputField value="{!Lead.Company}" />
 <apex:inputfield value="{!Lead.Email}" required="true"></apex:inputfield>
 
 <apex:inputfield value="{!Lead.Title}"></apex:inputfield>
 <apex:inputfield value="{!Lead.Website}"></apex:inputfield>
 
 <apex:inputfield value="{!Lead.Leadsource}"></apex:inputfield>
 <apex:inputfield value="{!Lead.Status}"></apex:inputfield>

 <apex:inputfield value="{!Lead.Rating}"></apex:inputfield>
 
 <apex:inputfield value="{!Lead.Industry}"></apex:inputfield>
 <apex:inputfield value="{!Lead.NumberOfEmployees}"></apex:inputfield>
     <apex:actionRegion >
         Target Sectors:  <apex:inputfield value="{!Lead.Target_Sectors__c}">
                                      <apex:actionSupport event="onchange" rerender="TargetSector,theMessage"/> 
                                      </apex:inputfield>
                                  </apex:actionRegion>
      <apex:outputPanel id="TargetSector">
                      <apex:pageBlockSection id="ProdFamily"  rendered="{!IF(Lead.Target_Sectors__c == 'Other', true, false)}"> 
                            <apex:inputfield value="{!Lead.Please_specify_the_Other_reason__c}"/>
                 </apex:pageBlockSection> 
    </apex:outputPanel> 
 </apex:pageblocksection>
 
 <apex:pageblocksection id="AddressInformationPBS" title="Address Information" columns="2">
 <apex:inputfield value="{!Lead.Street}"></apex:inputfield>
 <apex:outputtext value=""></apex:outputtext>
 
  <apex:inputfield value="{!Lead.Website}"></apex:inputfield>
 <apex:outputtext value=""></apex:outputtext>
 
 <apex:inputfield value="{!Lead.City}"></apex:inputfield>
 <apex:outputtext value=""></apex:outputtext>
 
 <apex:inputfield value="{!Lead.State}"></apex:inputfield>
 <apex:outputtext value=""></apex:outputtext>
 
 <apex:inputfield value="{!Lead.PostalCode}"></apex:inputfield>
 <apex:outputtext value=""></apex:outputtext>
 
 <apex:inputfield value="{!Lead.Country}"></apex:inputfield>
 <apex:outputtext value=""></apex:outputtext> 
 </apex:pageblocksection>
 
 <apex:pageblocksection id="AdditionalInformationPBS" title="Additional Information">
 <apex:inputfield value="{!Lead.ProductInterest__c}"></apex:inputfield>
 <apex:inputfield value="{!Lead.CurrentGenerators__c}"></apex:inputfield>
 
 <apex:inputfield value="{!Lead.SICCode__c}"></apex:inputfield>
 <apex:inputfield value="{!Lead.Primary__c}"></apex:inputfield>
 
 <apex:inputfield value="{!Lead.NumberofLocations__c}"></apex:inputfield>
 </apex:pageblocksection>
 
 <apex:pageblocksection id="DescriptionInformationPBS" title="DescriptionInformation">
 <apex:inputfield value="{!Lead.Description}"></apex:inputfield>
 </apex:pageblocksection>
 
 <apex:pageblocksection id="OptionPBS" title="Lead Information">
 <!-- If you want to have a checkbox to implement whether to use Active Assignment rules you will need to create your own using a custom Apex Extension and method -->
 </apex:pageblocksection>
 
 </apex:pageblock>
 
 </apex:form>
 
</apex:page>

In the above code, I need help for some functionalities.
 1) Can you please help me with Target sector field to get indented neatly with the page as it is showing as separate block in the page(please view this in your DE for clear understanding)
2) Can you please help me with save & new button along with custom extension
3) Can you please help me with displaying "Assign using active checkbox" in the vf page.
    
Thanks in advance
KK
Hi all,
I'm new to SF. I have a requirement where if a value from a region picklist(UK) is selected, it should unlock other picklist field with its sub-regions(UK). If other picklist value(Non uk) is selected, it should not populate. Can anyone help me with this requirement.

Thank you in advance
SK
I have a requirement where I need to store values in currency field as $2,00,000/$3,00,000. Basically, that field will be used to denote limits. I cannot do that using a currency field. WHen I tried to do that using text field, I am not recieving $ symbol(which is mandatory for both upper and lower limits) as the data is bulk uploaded using Data loader. Can anyone please help me with this requirement.
Thank you in advance.
Krish
Hi all,
I'm new to SF. I have a requirement where if a value from a region picklist(UK) is selected, it should unlock other picklist field with its sub-regions(UK). If other picklist value(Non uk) is selected, it should not populate. Can anyone help me with this requirement.

Thank you in advance
SK