• Tarun J.
  • SMARTIE
  • 600 Points
  • Member since 2011
  • Salesforce Certified Developer

  • Chatter
    Feed
  • 18
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 165
    Replies
Hi evryone. please find the below screenshot  and below code for  fields alignments and help me with the alignment.

User-added image

<apex:actionStatus onstart="blockPageLoading()" onstop="unblockPage()" id="blockUI"/>
        <apex:actionFunction name="recalPage" action="{!recalculatePage}"  rerender="procedureComponent,pagemessage"/>
        
        <apex:pageBlock mode="edit" tabStyle="event">
            <div style="margin-left: 300px;"><b><font color ="red"><apex:messages /></font></b></div>
            <br />
           
                <apex:pageBlockSection collapsible="false" columns="1" title="Details of calendar">  
                                
                <apex:inputfield value="{!eventDetails.Subject}"/> 
                <apex:inputfield value="{!eventDetails.Ownerid}"/>
                <apex:inputfield value="{!eventDetails.Internal_Organization__c}" onchange="recalPage();"/>
                <apex:inputfield value="{!eventDetails.Whatid}"/>
                <apex:inputfield value="{!eventDetails.Type__c}" onchange="recalPage();" />
                <apex:inputfield value="{!eventDetails.SubType__c}" onchange="recalPage();" />
                <apex:inputfield value="{!eventDetails.IsAllDayEvent}"/>                
                <apex:pageBlockSectionItem id="debut" >
                <apex:outputLabel value="Start Date Time" for="debut" />
                <apex:outputPanel >
                    <apex:inputText value="{!startDate}" id="dateField"  style="width:80px; height:20px;" required="true"/>
                    <apex:inputText value="{!startHour}" id="startDateHour" style="width:75px; height:20px;" />
                    [&nbsp;<a id="sethour" style="text-decoration: underline; cursor:pointer;" >{!CurrentstartHour}</a>&nbsp;]
                    </apex:outputPanel>                 
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem id="fin" >
                <apex:outputLabel value="End Date Time" for="fin"/>
                <apex:outputPanel >
                    <apex:inputText value="{!endDate}" id="enddate" style="width:80px; height:20px;" required="true"/>
                    <apex:inputText value="{!endHour}" id="endDateHour" style="width:75px; height:20px;" />
                    [&nbsp;<a id="setendHour" style="text-decoration: underline; cursor:pointer;" >{!CurrentstartHour}</a>&nbsp;]
                </apex:outputPanel> 
                </apex:pageBlockSectionItem>                
            </apex:pageBlockSection>
             
            
           <apex:pageblockSection columns="1" >
               <apex:repeat value="{!eventFieldSet}" var="field">    
                <!--<apex:datatable value="{!eventFieldSet}" var="field">-->
                    <apex:pageBlockSectionItem >
                                       
                    <apex:outputPanel rendered="{!field.Label = 'Type' || field.Label = 'Internal Organization' || field.label = 'Sub-Type'}">
                  
                           {!field.Label} &nbsp;&nbsp;
                            <apex:inputField value="{!eventDetails[field]}" onchange="recalPage();"/><br/>
                            
                   </apex:outputPanel>
                   
                   <apex:outputPanel rendered="{! !(field.Label = 'Type')}">
                           {!field.Label} &nbsp;&nbsp;
                           <apex:inputField value="{!eventDetails[field]}"/><br/>
                   </apex:outputPanel>
                   
                </apex:pageBlockSectionItem>
                </apex:repeat>
        <!--</apex:datatable>-->
        </apex:pageblocksection>
        
           </apex:pageblock>


regards,
Isha
I'm tasked with creating an Opportunity Amount field Trigger to Roll-Up from Opportunity Products. How would I go about creating this trigger to roll up from Opportunity Products? Sample code would be awesome!

Sincerely,
Junior Developer!
Hi,
I have a text field " Endos Count" which is a counter field. But the format of the count i need is, 001,002,003 etc. Now i am getting as 1,2 3. Can anyone suggest plz, how to get this type of format.
I just wrote the below formula, but its not working,
TEXT(VALUE(Endorsement_Count__c)+001)
Hello,

I have an issue with an Apex Test Class and I would really need your help. I have a Apex Trigger and an Apex Class and I have tried to create a test class but I can't get it over 70% code coverage.

