• Abhishek M.
  • NEWBIE
  • 90 Points
  • Member since 2017

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 17
    Replies
Hi there,

I have a need to create a trigger that will create a row for a 'Time_Entry' object based on the addition of a row to a 'Requst' object. The 'Request' object has 'Time entries' assigned to it and it is perceived that there is time associated with creating a new request, so the requirement is that the system create a 'Time Entry' for a 'Request' when the new request is opened. I've tried to create a trigger for this based on what i learned from the Trailhead training, but I'm missing something.
 
trigger New_Req_Time_Entry on Request__c (after insert) {
    //Get the ID number for the request just created. 
        string RequestID = Request__c.Id; 
    //Build the default values to the new time entry record. 
        Time_Entry__c entry = new Time_Entry__c(Activity__c='<Select Activity>', Date_Worked__c=System.today(), Hours_Worked__c=' 0', Minutes_Worked__c='15', Related_Object__c=RequestID);
    //Insert the new default time entry row into the Salesforce database. 
        Insert entry;

}

I've tried 3 or 4 approaches, and I keep thinking that I'm over thinking it!

Any help would be greatly appreciated.

Thanks!

Eric Anderson
Hi,

I have a button which is a div element. The css for this button is that it is grey in color.

<div class="UpdateButton"> UPDATE </div> 
When text is inputted in the text box the color of the button should change to red.
<div class="textpanel"> <input type="text" size="35" /><br/></div>

Similrly ther eis a checkbox on visualforce componenet which is referenced on the visualforce page. If that checkbox is checked the button should change to red.
  • April 12, 2017
  • Like
  • 0
I am attempting to learn Apex and last week successfully deployed my first (and admittedly rudimentary) Apex trigger to production.  Everything was going great until I attempted to update some of my Contact records via DataLoader.  I received a System.LimitException: Apex CPU time limit exceeded error.  I was able to successfully break my .csv file into 200-part pieces and upload, but I know there must be a better way.  As I understand it, the loops in my trigger are the cause, but I'm not sure how to improve the code to solve this.  My code is below and suggestions are greatly appreciated!

trigger contactDupCheck2 on Contact (before insert, before update, before delete) {
    set<string> emailSet = new set<string>();
    List<contact> contactList = new list<contact>();
    
    for(contact c : trigger.new){
        if(c.email!=null || c.email!=''){
            emailSet.add(c.email);
            contactList.add(c);
        }
    }
    List<Contact> listExistingContact = [select Id, email, LastName from Contact where email in: emailSet and id not in : trigger.new];
    for(contact currCon: contactList ){
    currcon.duplicate_email__c=false;
        for(contact exiscon : listExistingContact ){
            if(currcon.email==exiscon.email){
                currcon.duplicate_email__c=true;
            } else {
            currcon.duplicate_email__c=false;
            }
            if(currcon.email==null || currcon.email==''){
            currcon.duplicate_email__c=false;
            }
           
        }
    }
}
Is it possible to filter a VF inline related list?

My vf page consists of:

<apex:page standardController="advpm__Matter__c" title="Matter: {!advpm__Matter__c.Name}" id="pg">
  <apex:relatedList list="Cash_Receipts__r"/>
</apex:page>

I would like to exclude records based on one of the displayed fields.

Thanks
Hi there,

I have a need to create a trigger that will create a row for a 'Time_Entry' object based on the addition of a row to a 'Requst' object. The 'Request' object has 'Time entries' assigned to it and it is perceived that there is time associated with creating a new request, so the requirement is that the system create a 'Time Entry' for a 'Request' when the new request is opened. I've tried to create a trigger for this based on what i learned from the Trailhead training, but I'm missing something.
 
trigger New_Req_Time_Entry on Request__c (after insert) {
    //Get the ID number for the request just created. 
        string RequestID = Request__c.Id; 
    //Build the default values to the new time entry record. 
        Time_Entry__c entry = new Time_Entry__c(Activity__c='<Select Activity>', Date_Worked__c=System.today(), Hours_Worked__c=' 0', Minutes_Worked__c='15', Related_Object__c=RequestID);
    //Insert the new default time entry row into the Salesforce database. 
        Insert entry;

}

I've tried 3 or 4 approaches, and I keep thinking that I'm over thinking it!

Any help would be greatly appreciated.

Thanks!

Eric Anderson
Hello Everyone,

I need to create a validation rule to not allow the Close Date be changed : ISCHANGED( CloseDate )
if it is from a previous fiscal year (2016 and earlier) and the stage is in Closed-Won: ISPICKVAL(StageName, 'Closed – Won')