The class is:
public with sharing class OpportunitySchedulingHandler {

     //Update LineItemSchedule dates for all scheduling dates

    public static void ScheduleDateUpdate(String oppid, Integer DayDiff) 
    {
       List<OpportunityLineItem> idval = [SELECT id FROM OpportunityLineItem WHERE OpportunityId=:oppid];
       List<OpportunityLineItemSchedule> datelist = new List<OpportunityLineItemSchedule>();
       for (Integer i = 0; i < idval.size(); i++)
       {
           datelist = [SELECT ScheduleDate FROM OpportunityLineItemSchedule WHERE OpportunityLineItemId =:idval[i].id];
           Date firstDate = datelist[0].ScheduleDate.addDays(DayDiff);
           datelist[0].ScheduleDate = firstDate;

           Integer day = firstDate.day();
           Integer month = firstDate.month();
           Integer year = firstDate.year();

           for (Integer k = 1; k < datelist.size(); k++)
           {
               Integer nYear = year;
               Integer nMonth = month + k;
               Integer nDay = day;

               if (nMonth > 12) {
                   nMonth = nMonth - 12;
                   nYear = nYear + 1;
               }

               Set<Integer> longMonths = new Set<Integer> {1,3,5,7,8,10,12};

               if (nDay == 31 && ! longMonths.contains(nMonth)) {
                   nDay = 30;
 }

               if (nDay > 28 && nMonth == 2) {
                   nDay = 28;
               }

               Date mydate = date.newInstance(nYear,nMonth,nDay);
               datelist[k].ScheduleDate = mydate;
           }
           if(!datelist.isEmpty())
           {
                update datelist;
           }
        }
    }    

      //Update ServiceDate with closeDate

    public static void ScheduleServiceDateUpdate(String oppid)
    {
        List<Opportunity> oliList = [SELECT Id, Name, CloseDate, (SELECT Id, ServiceDate, OpportunityId from OpportunityLineItems) from Opportunity where Id =:oppid];
        List<OpportunityLineItem> oliUpdateList = new List<OpportunityLineItem>();
        for(Opportunity x : oliList)
        {
            for(OpportunityLineItem oli : x.OpportunityLineItems)
            {
                oli.ServiceDate = x.CloseDate;
                oliUpdateList.add(oli);
            }
        }
        if(!oliUpdateList.isEmpty()) 
        {
            update oliUpdateList;
        }
    }
}

The trigger is:

trigger OpportunityReScheduling on Opportunity (after update, before update, after insert) 
    {
        for (Opportunity o: Trigger.new)
        {
            if (Trigger.isBefore)
            {
                Opportunity prevOpportunity = Trigger.oldMap.get(o.ID);
                if (o.CloseDate != prevOpportunity.CloseDate) 
                {
                    Integer DayDiff = prevOpportunity.CloseDate.daysBetween(o.CloseDate);

                    OpportunitySchedulingHandler.ScheduleDateUpdate(o.id, DayDiff);
                }
            }

            if (Trigger.isAfter || Trigger.isInsert)
            {
                OpportunitySchedulingHandler.ScheduleServiceDateUpdate(o.id);   
            }
        }
    }

and the Test class is:

trigger OpportunityReScheduling on Opportunity (after update, before update, after insert) 
    {
        for (Opportunity o: Trigger.new)
        {
            if (Trigger.isBefore)
            {
                Opportunity prevOpportunity = Trigger.oldMap.get(o.ID);
                if (o.CloseDate != prevOpportunity.CloseDate) 
                {
                    Integer DayDiff = prevOpportunity.CloseDate.daysBetween(o.CloseDate);

                    OpportunitySchedulingHandler.ScheduleDateUpdate(o.id, DayDiff);
                }
            }

            if (Trigger.isAfter || Trigger.isInsert)
            {
                OpportunitySchedulingHandler.ScheduleServiceDateUpdate(o.id);   
            }
        }
    }

Can somebody help me figure this out? I still getting my way arround Apex and I would really appreciate any assistance

Thank you very much

Alex

 
I have the following formula for a workflow rule that, one of the formula items is that from a picklist either 2 of several items are part of the conditions. This picklist field is Broker Representation, I want the WF to trigger if broker reprensentation equals Seller OR Double Side. How can I change the below formula to reflect this? I tried playing around but it seems I'm always missing a ) or , 

AND(
TEXT(Loan_Type__c)= "VA",
NOT(ISBLANK(Lender_Company_Contact__c )),
NOT(ISBLANK(Buyer_Selling_Agent__c)),
NOT(ISBLANK(Listing_Agent__c )),
NOT(ISBLANK( Appraisal_Ordered_Date__c )),
ISBLANK( Appraisal_Date_Time__c ),
Text ( rethink3__Broker_Representation__c ) = ("SELLER" "Double sided")
)

 
Hello!

Need a little help here.

I have several formula fields on an object that I need to condense to one field. I have several because compilation limits prevented me from including all of my IF statements in one formula field, so now I decided to use a workflow rule.

Below I have pasted all of the formulas that are currently calculating values on four different formula fields.

How do I string them together so that I can get each calculation to run in one field? It's named Total Cost.

Thanks in advance!


IF(Couple__c=True&&ISPICKVAL(Deployment_No__c, "1")&&New_Pricing__c=False,(STIMonthlyCostcurrency__c+ STIDailyCostcurrency__c+GA_Addtl_Cost__c+91)*2+ Donor_Elf_Fee__c,0)

IF(Couple__c=True&&ISPICKVAL(Deployment_No__c, "1")&&New_Pricing__c=True,(GAMonthlyCostcurrency__c + GADailyCostcurrency__c +GA_Addtl_Cost__c+91)*2+ Donor_Elf_Fee__c,0)

IF(ISPICKVAL(Deployment_No__c,"1")&&ISBLANK(StartDate)|| New_Pricing__c=True||Couple__c =True||NOT(ISPICKVAL(Deployment_No__c,"1"))&&Total_Amount_Received__c>26,0,91+STIMonthlyCostcurrency__c+ STIDailyCostcurrency__c+ GA_Addtl_Cost__c-Applied_Credit__c+ Donor_Elf_Fee__c)

IF(ISPICKVAL(Deployment_No__c,"1")&&ISBLANK(StartDate)||Couple__c =True||NOT(ISPICKVAL(Deployment_No__c,"1"))||New_Pricing__c=False&& Total_Amount_Received__c>26,0,91+GAMonthlyCostcurrency__c + GADailyCostcurrency__c + GA_Addtl_Cost__c-Applied_Credit__c+ Donor_Elf_Fee__c)

IF(Couple__c=True&&NOT(ISPICKVAL( Deployment_No__c,"1"))&&New_Pricing__c=False,(STIMonthlyCostcurrency__c+ STIDailyCostcurrency__c+GA_Addtl_Cost__c)*2+Donor_Elf_Fee__c,0)

IF(Couple__c=True&&NOT(ISPICKVAL( Deployment_No__c,"1")),(GAMonthlyCostcurrency__c + GADailyCostcurrency__c +GA_Addtl_Cost__c)*2+Donor_Elf_Fee__c,0)

IF(Couple__c=True||(ISPICKVAL(Deployment_No__c,"1"))||New_Pricing__c=True&&NOT(ISPICKVAL(Deployment_No__c,"1")),0, STIMonthlyCostcurrency__c + STIDailyCostcurrency__c +GA_Addtl_Cost__c-Applied_Credit__c+ Donor_Elf_Fee__c)

IF(Couple__c=False&&NOT(ISPICKVAL(Deployment_No__c,"1"))||New_Pricing__c=True&&NOT(ISPICKVAL(Deployment_No__c,"1")), GAMonthlyCostcurrency__c + GADailyCostcurrency__c +GA_Addtl_Cost__c-Applied_Credit__c+ Donor_Elf_Fee__c,
When creating a task and selecting Lead the related to field is greyed out. 
User-added image 

But when I select Contact from dropdown the related field becomes editable. Is it possible to relate a task on a lead record?

User-added image
I have a checkbox, donotsend__c, that if checked and saved, the user will be prompted with an error in not having sufficient access to do so. 

The checkbox must not be able to be saved to true. 

Can someone help me with this validation rule? 

Thanks!
I wan't to show different task page layouts for a single user depending on  the opportunity stage. Our sales process is automated through tasks needing different inputs during different stages in the process. I wan't to show only the required fields for each stage so there is less probability for the sales rep to get lost. What is the best method to do this?
I have a custom Object Book3__c , In which I have the records as Below.

Name          Email__c
Book1    hh@gmail.com
Book2    hh@gmail.com

Book3    gg@gmail.com
Book4    gg@gmail.com

Book5    kk@gmail.com
Book6    kk@gmail.com
Book7    kk@gmail.com

The problem with the below code is, It deletes all the records . But I need to Keep one and delete the remaining. What Am I missing here.?
 
Global class removeDuplicateRecords implements Database.Batchable<SObject> , Database.Stateful {
    
    global Set<String> emailstring;
    
    global Database.QueryLocator start(Database.BatchableContext BC){
      return Database.getQueryLocator([Select Email__c from Book3__c where Email__c != null]);
      }
    
    global void execute(Database.BatchableContext BC , List<Book3__c> scope){
        
        Set<String> emailstring = new Set<String>();
        
      //  Map<String , Book3__c> EmailBookmap = new Map<String , Book3__c>();
        for(Book3__c s : scope){
        // EmailBookmap.put(s.Email__c , s);
            emailstring.add(s.Email__c);
            
        }  
       // system.debug(EmailBookmap);
        system.debug(emailstring);
        
        List<Book3__c> bklst = [select Email__c from Book3__c where Email__c In :emailstring ];
        
        List<Book3__c> duplicatelist = new List<Book3__c>();
        
        for(Book3__c bk : Scope){
        for(Book3__c b :bklst){
           // if(emailstring.contains(b.Email__c)){
            if(bk.email__c == b.email__c){
              duplicatelist.add(b);  
            }
            else{
             emailstring.add(bk.Email__c);   
            }
        }
        }
        
       // system.debug(EmailBookmap);
        system.debug(duplicatelist);
      delete duplicatelist;
    }
    
    global void finish(Database.BatchableContext BC){
        
    }
        

}

 
I have Created a field email__c on Account and I want to update Update this with the contact that is Active (Active__c checkbox on Contact)
When contact status is active, then I want to deactivate all related account contacts and update active contact email on account email filed . How do I achieve this. I am not knowing how do I deactivate the remaining contacts if the current contact is Active. Please guide me in SOlving this
public class updateAccwithActiveContactEmail {

    public Static void updateAccountwithActiveContact(List<Contact> newconlist){
        
        List<Account> accToUpdate = new List<Account>();
        List<Contact> conToUpdate = new List<Contact>();
       
        Set<Id> accIdSet = new Set<Id>();
        for(Contact c : newconlist){
         accIdSet.add(c.AccountId);   
        }
        system.debug(accIdSet);
        
       List<Account> accWithConlist = [Select Id,Email__c,(Select Id,Active__c,Email,AccountId from Contacts) from Account Where Id IN : accIdSet];
       List<Contact> conlist = accWithConlist[0].Contacts;
        system.debug(accWithConlist);
       system.debug(conlist); 
        system.debug(newconlist);
        
        for(Contact c : newconlist){
         for(Account a : accWithConlist ){
             for(Contact con :conlist ){
                   // if(c.Id == con.Id && c.Active__c == true){
                    if(c.Id != con.Id ){
                    con.Active__c = False ;
                    con.Account.Email__c = c.Email;
                    }
                   
                    
                // accToUpdate.add(a);
                conToUpdate.add(con);
                   // system.debug(accToUpdate);
                    system.debug(conToUpdate);
               }
             // update accToUpdate;  
            }
        }
     }
}

 
I'm trying to create a SOQL query with a subquery to show contacts and accounts located within a state that have a certain custom object relationship:

Here is my code:

SELECT Id,Name FROM Account WHERE Our_Role_Count__c > 0 AND BillingState = 'NH' AND Id IN (SELECT Account__r.Id,Account__r.Name,Account__r.BillingState, Our_Role__r.Name FROM Our_Role_Service_Affiliation_for_Account__c WHERE Our_Role__r.Name != 'Outreach')

However I get an error: The inner select field 'Account__r.Id' cannot have more than one level of relationships
hello

The below code when run is returning the opposite value of what the debug logs show.
 
List <Id> leadsToConvert = new List<Id>();
leadsToConvert.add(leadId);

List<Id> convertedOpps = new List<Id>();
convertedOpps = ConvertLead.ConvertLeads(leadsToConvert);
        
--> this debug statement shows the Opportunity ID and that the size is 1
System.debug('LeadUtilities.convertTheLead Opp Id = ' + convertedOpps[0] + '  - size = ' + convertedOpps.size());

--> the if statement returns Not Converted even though the size is 1
if (convertedOpps.size() > 0) 
   return 'Converted';
else
   return 'Not Converted';
Here are the debug statements that show the size of the list being returned from convertLeads newOpp (1) and the size of the list in the convertTheLead method (1).
User-added image
I have been unable to find anything to explain why this would happen. Has anyone run into this and been able to resolve the issue? Or is their something that I have done that would cause this.

Thank you for any help for a newbie apex developer.

CeeMo
  • March 15, 2017
  • Like
  • 0
I have a custom object "Service Agreement" and need to reference the Opportunity Products on that object when the Service Areement is created from an Opportunity. (It is my understanding that these will update when a quote is synced...please correct me if I am wrong.) The bottom line is that I need the agreed upon products and associated information (price, qty, etc.) on the Service Agreement. My deadline is looming and I just can't figure this out.
I'm trying to change the timeout value from apex using a button in <apex:actionStatus>
apex class:
global class ApexController {
public Integer intMergeTimeout {get; set;}
public void timeoutMerge(){
        //set timeout to 1second
        intMergeTimeout = 500;
    }
}

javascript:
 
<apex:includeScript value="/soap/ajax/21.0/connection.js"/>
        <apex:includeScript value="/soap/ajax/21.0/apex.js"/>
        <script>
        function timeout(){
            sforce.connection.sessionId = "{!$Api.Session_ID}";
            try{
                var result = sforce.apex.executeAnonymous("ApexController","timeoutMerge",{});
                console.log('Timeout!!');
            }catch(e) {
                alert(e);
            }
        }
        </script>

VF(because apex:commandButton doesn't work in the facet I used <input type:"button">):
 
<apex:commandButton value="Action" action="{!action}" status="Loading" reRender="pageSecId" timeout="{!intMergeTimeout}"/>                            
                            <apex:actionStatus id="Loading" >
                                <apex:facet name="start">                                    
                                    <div>
                                        <div class="popupBackground" />
                                        <div class="PopupPanel">
                                            <div align="center">
                                                <div class="slds-text-heading--label">
                                                    <b>Merging...</b>                                                    
                                                </div>
                                                <div class="slds-button slds-button--brand">
                                                    <input type="button" onclick="timeout()" value="Cancel"/>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </apex:facet>                                
                                <apex:facet name="stop"></apex:facet>
                            </apex:actionStatus>





 
  • January 14, 2016
  • Like
  • 0
Hello guys.I have this simple trigger i need to compare old and new values for this trigger and if its not match then update the phone field.Can somebody sort out this problem with code?

trigger SameobjTrg on Contact (before insert) 
{
    for(contact con:trigger.new)
    {
        con.MobilePhone = '98765436523';
      }
}

Hi all,

 

I need to create my own object, named thePeople with some basic fields such as firstName, lastName, email, company... By copying and modifying sample codes, I can create a form in Visualforce to enter data and then write down information of my object to server via Lead object, using Apex code. The Apex code looks like:

 

public class thePeople {

            private String firstName;
            private String lastName;
            private String company;
            private String email;
		...
            public PageReference save() {
                PageReference p = null;
                try {
                        Lead newlead = new Lead(LastName=this.lastName, 
                                                FirstName=this.firstName, 
                                                Company=this.company, 
                                                Email=this.email);
                        insert newlead;
                 } catch (Exception e) {
                        p = Page.failure;
                        p.getParameters().put('error', 'noInsert');
                 }
                
                if (p == null) {
                    p = Page.success;
                }
                
                p.setRedirect(true);
                return p;
            }
}

 

However, Lead object seems to be too redundant and heavy one to me. Furthermore, I don't want all information of my object can be seen in Lead tab. 

 

Thus my (first) question: can I write and read my own object only with only few fields instead of using standard ones? If yes, how (please give me a sample)?

 

Thanks in advance for any helps.

 

Tony

 


I am trying to connect SFDC with aws Dynamodb from last few days using query string parameter but not able to generate signature correctly. I have followed steps mentioned in amazon document to generate Signature Version 4, but still I am getting below response:
<Message>The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.</Message>

It seems either some of the parameters I am not using correctly or missing few items.
.
Can someone help me on this?

-Thanks,
TK

Hi,

 

I am having a scenario where I have to populate the value of a field through WF.

There a two fields on the Contact: Contact ID Auto (an Auto Number field) and Contact ID(Text field).

The scenario is:

If 'Contact ID' field is Null, populate it with the value of 'Contact ID Auto' field.

I have created a WF (Evaluation Criteria: Only when a record is created) which checks for the 'Contact ID =Null' and populate its value with 'Contact ID Auto'.

 

 

Issue: Sometimes the WF works fine and populate the correct value while sometimes 'Contact ID' field remains blank.

Is there any time difference in 'value getting updated in auto Number field' and 'the Execution of WF'?

 

Please suggest.

 

Thanks in advance.

 

 

 

global class MyBatchJob2 implements Database.Batchable<Account_Product__c>,Database.stateful {

global MyBatchJob2(){}

global List<Account_Product__c> start(Database.BatchableContext BC) {
    return [Select id,name,Account__c,AccountProductCatgory__c,Product_Category__c,Products__c, Show__c,Account__r.id 
           From Account_Product__c where  Account__r.id !=null];
}

global void execute(Database.BatchableContext BC, List<Account_Product__c> scope) {
   List<Account_Product_Batch__c> lh = new List<Account_Product_Batch__c>();
   for(Account_Product__c obj : scope){
       System.debug('Course_temp records are: ' +obj);
       lh.add(
           new Account_Product_Batch__c(
           name=obj.name,
              Account_Name__c=obj.Account__c, 
                       Account_Product_Category__c=obj .AccountProductCatgory__c,
                       Product_Category__c=obj.Product_Category__c,
                        Products__c=obj.Products__c,
                        Show__c=obj.Show__c
                        //acc_id__c=obj.Account__r.id 
                    
       ));
       System.debug('The list is: '+lh);
   }
   insert lh;
   //delete scope;
}

i created one batch class for copying all the data from "Account Product" object to my newly created custom object "Account Product Batch". the batch copied all the records sucessfully.
Now i need to copy all the Account's related contact too in "Account Product Batch" from "Account Product".
Hi evryone. please find the below screenshot  and below code for  fields alignments and help me with the alignment.

User-added image

<apex:actionStatus onstart="blockPageLoading()" onstop="unblockPage()" id="blockUI"/>
        <apex:actionFunction name="recalPage" action="{!recalculatePage}"  rerender="procedureComponent,pagemessage"/>
        
        <apex:pageBlock mode="edit" tabStyle="event">
            <div style="margin-left: 300px;"><b><font color ="red"><apex:messages /></font></b></div>
            <br />
           
                <apex:pageBlockSection collapsible="false" columns="1" title="Details of calendar">  
                                
                <apex:inputfield value="{!eventDetails.Subject}"/> 
                <apex:inputfield value="{!eventDetails.Ownerid}"/>
                <apex:inputfield value="{!eventDetails.Internal_Organization__c}" onchange="recalPage();"/>
                <apex:inputfield value="{!eventDetails.Whatid}"/>
                <apex:inputfield value="{!eventDetails.Type__c}" onchange="recalPage();" />
                <apex:inputfield value="{!eventDetails.SubType__c}" onchange="recalPage();" />
                <apex:inputfield value="{!eventDetails.IsAllDayEvent}"/>                
                <apex:pageBlockSectionItem id="debut" >
                <apex:outputLabel value="Start Date Time" for="debut" />
                <apex:outputPanel >
                    <apex:inputText value="{!startDate}" id="dateField"  style="width:80px; height:20px;" required="true"/>
                    <apex:inputText value="{!startHour}" id="startDateHour" style="width:75px; height:20px;" />
                    [&nbsp;<a id="sethour" style="text-decoration: underline; cursor:pointer;" >{!CurrentstartHour}</a>&nbsp;]
                    </apex:outputPanel>                 
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem id="fin" >
                <apex:outputLabel value="End Date Time" for="fin"/>
                <apex:outputPanel >
                    <apex:inputText value="{!endDate}" id="enddate" style="width:80px; height:20px;" required="true"/>
                    <apex:inputText value="{!endHour}" id="endDateHour" style="width:75px; height:20px;" />
                    [&nbsp;<a id="setendHour" style="text-decoration: underline; cursor:pointer;" >{!CurrentstartHour}</a>&nbsp;]
                </apex:outputPanel> 
                </apex:pageBlockSectionItem>                
            </apex:pageBlockSection>
             
            
           <apex:pageblockSection columns="1" >
               <apex:repeat value="{!eventFieldSet}" var="field">    
                <!--<apex:datatable value="{!eventFieldSet}" var="field">-->
                    <apex:pageBlockSectionItem >
                                       
                    <apex:outputPanel rendered="{!field.Label = 'Type' || field.Label = 'Internal Organization' || field.label = 'Sub-Type'}">
                  
                           {!field.Label} &nbsp;&nbsp;
                            <apex:inputField value="{!eventDetails[field]}" onchange="recalPage();"/><br/>
                            
                   </apex:outputPanel>
                   
                   <apex:outputPanel rendered="{! !(field.Label = 'Type')}">
                           {!field.Label} &nbsp;&nbsp;
                           <apex:inputField value="{!eventDetails[field]}"/><br/>
                   </apex:outputPanel>
                   
                </apex:pageBlockSectionItem>
                </apex:repeat>
        <!--</apex:datatable>-->
        </apex:pageblocksection>
        
           </apex:pageblock>


regards,
Isha
I'm tasked with creating an Opportunity Amount field Trigger to Roll-Up from Opportunity Products. How would I go about creating this trigger to roll up from Opportunity Products? Sample code would be awesome!

Sincerely,
Junior Developer!
I have a formula text field contains three fields.  One a currency field, a % field, and a date field.
The % and Data field are fine.  The issue is with the Currency field.  I have been able to add in the "$" sign and comma - leaving out the decimals.
But I need to include the parathesis for negatives and not a "-" negative sign.  How can I do this without "re-creating" my formula????
FYI - It has to be a formula text field....
IF(Amount__c < 0, "(","") & "$" & 
CASE(LEN(TEXT(Amount__c)), 
1, TEXT(Amount__c), 
2, TEXT(Amount__c), 
3, TEXT(Amount__c), 
4, LEFT(TEXT(Amount__c), 1) & "," & RIGHT(TEXT(Amount__c), 3), 
5, LEFT(TEXT(Amount__c), 2) & "," & RIGHT(TEXT(Amount__c), 3), 
6, LEFT(TEXT(Amount__c), 3) & "," & RIGHT(TEXT(Amount__c), 3), 
7, LEFT(TEXT(Amount__c), 1) & "," & MID(TEXT(Amount__c), 2,3) & "," & RIGHT(TEXT(Amount__c), 3), 
8, LEFT(TEXT(Amount__c), 2) & "," & MID(TEXT(Amount__c), 3,3) & "," & RIGHT(TEXT(Amount__c), 3), 
9, LEFT(TEXT(Amount__c), 3) & "," & MID(TEXT(Amount__c), 4,3) & "," & RIGHT(TEXT(Amount__c), 3), 
10, LEFT(TEXT(Amount__c), 1) & "," & MID(TEXT(Amount__c), 2,3) & "," & MID(TEXT(Amount__c), 5,3) & "," & RIGHT(TEXT(Amount__c), 3), 
11, LEFT(TEXT(Amount__c), 2) & "," & MID(TEXT(Amount__c), 3,3) & "," & MID(TEXT(Amount__c), 6,3) & "," & RIGHT(TEXT(Amount__c), 3), 
12, LEFT(TEXT(Amount__c), 3) & "," & MID(TEXT(Amount__c), 4,3) & "," & MID(TEXT(Amount__c), 7,3) & "," & RIGHT(TEXT(Amount__c), 3), null) & 
IF(Amount__c < 0, ")","") &

 
Hi,
I have a text field " Endos Count" which is a counter field. But the format of the count i need is, 001,002,003 etc. Now i am getting as 1,2 3. Can anyone suggest plz, how to get this type of format.
I just wrote the below formula, but its not working,
TEXT(VALUE(Endorsement_Count__c)+001)
Hi,
i have lighting component cancel button when i hit the cancel button it should be redierct to opportunity tab 
i wrote a some code it close the window but it not redirect to opp tab pleasee help me some one
this is my page

User-added image
for that i wrote a following code
doCancel: function(component, event) {
        var retValue = component.get('v.OpportunityID');
        if(window.opener == null){
            window.location.href = "/"+retValue;
        }else{
            window.close();
        }
    }
 
Hi Team,
I am trying to import data using data loader but getting error. I have created a custom object "Test" which has a look up field "Merchandise"
I have added Merchandise ID in the column as well. Please correct me where I am doing wrong.

Thanks in Advance!
Dheeraj

Test ObjectData Loader Error 
Hello,

I have an issue with an Apex Test Class and I would really need your help. I have a Apex Trigger and an Apex Class and I have tried to create a test class but I can't get it over 70% code coverage.

The class is:
public with sharing class OpportunitySchedulingHandler {

     //Update LineItemSchedule dates for all scheduling dates

    public static void ScheduleDateUpdate(String oppid, Integer DayDiff) 
    {
       List<OpportunityLineItem> idval = [SELECT id FROM OpportunityLineItem WHERE OpportunityId=:oppid];
       List<OpportunityLineItemSchedule> datelist = new List<OpportunityLineItemSchedule>();
       for (Integer i = 0; i < idval.size(); i++)
       {
           datelist = [SELECT ScheduleDate FROM OpportunityLineItemSchedule WHERE OpportunityLineItemId =:idval[i].id];
           Date firstDate = datelist[0].ScheduleDate.addDays(DayDiff);
           datelist[0].ScheduleDate = firstDate;

           Integer day = firstDate.day();
           Integer month = firstDate.month();
           Integer year = firstDate.year();

           for (Integer k = 1; k < datelist.size(); k++)
           {
               Integer nYear = year;
               Integer nMonth = month + k;
               Integer nDay = day;

               if (nMonth > 12) {
                   nMonth = nMonth - 12;
                   nYear = nYear + 1;
               }

               Set<Integer> longMonths = new Set<Integer> {1,3,5,7,8,10,12};

               if (nDay == 31 && ! longMonths.contains(nMonth)) {
                   nDay = 30;
 }

               if (nDay > 28 && nMonth == 2) {
                   nDay = 28;
               }

               Date mydate = date.newInstance(nYear,nMonth,nDay);
               datelist[k].ScheduleDate = mydate;
           }
           if(!datelist.isEmpty())
           {
                update datelist;
           }
        }
    }    

      //Update ServiceDate with closeDate

    public static void ScheduleServiceDateUpdate(String oppid)
    {
        List<Opportunity> oliList = [SELECT Id, Name, CloseDate, (SELECT Id, ServiceDate, OpportunityId from OpportunityLineItems) from Opportunity where Id =:oppid];
        List<OpportunityLineItem> oliUpdateList = new List<OpportunityLineItem>();
        for(Opportunity x : oliList)
        {
            for(OpportunityLineItem oli : x.OpportunityLineItems)
            {
                oli.ServiceDate = x.CloseDate;
                oliUpdateList.add(oli);
            }
        }
        if(!oliUpdateList.isEmpty()) 
        {
            update oliUpdateList;
        }
    }
}

The trigger is:

trigger OpportunityReScheduling on Opportunity (after update, before update, after insert) 
    {
        for (Opportunity o: Trigger.new)
        {
            if (Trigger.isBefore)
            {
                Opportunity prevOpportunity = Trigger.oldMap.get(o.ID);
                if (o.CloseDate != prevOpportunity.CloseDate) 
                {
                    Integer DayDiff = prevOpportunity.CloseDate.daysBetween(o.CloseDate);

                    OpportunitySchedulingHandler.ScheduleDateUpdate(o.id, DayDiff);
                }
            }

            if (Trigger.isAfter || Trigger.isInsert)
            {
                OpportunitySchedulingHandler.ScheduleServiceDateUpdate(o.id);   
            }
        }
    }

and the Test class is:

trigger OpportunityReScheduling on Opportunity (after update, before update, after insert) 
    {
        for (Opportunity o: Trigger.new)
        {
            if (Trigger.isBefore)
            {
                Opportunity prevOpportunity = Trigger.oldMap.get(o.ID);
                if (o.CloseDate != prevOpportunity.CloseDate) 
                {
                    Integer DayDiff = prevOpportunity.CloseDate.daysBetween(o.CloseDate);

                    OpportunitySchedulingHandler.ScheduleDateUpdate(o.id, DayDiff);
                }
            }

            if (Trigger.isAfter || Trigger.isInsert)
            {
                OpportunitySchedulingHandler.ScheduleServiceDateUpdate(o.id);   
            }
        }
    }

Can somebody help me figure this out? I still getting my way arround Apex and I would really appreciate any assistance

Thank you very much

Alex

 
Hi All,
I have a visual force page that allows a user to enter/edit their mileage expenses.  All is working fine, but I'm needing to have a column heading rerender when a user hits a "refresh programs" button, but I'm not having any luck.  Here is a simplified version of the page:
 
<apex:page standardController="Expense_Report__c" extensions="addMileageExpense" sidebar="false" showHeader="true">
 <apex:form >		
 		<apex:pageBlock title="Mileage Report" id="er" >
    <table>     
      <tr>
          <td style="width:85px">
          		<h2>Program 1:</h2>
          </td>
          <td style="width:175px">
          		<apex:inputField value="{!Expense_Report__c.Program_1_Mileage_log__c}">          
           		</apex:inputField>
     	  </td>
        <td><apex:commandButton value="Refresh programs" action="{!refreshProgram}" reRender="program_num"></apex:commandButton></td>
        </tr>
    </table>
            <apex:pageMessages />
 		<apex:variable var="rowNumber" value="{!0}"/>
               <apex:pageblockSection columns="1" > 
 					
                   <apex:pageBlockTable title="Mileage Expenses" var="me" value="{!expenseList}" > 
  
 					<apex:column headerValue="Entry" style="width:20px; text-align:center;" headerClass="centertext">
 						<apex:outputText value="{0}" style="text-align:center;"> 
 							<apex:param value="{!rowNumber+1}" /> 
 						</apex:outputText>
					</apex:column> 
 					
                    <apex:column headerValue="Date of trip" >
                       <apex:inputField value="{!me.Date__c}"  required="true"/>
 					                    </apex:column>
                    
                    <apex:column headerValue="Purpose and Description" >
                       <apex:inputField value="{!me.Name}" required="true"/>
 					</apex:column> 
                    <apex:column headerValue="{! Expense_Report__c.Program_1_Number__c}" 
                                 style="width:50px" id="program_num">
                        <apex:inputField value="{!me.Prgm_1_Miles__c}" style="width:50px">
                        </apex:inputField>
                    </apex:column>
                 </apex:pageBlockTable>
             </apex:pageblockSection>                            
 		</apex:pageBlock> 		
 	</apex:form> 
 </apex:page>

The refresh program button simply upserts the existing expense report record after the "program 1" field is changed (and this is working ).  What I'm having problems with is getting the last column heading to rerender after the user changes program and hits the refresh program button.  The last column heading, Expense_Report__c.Program_1_Number__c, is a formula field based on program 1.  On a side note, if I refresh my browser after hitting refresh programs button, it does update the column heading, but  I'm trying to do this without refreshing the whole page. 

I'm new to visualforce so any help/advice is appreciated.

Best,
Collen
I have exhausted all of 3 days trying to research how to do this but due to my limitations being new to the developing world I am afraid I really need some help. Any help is really appreciated. 
 
Controller

public with sharing class Editpositions {
    
    public Position__c myPosition;
    public Position__c editpos {get;set;}
    public Job_Posting__c editpost {get;set;}
    
    
    public Editpositions(ApexPages.StandardController controller) {
        this.editpos = (Position__c) controller.getRecord();
        
    }
    public Position__c getPosition() {
        return myPosition;
        
    }
    Public List <SelectOption> getitems() {
        <SelectOption>() options = new List<SelectOption>();
        //   for (Employment_Website__c mySite = [SELECT Id, Name FROM Employment_Website__c]);      
        //  options.add(new SelectOption(mySite.Id,mySite.Employment_Website__c)) 
        // Loop through the list and update the Name field  
        //    return options; 
    }
}
The issue is where I have put the code in comments // because it was giving me all kinds of errors I just have no idea what I am doing at this point all I know is that after <SelectOption>() options = new List<SelectOption>(); I need to specify to for loop my employment website to selecOption or something like that. 
VF Page

<apex:page standardController="Position__c" extensions="Editpositions">  
    <apex:sectionHeader title="{!Position__c.Name}" subtitle="Edit Records"/>
    <apex:form >
        <apex:pageBlock title="Create and edit Job Positions">
            
            <apex:pageBlockButtons location="both">
                <apex:commandButton action="{!save}" value="Save Record"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
            </apex:pageBlockButtons>
            <apex:pageMessages />
            
            <apex:pageBlockSection title="Create New Position" columns="2">
                <apex:inputField value="{!Position__c.Name}"/>
                <apex:inputField value="{!Position__c.Responsibilities__c}"/>
                <apex:inputField value="{!Position__c.Job_Description__c}"/>
                <apex:inputField value="{!Position__c.Skills_Required__c}"/>
                <apex:inputField value="{!Position__c.Educational_Requirements__c}"/>
                <apex:inputField value="{!Position__c.Java__c}"/>
                <apex:inputField value="{!Position__c.Apex__c}"/>
                <apex:inputField value="{!Position__c.C__c}"/>
                <apex:inputField value="{!Position__c.Javascript__c}"/> 
                <apex:inputField value="{!Position__c.Travel_Required__c}"/>
                <apex:inputField value="{!Position__c.Location__c}"/>
                <apex:inputField value="{!Position__c.Open_Date__c}"/>
                <apex:inputField value="{!Position__c.Hire_By__c}"/>
                <apex:inputField value="{!Position__c.Min_Pay__c}"/>
            </apex:pageBlockSection>
            
            
            <apex:dataList value="{!Position__c}" var="Position__c">
                <apex:outputText value="{!Position.Name}"/>
            </apex:dataList>
            
            
        </apex:pageBlock>
    </apex:form>
</apex:page>

Allso I don't know how to let the two communicate like what code I need to put into the VF Page to run that. 
Once the process is it complete it should let me have a picklist in the Standard object Position where I can choose employment websites to choose to post job postings to. But I have to be able to save more than one website multi picklist type. Once I complete this it should work hopefully.

Thank you for any and all help!
 
Can any one help me how to use CATEGORIES in CUSTOM LABELS...Tell me how it can be used in our code with example...I am learning salesforce...thank you
Hello!

Need a little help here.

I have several formula fields on an object that I need to condense to one field. I have several because compilation limits prevented me from including all of my IF statements in one formula field, so now I decided to use a workflow rule.

Below I have pasted all of the formulas that are currently calculating values on four different formula fields.

How do I string them together so that I can get each calculation to run in one field? It's named Total Cost.

Thanks in advance!


IF(Couple__c=True&&ISPICKVAL(Deployment_No__c, "1")&&New_Pricing__c=False,(STIMonthlyCostcurrency__c+ STIDailyCostcurrency__c+GA_Addtl_Cost__c+91)*2+ Donor_Elf_Fee__c,0)

IF(Couple__c=True&&ISPICKVAL(Deployment_No__c, "1")&&New_Pricing__c=True,(GAMonthlyCostcurrency__c + GADailyCostcurrency__c +GA_Addtl_Cost__c+91)*2+ Donor_Elf_Fee__c,0)

IF(ISPICKVAL(Deployment_No__c,"1")&&ISBLANK(StartDate)|| New_Pricing__c=True||Couple__c =True||NOT(ISPICKVAL(Deployment_No__c,"1"))&&Total_Amount_Received__c>26,0,91+STIMonthlyCostcurrency__c+ STIDailyCostcurrency__c+ GA_Addtl_Cost__c-Applied_Credit__c+ Donor_Elf_Fee__c)

IF(ISPICKVAL(Deployment_No__c,"1")&&ISBLANK(StartDate)||Couple__c =True||NOT(ISPICKVAL(Deployment_No__c,"1"))||New_Pricing__c=False&& Total_Amount_Received__c>26,0,91+GAMonthlyCostcurrency__c + GADailyCostcurrency__c + GA_Addtl_Cost__c-Applied_Credit__c+ Donor_Elf_Fee__c)

IF(Couple__c=True&&NOT(ISPICKVAL( Deployment_No__c,"1"))&&New_Pricing__c=False,(STIMonthlyCostcurrency__c+ STIDailyCostcurrency__c+GA_Addtl_Cost__c)*2+Donor_Elf_Fee__c,0)

IF(Couple__c=True&&NOT(ISPICKVAL( Deployment_No__c,"1")),(GAMonthlyCostcurrency__c + GADailyCostcurrency__c +GA_Addtl_Cost__c)*2+Donor_Elf_Fee__c,0)

IF(Couple__c=True||(ISPICKVAL(Deployment_No__c,"1"))||New_Pricing__c=True&&NOT(ISPICKVAL(Deployment_No__c,"1")),0, STIMonthlyCostcurrency__c + STIDailyCostcurrency__c +GA_Addtl_Cost__c-Applied_Credit__c+ Donor_Elf_Fee__c)

IF(Couple__c=False&&NOT(ISPICKVAL(Deployment_No__c,"1"))||New_Pricing__c=True&&NOT(ISPICKVAL(Deployment_No__c,"1")), GAMonthlyCostcurrency__c + GADailyCostcurrency__c +GA_Addtl_Cost__c-Applied_Credit__c+ Donor_Elf_Fee__c,