UNLESS it is done by either Profile IDs:
     $User.ProfileId = "00ew0000001R9Bh",
        $User.ProfileId = "00ew0000001R98E"

Any assistance would be appreciated!

Thank you,
Julia
We use SF as our system of record, recording all donors to the organization. We also have a website for the organization.What we'd like to be able to do is the following:
  1. A person signs in on our website
  2. The website in turn, via whatever APIs, connects with our SalesForce instance, sending username + password over
  3. The person's username or other credentials is checked against the person's donor/Contact record in SalesForce
  4. Some kind of code is sent back to our website, to allow the donor to, for example, get preferential pricing or gain some other benefit by virtue of being a donor.
Is the above scenario implementable in some fashion? How would you suggest we go about doing so? And if not, what alternatives would you suggest?
Thank you very much!
Hi,

I have a button which is a div element. The css for this button is that it is grey in color.

<div class="UpdateButton"> UPDATE </div> 
When text is inputted in the text box the color of the button should change to red.
<div class="textpanel"> <input type="text" size="35" /><br/></div>

Similrly ther eis a checkbox on visualforce componenet which is referenced on the visualforce page. If that checkbox is checked the button should change to red.
  • April 12, 2017
  • Like
  • 0
It has been requested of me that I create a 'Related list' that can be shared to multiple objects that can be used for our time entry. Much like 'Files', 'Groups', 'Notes'  and 'Open Activities' show up in all 'Standard' and 'Custom' objects, my management wants me to create a 'Related list' format that will show up as being available for 'Planting' in any of the objects that we desire such as 'Accounts', 'Contacts' and so on as well as any 'Custom objects' that we may define.

Please let me know how I can do this.

Thanks! - Eric-
Hi all,

by using inbound email handler and email services where do inbound/incoming emails go in Salesforce, for example for Cases? do they go the related list Emails?
I am attempting to learn Apex and last week successfully deployed my first (and admittedly rudimentary) Apex trigger to production.  Everything was going great until I attempted to update some of my Contact records via DataLoader.  I received a System.LimitException: Apex CPU time limit exceeded error.  I was able to successfully break my .csv file into 200-part pieces and upload, but I know there must be a better way.  As I understand it, the loops in my trigger are the cause, but I'm not sure how to improve the code to solve this.  My code is below and suggestions are greatly appreciated!

trigger contactDupCheck2 on Contact (before insert, before update, before delete) {
    set<string> emailSet = new set<string>();
    List<contact> contactList = new list<contact>();
    
    for(contact c : trigger.new){
        if(c.email!=null || c.email!=''){
            emailSet.add(c.email);
            contactList.add(c);
        }
    }
    List<Contact> listExistingContact = [select Id, email, LastName from Contact where email in: emailSet and id not in : trigger.new];
    for(contact currCon: contactList ){
    currcon.duplicate_email__c=false;
        for(contact exiscon : listExistingContact ){
            if(currcon.email==exiscon.email){
                currcon.duplicate_email__c=true;
            } else {
            currcon.duplicate_email__c=false;
            }
            if(currcon.email==null || currcon.email==''){
            currcon.duplicate_email__c=false;
            }
           
        }
    }
}
Hello Developers!

I have a situation here in which trigger is not firing.
Master object: Volunteer_Project__c and Detail object: Participation__c
I want to count number of unique email addresses (Total_Associated_Volunteers__c) of Participation__c on Volunteer_Project__c.

Approach: Whenever there is a record entry in child for one particular master, I am compering that newly inserting record's email address to all of the child records of that master. If similar email found then Unique_Roll_Up__c on that detail record is 0 otherwise 1. At the end, I am putting rollup summary on Unique_Roll_Up__c at the Master object.

Trigger:
 
Trigger UniqueRollUp On Participation__c(Before Insert, Before Update){

    List<Participation__c> Partici = New List<Participation__c>();
    Set<String> UniqueEmailSet = New Set<String>();
    Set<ID> ProjIds = New Set<ID>();
    
    If(Trigger.IsInsert || Trigger.IsUpdate)
    {
        For(Participation__c P: Trigger.New)
        {    
            ProjIds.add(P.Volunteer_Project_Name__c);    
        }
    }
    
    Partici = [Select Volunteer_Email__c FROM Participation__c WHERE Volunteer_Project_Name__c = :ProjIds];
    
    For(Participation__c Pa: Trigger.New){
        If(Pa.Volunteer_Email__c != null){
            
            for(Integer I = 0; I<Partici.size(); I++){
                if(Pa.Volunteer_Email__c == Partici[0].Volunteer_Email__c){
                    Pa.Unique_Roll_Up__c = 0;
                }
            }
        }
        else{
            Pa.Unique_Roll_Up__c = 1;
        }
    }
}

Thank You!
HI Everyone 

Good Afternoon,

Please help me this query syntax
Actullay my secenario is null values not show to contact lastname

select id, lastname, account.id, account.lastname from contact where lastname!=null
Hi Everyone!

I would greatly appreciate some help with the following problem. I've included a screenshot as a reference as well as my code below: User-added image

<messaging:emailTemplate recipientType="Contact"
    relatedToType="Account"
    subject="Case report for Account: {!relatedTo.name}"
    replyTo="weglinj@unlv.nevada.edu">

    <messaging:htmlEmailBody >
        <html>
            <body>

            <h1 style="color: #5e9ca0;">VIP Vegas Quote:</h1>
<h2 style="color: #2e6c80;"><strong>{!Viper__c.First_Name__c} {!Viper__c.Last_Name__c}'s VEGAS TRIP</strong>:</h2>
<p>Date: {!Reservations__c.Reservation_Date__c}<br />Venue: {!Reservations__c.Venue_1__c}<br />DJ / Performance: (Insert DJ/Performance)</p>
<li>Free 24/7 Concierge Service (i.e. dinner reservations, show tickets, Vegas attractions, and gentlemen's clubs/ male reviews)</li> 
<li>VIP Personal Hosted Entry for {!Reservations__c.Guys__c} gentlemen, and {!Reservations__c.Girls__c} ladies into {!Reservations__c.Venue_1__c}. No lines... No wait...(11:30pm Arrival)</li>
<li>{!Reservations__c.Minimum1__c} USD Alcohol and Beverage Credit (includes all standard mixers)</li>
<li>VIP Table- {!Reservations__c.Req_Table__c}-{!Reservations__c.Req_Section__c}</li>
<li>Price Includes All: State Taxes, Entertainment Taxes, Service Fees and Gratuities</li>
</ul>
<p>Package Total: {!Reservations__c.Package_Total__c} USD / {!Reservations__c.Price_Per_Person__c} based on {!Reservations__c.Group_Size__c} patrons</p>

            </body>
        </html>
    </messaging:htmlEmailBody>
</messaging:emailTemplate>
I am trying to have a conditional rerender.  I am having trouble with the actionSupport reRender section.  It says I have a syntax error.  Note: I have tried double quotes and single quotes around the None and Person.

<apex:actionSupport event="onkeyup" reRender="{!IF(ISBLANK({!newContact.email})),'None','Person'}"/> 

 <apex:outputLabel id="Person" >        
            Blah Blah                                                            
          </apex:outputLabel>

<apex:outputLabel id="None" >        
            Blah Blah 2           
           </apex:outputLabel>
Hello Everyone,

Pretty simple question, I have this apex trigger ready to go; But I am unsure where to place it. It updates contacts and opportunity owners to match the account owner, So I am assuming I put it under the account triggers? 
Here is the code.

trigger reassignContactOwnerToAccountOwner on Contact ( before insert, before update ) {

    List<Id> accountIds = new List<Id>();
    Map<Id, Id> accountOwnerIdMap = new Map<Id, Id>();

    // all the accounts whose owner ids to look up
    for ( Contact c : Trigger.new ) {
        accountIds.add( c.accountId );
    }
    
    // look up each account owner id
    for ( Account acct : [ SELECT id, ownerId FROM account WHERE id IN :accountIds ] ) {
        accountOwnerIdMap.put( acct.id, acct.ownerId );
    }
    
    // change contact owner to its account owner
    for ( Contact c : Trigger.new ) {
        c.ownerId = accountOwnerIdMap.get( c.accountId );
    }
   
}

 
Hello SF community,

I've created a visualforce page that I would like to display as a homepage component.  I've also created two custom fields on the user object that I would like that to be able to update based on the current user.  I'm using the "User" standard controller, here is a bit of my code for the input fields.  Do I need a custom controller or am I missing something simple?  I'm fairly new to Visualforce, so I'm still learning.  Thank you for any assistance!

<apex:page standardController="User" doctype="html-5.0">
                <apex:inputField value="{!User.Time_off_start_date__c }"
                    label="" style="width:125px" showDatePicker="false" type="date">
                </apex:inputField>
                <apex:inputField value="{! User.Time_off_end_date__c }"
                    label="" style="width:125px" showDatePicker="false" type="date">
                </apex:inputField>
                <apex:commandButton action="{! save }" value="Submit"/>