• Nirmal Christopher
  • NEWBIE
  • 215 Points
  • Member since 2013
  • Technology Lead
  • Infosys

  • Chatter
    Feed
  • 4
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 26
    Questions
  • 83
    Replies
HI, This may seem like an elementary question but I have not seen this explained anywhere in Sales Force docs however I may have overlooked this topic:

Q) Do inactive triggers still get calculated in an organization's overall coverage ?
I was thinkng that since their meta-xml status has changed to "Inactive" , the Apex Test Execution is somehow notified to omit the inactive trigger as part of  the overall coverage thus possibly increasing the organization's overalll code coverage percentage.

Brief Explanation/Reason for my question:
We have to maintain and scrub our list of older triggers and classes which may no longer be  needed  (not sure yet) due to changes in process or due to software upgrades like Non-Profit Starter Pack(which changes the Contact-Account Relationship regarding Contact's Account ID lookup by making this lookup field obsolete since accounts are now regarded as affiliations ).

Thanks much.
Hi, I have a trigger in place that updates the product schedule dates if the Opportunity close date changes.  The trigger works exactly as expected, however, I'm unable to test it adequately. The test logic does not insert the default product schedules automatically, so I'm trying to insert them manually so I can generate adequate coverage. However, the code fails on insert when I try to insert the OpportunityProductSchedule record, the error is: 

System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []

When I looked up the Object reference for OpportunityLineItemSchedule, it shows as createable so I'm not sure what the issue is - anyone been able to test product schedules? All of the posts I found it looks like other people are having the same issues and am not finding any resolutions posted. 

APEX Trigger and Class: 
trigger updateProdScheduleTrigger on Opportunity (after update) {
   
    Set<id> olisIds = new Set<id>();
    Set<id> opptyIds = new Set<id>();
   
    for(Opportunity o : trigger.new){
        if(o.CloseDate != trigger.oldMap.get(o.id).CloseDate){
     opptyIds.add(o.id);
        }
    }
    if(!opptyIds.isEmpty()){
    List<OpportunityLineItem> oli = [SELECT id FROM OpportunityLineItem WHERE OpportunityId IN :opptyIds AND HasRevenueSchedule = TRUE];
        if(!oli.isEmpty()){
            for(OpportunityLineItem olis : oli){
                olisIds.add(olis.id);
            }
        }
        updateProductSchedule.updateSchedule(olisIds);
    }

}

public class updateProductSchedule{
   
   
    public static void updateSchedule(Set<id> olisIds){
       
        List<OpportunityLineItem> olis = [SELECT id, OpportunityId, Opportunity.CloseDate, UnitPrice
                                          FROM OpportunityLineItem
                                          WHERE Id IN :olisIds];
        Map<String, Date> lineCloseDate = new Map<String, Date>();
        for(OpportunityLineItem o : olis){
            lineCloseDate.put(o.id, o.Opportunity.CloseDate);
        }
       
        List<OpportunityLineItemSchedule> oliSchedules = new List<OpportunityLineItemSchedule>();
       
  oliSchedules = [SELECT id, ScheduleDate, OpportunityLineItemId, Quantity, Revenue, Type, OpportunityLineItem.UnitPrice,
                        OpportunityLineItem.OpportunityId, OpportunityLineItem.Opportunity.CloseDate
                        FROM OpportunityLineItemSchedule
                        WHERE OpportunityLineItemId IN :olisIds ORDER BY ScheduleDate ASC];
      
        for(OpportunityLineItemSchedule os : oliSchedules){
            system.debug('current os schedule date>>>'+os.ScheduleDate +  ' and revenue>>>'+os.Revenue);
        }
   List<OpportunityLineItemSchedule> olischedToUpdate = new List<OpportunityLineItemSchedule>();       
       
       
        Date newStartSchedDate = oliSchedules[0].OpportunityLineItem.Opportunity.CloseDate;
        Decimal newREvScheduleAmt = oliSchedules[0].OpportunityLineItem.UnitPrice / 12;
        for(Integer i = 0; i<oliSchedules.size(); i++){
            oliSchedules[i].Revenue = newRevScheduleAmt;
            oliSchedules[i].ScheduleDate = newStartSchedDate.addMonths(i);
            olischedToUpdate.add(oliSchedules[i]);
            system.debug('current os schedule date>>>'+oliSchedules[i].ScheduleDate +  ' and revenue>>>'+oliSchedules[i].Revenue);
        }
        update olischedToUpdate;
      
    }

}

TEST Code: 

@istest (seeAlldata=True)
public class testUpdateProdSchedule{
    private testmethod static void testUpdateSched(){
       
        List<Account> accts = new List<Account>();
        for(integer i=0; i<200; i++){           
            Account a = new Account(Name='test'+i);
            accts.add(a);
        }
        insert accts;
       
        List<Opportunity> opptys = new List<Opportunity>();
        for(integer i=0; i<200; i++){
            Opportunity o = new Opportunity(Name='test'+i, AccountId = accts[i].id, CloseDate=date.today().addMonths(12),
                                            Amount=0, StageName='Proposed');
            opptys.add(o);
        }
        insert Opptys;
        Set<id> opptyIds = new Set<Id>();
        for(Opportunity o : opptys){
            opptyIds.add(o.id);
        }
        PricebookEntry pbe = [SELECT id, UnitPrice, Product2.NumberOfRevenueInstallments FROM PriceBookEntry
                              WHERE isActive=True
                              AND Product2.NumberOfRevenueInstallments = 12 LIMIT 1];
       
        system.debug('number of rev installments for pbe>>>'+pbe.Product2.NumberOfRevenueInstallments);
       
        List<OpportunityLineItem> olis = new List<OpportunityLineItem>();
        for(integer i=0; i<200; i++){
         OpportunityLineItem oli = new OpportunityLineItem();
            oli.OpportunityId=opptys[i].id;
            oli.PricebookEntryId=pbe.id;
            oli.Quantity=1;
            oli.UnitPrice=1200000;
            olis.add(oli);
        }
        insert olis;
        OpportunityLineItem line = [SELECT id FROM OpportunityLineItem WHERE PriceBookEntryId=:pbe.id LIMIT 1];
        List<OpportunityLineItemSchedule> oliSchedToInsert = new List<OpportunityLineItemSchedule>();
        for(integer i=0; i<12; i++){
            OpportunityLineItemSchedule s = new OpportunityLineItemSchedule();
            s.Revenue = 100000;
            s.ScheduleDate = date.today().addMonths(i);
            s.OpportunityLineItemId = line.id;
            s.type = 'Both';
            s.Quantity = 1;
           
            oliSchedToInsert.add(s);
        }
        insert oliSchedToInsert;
       
        List<OpportunityLineItemSchedule> oliSched = [SELECT id, Revenue, ScheduleDate,OpportunityLineItemId,
                                                      OpportunityLineItem.OpportunityId FROM OpportunityLineItemSchedule
                                                      WHERE OpportunityLineItem.OpportunityId IN : opptyIds];
       
        system.debug('size of schedule list>>>'+oliSched.size());
        //system.assertEquals(oliSched.size()>0, true);
        opptys[0].closeDate = date.today().addMonths(13);
        update opptys[0];
       
        List<Opportunity> opptysToUpdate = new List<Opportunity>();
       /* for(integer i=0;i<200; i++){
            opptys[i].CloseDate = date.today().addMonths(14);
            opptysToUpdate.add(opptys[i]);
        }
        update opptysToUpdate;*/
       
    }
}
I have a  Wrapper list which  I used to display the contents in the visualforce page  The wrapper  list has a Index number (showed in screen shot next to the button) . On Clicking the button the index number is passed to find the exact position and clone the value inside the list and adds inside the list again and increments the index number to +1.It works fine until that. But the subsequent index position needs to get updated.

for example if the list contains 6 rows. I am hitting the button inside the third row a new record need to get inserted copying the 3rd row's values in the 4 th  row. Then 5,6,7 th rows index number also have to be incremented appropriately. slw1 is the list in need to add and display.

Copied the method below which will execute on click of the button.
public void addcountqualify(){
    qwerty=slw1.size();
    qualifyindex= ApexPages.currentPage().getParameters().get('indexnumber'); 
    integer countq=integer.valueof(qualifyindex);
    system.debug('----->qualifyindex'+qualifyindex);
      system.debug('----->countq'+countq);
      
    steplibrarywrap sl=new steplibrarywrap();
        sl.stagenames =slw1[countq].stagenames;  
        sl.stepNames  =slw1[countq].stepNames;
        sl.RequiredByCandidate=slw1[countq]. RequiredByCandidate;
        sl.order = slw1[countq].order+'dupe' ;
        sl.StepLibrary =slw1[countq]. StepLibrary ;
        sl.evaluator =slw1[countq].evaluator ;                    
        sl.evaluatorName = slw1[countq].evaluatorName ;
        sl.StepLibraryID =slw1[countq].StepLibraryID ;
        sl.indexqualify=slw1[countq].indexqualify+1;
        integer inq=slw1[countq].indexqualify+1;
       
        for(steplibrarywrap  slw:slw1){
            if(slw.indexqualify>=inq){
            slw.indexqualify=inq+1;
            }
          } 
       slw1.add(countq,sl);
       listcatteria.addall(slw1);
    system.debug('------>listcatteria'+listcatteria);
    
    }










User-added image

Attempting to map exact spring string to the API name of the queues using 'split by character camel case. Currently the process is not picking up the API names. 

for Example I have variable like CDFiles_3pTalk as the API name.

CDFiles- will be a constant string which will be concatenated always

The text field I have should be render aotomatically text automatically to the above format no matter what the Imput is 

for Instance if the user give the input as 3pTalk it should render me the name CDFiles_3pTalk but it gives me CDFIles_3_p_Talk which is incorect. Copied my code below  Any suggerstions?
 
/******

Description: This Trigger will update the Owner in the Customer downloads object based on the field SO_Name__c. The field "SO_Name__c"
needs to match exactly with the pre-existing Account Name. Queue name picks the right record based on the SO_Name__C and matching Account Name and updates the "OwnerId" field 
and "Downloads_Account_Name__c" Field

*******/

trigger UpdateOwnerinCD on Customer_Download__c (before insert,before update) {
    set<string>collectaccnames=new set<string>();
    set<string>collectaccnames1=new set<string>();
        for(Customer_Download__c cd:trigger.new){
        //Collecting and processing the list of variable for query clauses 
            if(cd.SO_Name__c!=null){
                string clipoff=cd.SO_Name__c;
                 clipoff=clipoff.replaceall('[^a-z^A-Z^0-9]','_');
                    system.debug(clipoff);
                    List<String> splitname = clipoff.splitByCharacterTypecamelcase();
                    System.debug(splitname);
                    string clipoff1='';
                    for (string s:splitname){
                    if(!s.contains('_'))
                        {clipoff1+=s;}   
                            clipoff1+='_';
                        }
                    clipoff1=clipoff1.replace('__','_');
                    clipoff1=clipoff1.removeend('_');
                    System.debug(clipoff1);
      
                collectaccnames.add('CDfiles_'+clipoff1);
                collectaccnames1.add(cd.SO_Name__c);
            }
          }
System.debug('collectaccnames'+collectaccnames);
    //Build Lists to select Records
    list<account>acc=[select id,name from account where name IN:collectaccnames1 limit 9999];
    list<group>g=[select id,developername,type from group where developername IN:collectaccnames AND  type='queue' ];
    system.debug('g'+g);
    Map<string,group>groupmap=new map<string,group>();
    Map<string,account>accountmap=new map<string,account>();
        for(group g1:g){
            groupmap.put(g1.developername,g1);
        }
        for(account acc1:acc){
            accountmap.put(acc1.name,acc1);
        }
    system.debug('groupmap'+groupmap);
    system.debug('accountmap'+accountmap);
        for(Customer_Download__c cd1:trigger.new){
            if(cd1.SO_Name__c!=null){
            //Get the values from the Maps and update the Owner field and Downloads account name field.
                string clipoff=cd1.SO_Name__c;
                clipoff=clipoff.replaceall('[^a-z^A-Z^0-9]','_');
                system.debug(clipoff);
                List<String> splitname = clipoff.splitByCharacterTypecamelcase();
                System.debug(splitname);
                string clipoff1='';
                for (string s:splitname){
                    if(!s.contains('_'))
                        {clipoff1+=s;}   
                        clipoff1+='_';
                }
                clipoff1=clipoff1.replace('__','_');
                clipoff1=clipoff1.removeend('_');
                System.debug(clipoff1);               
                System.debug('clipoff1'+clipoff1);
                clipoff1 ='CDfiles_'+clipoff1;
                system.debug('clipoff1'+clipoff1 );
                group g12 = groupmap.get(clipoff1);
                system.debug(g12+'g12');
                account acco=accountmap.get(cd1.SO_Name__c);
                    if(!test.isrunningtest()){
                    if(g12 != null && g12.id!=null){
                     cd1.Ownerid=g12.id;
                     }else{
                        cd1.Ownerid=userinfo.getuserid();
                    }
                if(acco!=null){
                cd1.Downloads_Account_Name__c=acco.id;
                }
                }
            }
        } 
   }

 
Description : We have the external system which have the TAR files which is sent to "Content Document" object in salesforce and Salesforce need to delete the files autometically from the system every 30 days. Here is the problem I am unable to identify which is TAR files among the other files in the object since the field "FileType" returns the value "Unknown". Please let me know if there is any work round to identify the TAR files in the "Content Document" object 
Hi everyone,

I have a Case where I need to control the number of users created for customer portal with respect to ech account.

For example: I have Account A under which I have contacts 1,2,3,4,5. out of the five contacts the Administrator or delegated administrator should have the ability to limit the number of users can be created from each contact.

Is it possible to create a picklist field in the accounts objects with the values  like 1 2 3 ttc and based on the selection is it possible to limit the number of users created for each account?

Idea to Implement trigger is appreciated
We are building a recruiting app have a requirement like connecting  force.com sites between two different orgaizations,One org will be my company's production org, Other will be the Client's org. These two orgs will have a custom recruiting application installed which is built by us. The business process expected is as follows

Just like Monster Jobs portal or any other jobs portal the client's open positions have to be published in our force.com site. If a candidate applies for a  Client'sJob from our portal the appication has to be catured in our site. If the Candidate applies for the same job in Client's portal the information should be captured only in the client's org. Is there any way to do this without using integration techniques or web services API. If it can be done only using web services API Please share our views too.

If you can share your ideas how to do this It will ease my pain. Thanks for the help in advance.



I have these field  Inorder to change the value from the look up field in a visualforce page and choose required value from the pop up after selecting the pop up  is not getting disappeared (the popup remains Intact) but the field value is changed. Since this is from the standard field  I am un able to track why this is not working.

<apex:inputField value="{!Jobs__c.Job_Locations__c}" required="true">
In a scenario i want to retain only the old values of the event if the event is updated directly when related to a custom object. Here is my  trigger. IT works fine for all the event fields except event start date and end date. These two field are not retaining their old values, It accepts the user Inputs.Also Debug statements working fine as expected. But its not updating the field values.

trigger prohibitUpdate on Event (before update) {
Set<id>neweveid=new set<id>();
Set<id>whatid=new set<id>();
for(event eve:trigger.new){
neweveid.add(eve.id);
whatid.add(eve.whatid);
}

for(event eve:trigger.new){

Event oldEve = Trigger.oldMap.get(eve.id);
if(trigger.isupdate){
system.debug('******'+trigger.old[0].StartDateTime);
          eve.StartDateTime=oldEve.StartDateTime;
          eve.EndDateTime=oldEve.EndDateTime;
          eve.Onsite_Arrival_DateTime__c = oldEve.Onsite_Arrival_DateTime__c;
          eve.Onsite_Completion_DateTime__c =  oldEve.Onsite_Completion_DateTime__c;
          eve.Location = oldEve.Location;
          eve.Description = oldEve.Description;
          eve.OwnerId = oldEve.OwnerId;
          eve.ShowAs = 'OutofOffice';
          eve.Subject = oldEve.Subject;
          eve.WhoId = oldEve.WhoId;       
}
}
}
We are trying to implement a new NPSP organization. Created a trigger and a test class but when we are trying to deploy into production and tried to run all the tests. first all the NPSP test classes failed we made some modifications in the classe and ran the tests again. Now all the test classes are passed but the code coverage is 59%. Since all these test classes comes from NPSP package we are unable to modify it. We ran the test classes in production same problem. Did any one have experienced this before?
This component renders a picklist value from the sobject
<apex:inputField value="{!Evaluation__c.Outcome__c}" ></apex:inputField>

this components renders picklist field in wich a value called 'None' is added
                    <apex:selectList value="{!nextStageSelection}" multiselect="false" size="1"  label="Next Stage" >                      
                        <apex:selectOptions value="{!StageItems}"/>
                    </apex:selectList>

In the first picklist if i choose the value  'Rejected' then automatically 'None should be selected in the picklist value. I am not an expert in Java script. please help  me. Thanks in advance.'
Hi i am trying to build a trigger when mass import is done using a data loader the trigger should save the file in specific formats. For Example IF Job__c is the master object and jobApplicant__c is the child object when doing bulk imports the files should get saved in the following format
JA-0001.0002
JA-0001.0003
JA-0001.0004
 where '0001' comes from the master record name and 0002 is the indvidual child records related to the master.
below is the sample code please help me with the working code
trigger updateAppplicantName on Job_Applicants__c (before insert, before update) {
set<id> vacSet = new set<id>();
for(Job_Applicants__c ja:trigger.new){
vacSet.add(ja.Job_Name__c);
}           
  System.debug('***vacSet***'+vacSet); 
  list<Job_Applicants__c >japp=[select id,name,Job_Name__r.name from Job_Applicants__c where Job_Name__c IN:vacSet order by createddate desc limit 1 ];
String vName='' ;
  string jobname;
  integer num;
  jobname=japp[0].Job_Name__r.name ;
  String jobApplicant=japp[0].name;
  String jobApplicant1=jobApplicant.substring(8,12);
  num=integer.valueof(jobApplicant1);
string AppName=japp[0].name;
String Jobname1=jobname.substring(3,7);
  for(Job_Applicants__c jaa:trigger.new){
  jaa.name='JA-'+Jobname1+num+1;
 
    }
}

Thanks in Advance.
I have developing apex class that will send an email with site URL, it's hard coded it's working our org, when I deploy the apex class in another org, It's sending the same URL as it's hard coded.

I need to send the URL dynamically depends on where it's installed.
Hello Team,

We have couple of questions for submitting app in app exchange

1. After submitting the App for getting the security Review, what is next?

2. What are all the steps involved in assigning a license to a customer?

3. When do we upload the marketing material to our app-exchange listing?

4. When a potential customer asks for a trial - should the customer contact us before they install and start using it?

5. Do we need a copy of license for the customer to sign and start using it.

~Nirmal
The below code is not working for me. I was testing the code which is given from the saleforce blogs. The streaming api Doesnt working can any one tell me what i am missing here?

<apex:page id="page" tabStyle="Case">

    <apex:includeScript value="{!$Resource.cometd}"/>
    <apex:includeScript value="{!$Resource.jquery}"/>
    <apex:includeScript value="{!$Resource.json2}"/>
    <apex:includeScript value="{!$Resource.jquery_cometd}"/>
   
    <script type="text/javascript">
   
        var j$ = jQuery.noConflict();
        j$(document).ready(function() {
    
            j$.cometd.init({
                url: window.location.protocol+'//'+window.location.hostname+'/cometd/28.0/',
                requestHeaders: { Authorization: 'OAuth {!$Api.Session_ID}'}
            });
   
            j$.cometd.subscribe('/topic/CaseNotifications’, function(message) {
                document.getElementById('{!$Component.page.block.casenumber}').innerText = message.data.sobject.CaseNumber;
                document.getElementById('{!$Component.page.block.casestatus}').innerText = message.data.sobject.Status;
                document.getElementById('{!$Component.page.block.casepriority}').innerText = message.data.sobject.Priority;
                console.log(message);
            });
       });
      
   </script>
    <apex:sectionHeader title="Simple" subTitle="Case Notifications"/>
    <apex:pageBlock id="block">
        <apex:panelGrid columns="2">
<apex:outputLabel value="Case Number: "
for="casenumber" style="font-weight: bold;"/>
            <apex:outputText value="" id="casenumber"/>
            <apex:outputLabel value="Case Status:  "
for="casestatus" style="font-weight: bold;"/>
            <apex:outputText value="" id="casestatus"/>
            <apex:outputLabel value="Case Priority:  "
for="casepriority" style="font-weight: bold;"/>
            <apex:outputText value="" id="casepriority"/>
        </apex:panelGrid>
    </apex:pageBlock>
</apex:page>

http://wiki.developerforce.com/page/Streaming_Real_Time_Data_into_Visualforce?app_data=%7B%22pi%22%3A%22532112ed9b6f688114000003%22%2C%22pt%22%3A%22wall%22%7D

This is the link for the  blog.
In contact I have member photos(JPEG files). I am creating a UI to display (using Apex and visualforce) all the attachments with a check box by it's side. The User will have the ability to choose the files they like to download and click a download button all the slected records should get  downloaded without viewing the record. how can i acheive this? I tried using java script i n the code its not working. \

Note:The files are getting downloaded automatically it the file is a word document or a XLS document. If the document is a Image file how we can do this?
Im unable to save this code but it works well with contact or account sobject the error im getting is "attcon Compile Error: Dynamic SOQL loop variable must be an SObject or SObject list (concrete or generic) at line 27 column 32" Did i miss anything here?

public pagereference search(){
        if(searchResults==null){
        searchResults=new list<AttachmentWrapper>();//initiate searchresults if the value is null
            }
        else{
        searchResults.clear();//clear out the current results if the values pre exist
            }
        //dynamic SOQL query to fetch the attachments
                String qry = 'Select Name, Id From attachment Where Name LIKE \'%'+searchText+'%\' Order By Name';
                for(attachment att:database.query(qry)){
               
                }

    return null;
    }
I wanted to pick the attachment record from contact and send the attachment in an email. this is the requirement im getting null pointer exception. I checked in debuglogs seems everything is fine. The email should fire on the condition  ID_card_Status__c=='Designer'. Below is my trigger kindly help me asap.
trigger autonumberid on Contact (before insert, before update) {
public string var1='';
public id[] attachmentid=new id[]{};


list<RecordType>ALLRT1=[SELECT DeveloperName,Id,SobjectType FROM RecordType
                       where SobjectType ='Contact' AND DeveloperName='Primary_Member'];
                      
list<RecordType>ALLRT2=[SELECT DeveloperName,Id,SobjectType FROM RecordType
                       where SobjectType ='Contact' AND DeveloperName='Student_Member'];
                      
list<RecordType>ALLRT3=[SELECT DeveloperName,Id,SobjectType FROM RecordType
                       where SobjectType ='Contact' AND DeveloperName='Business_Member'];

list<RecordType>ALLRT4=[SELECT DeveloperName,Id,SobjectType FROM RecordType
                       where SobjectType ='Contact' AND DeveloperName='Pillar_Member'];

list<RecordType>ALLRT5=[SELECT DeveloperName,Id,SobjectType FROM RecordType
                       where SobjectType ='Contact' AND DeveloperName='Life_Member'];
                      
list<RecordType>ALLRT6=[SELECT DeveloperName,Id,SobjectType FROM RecordType
                       where SobjectType ='Contact' AND DeveloperName='Patron_Member'];

list<contact>priList=[select id,Contact_Id__c,Contact_Record_Id__c,RecordTypeId  from contact
                     where Contact_Record_Id__c!=null];
                    
Decimal d1=priList.size();
for(contact c1:trigger.new){
string recordtypeid=c1.recordtypeid;
    if(recordtypeid.contains(ALLRT1[0].id)){
        c1.Contact_Record_Id__c='TN/CHE/PRI-000'+d1++;
    }
    if(recordtypeid.contains(ALLRT2[0].id)){
        c1.Contact_Record_Id__c='TN/CHE/STU-000'+d1++;
    }
    if(recordtypeid.contains(ALLRT3[0].id)){
        c1.Contact_Record_Id__c='TN/CHE/BUS-ME-000'+d1++;
    }
    if(recordtypeid.contains(ALLRT4[0].id)){
        c1.Contact_Record_Id__c='TN/CHE/PIL-000'+d1++;
    }
    if(recordtypeid.contains(ALLRT5[0].id)){
        c1.Contact_Record_Id__c='TN/CHE/LIF-000'+d1++;
    }
    if(recordtypeid.contains(ALLRT6[0].id)){
        c1.Contact_Record_Id__c='TN/CHE/PAT-000'+d1++;
    }
    if(trigger.isupdate){
    if(c1.ID_card_Status__c=='Designer'){
    if(trigger.isupdate){
     Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
      Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
  
     attachment file=[select id,parentid,body from attachment where parentid=:c1.id AND Name LIKE '%photo%' Limit 1];
     Blob b =file.body ;
      efa.setBody(b);
     String[] emailAddrnew1 = new String[] {'nchristopher@gtr.net'};
    
            attachmentid.add(file.id);
            system.debug('***************'+file.id);
            system.debug('bbbbbbbbbbb'+b);
    
     mail.setToAddresses(emailAddrnew1);
     system.debug('emailAddrnew1'+emailAddrnew1);
      system.debug('eeeeeeeeeeeeeeeeeeeeeeeeeeee'+efa);
     mail.setSubject('New card print request'); 
     mail.setPlainTextBody('print this new id card'); 
     mail.setHtmlBody('This is to notify that the Owner of lead: https://ap1.salesforce.com/ <b>'); 
     mail.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
     Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); 
   
}}}
}
}
Is this trigger bulkified im unable to bulk inset using data loader only the last recored in the csv file gets the field update properly

trigger urlattachmentupdate on Attachment (after insert,after update) {
list<contact>cc=new list <contact>();
set<attachment>a=new set<attachment>();
Public string attachmentid='';
Public string parentid='';

for(Attachment aa:trigger.new){
attachmentid=aa.id;
parentid=aa.parentid;
System.debug('Attchment IDDD'+attachmentid);
System.debug('ParentIDDDDDDDDDDD'+parentid);
}
cc=[Select id from contact where id =:parentid];
for(contact cc1:cc){
cc1.Member_Photo_URL__c='https://c.cs10.content.force.com/servlet/servlet.FileDownload?file='+attachmentid;
}
update cc;
}
This is the VF code Snippet we are using in our org. The user user rich text area to enter te data and this component is used in a standard page. but we are querying this value in anothe Custom VF page. The problem is the output text value renders the output along with HTML tags. If i remove the HTMLENCODE it works fine. FYI  HTMLENCODE  is required for submitting the app for app exchange. So we cannnot remove that.

<td><apex:outputText value="{!HTMLENCODE(r.questions)}" escape="false"/></td>

Any alternative solutions is appreciated.
in VF  page
<apex:pageBlockSectionItem >            
          
             <apex:outputLabel value="" style="font-style:italic;font-weight:bold"  >
              <apex:outputText value="Job Title" ></apex:outputText>
              </apex:outputLabel>                            
              <apex:inputtext value="{!jobtitle }" />       
            </apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
            <apex:outputLabel value="Job Description" style="font-weight:italic;font-weight:bold">
                </apex:outputLabel>
                    <apex:inputTextarea value="{!jobDescription2}" required="true"/>        
            </apex:pageBlockSectionItem>
         <apex:pageBlockSectionItem >

In controller

public with sharing class help{

    public string jobtitle {get;set;}

    public string jobDescription2{get;set;}


public Pagereference send_email2(){
    string id=userinfo.getuserid();
   firstName=userinfo.getfirstname();
   lastName=userinfo.getlastname();
   user u1 =[select id,firstname,lastname,Companyname,phone,email from user where id=:id limit 1];
 
   Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
   String[] toAddresses = new String[] {'nchristopher@gtr.net'};
      system.debug('+++++++'+jobtitle);
      system.debug('+++++++'+jobDescription2);
   mail.setToAddresses(toAddresses );
   mail.setReplyTo('nchristopher@gtr.net');
   mail.setSubject('New Support request from -'+u1.companyName);
   mail.setBccSender(false);
   mail.setUseSignature(false);
  // if(selectionstage1=='Report-Issue' ){
   mail.setHtmlBody('Hi GTR Support,<p/> This is to inform you that there is a new support request from'+u1.Companyname+', The details are given below <br/> <table><tr><td> User Name: &nbsp;'+u1.firstname+'&nbsp;'+u1.lastname+'</td></tr><tr><td>Phone Number: &nbsp;'+u1.Phone+'</td></tr><tr><td>E-mail: &nbsp;'+u1.email+'</td></tr><tr><td>Support Type: Recruiting Help From GTR</td></tr><tr><td>Issue Description: &nbsp;'+jobDescription2+'</td><td>Job Title:'+jobtitle+'</td></tr></table>'  );
  
 
   Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
 
   return null;
   }
}


The text area and text field component prints null if send_email2 button is invoked....because of this i am unable to get the user inputs. What might be the issue. the same code works fine in my devloper acc...but in the sandbox its not working.

I want to do a lookup field update on edit page on click of a button action for this i have created a VF page and a controller. For each click the field should get updated as rec1,rec2...etc. How can we do this? I had an idea of retrieving a record using a soql query but bit stuck how to sort it and build where clause for it? Any idea how to acheive this?

We are building a recruiting app have a requirement like connecting  force.com sites between two different orgaizations,One org will be my company's production org, Other will be the Client's org. These two orgs will have a custom recruiting application installed which is built by us. The business process expected is as follows

Just like Monster Jobs portal or any other jobs portal the client's open positions have to be published in our force.com site. If a candidate applies for a  Client'sJob from our portal the appication has to be catured in our site. If the Candidate applies for the same job in Client's portal the information should be captured only in the client's org. Is there any way to do this without using integration techniques or web services API. If it can be done only using web services API Please share our views too.

If you can share your ideas how to do this It will ease my pain. Thanks for the help in advance.



I have developing apex class that will send an email with site URL, it's hard coded it's working our org, when I deploy the apex class in another org, It's sending the same URL as it's hard coded.

I need to send the URL dynamically depends on where it's installed.
Hi there

First of all, I am NOT looking to rename "Account" to something else, but can I rename the field "Account" on just one of my standard objects?  

Specifically, on the standard Quote object, the standard "Account" field really represents "Bill-to Party" (as per SAP).  I would like to know if I can rename just this one standard field Account on Quote?  Again, I don't mean to rename "Account" globally.

I went to the Rename Tabs and Labels for Quote and don't even see the field for "Account".  Then I realize, when I go to the Rename page for, say, Opportunities, I don't see "Account" either.

Does it mean I can not rename the "Account" field name without renaming "Account" object name, globally?

Thanks
King
Hi,

I have a requirment:
Parent P(STD obj) – lookup relationship - Child C(Custom obj)
If C has no records then show C  creation link
Else show ‘Send an Email’ link (Link : Go to - Activity related list – Send an Email button )

*Else part working fine.

I am unable to control the visiblity of the child creation link when no child record present.

Thanks,
Sameera
 
Hi All,
I have a requirement that on the click of account save button it has to check whether loginName and Keymanagername(Field on account which has lookup with user) are same or not if yes then assign it to one permission set.
As per my understanding i have Wriiten this in Account Handler Class 
Id userId=UserInfo.getUserId();
String userName=[Select Id, Name From User Where Id =:userId].Name;
system.debug('username'+userName);
and Created a list object on handler class like private List<KeyAccountManager__c> keymanagersFromAccounts = new List<KeyAccountManager__c>();
But i am not sure how can i compare this both because one is string and another is list object.Could any one that what would be the right approach for it.should i need to find all accounts keymanagers in a field and have to put a loop to check its matching with usename or not.I dont have a clear understaning that how to achieve this.
Hi all, i'm a beginner ! 

I'm working on a BI project with Tacton and SalesForce. I need to "move" data (realted to an opportnity X in SalesForce) from Tacton to SalesForce, so i can create with those data a BI Dashboard with a third software called Tableau. 

Any possibility to move data from Tacton to SalesForce ? Thank you ! 
I want a chat button to be displayed on my website that says "Chat with Us" where people can click to initiate a chat on VerifiedFirst.com.
This code is embedded in my footer but no button appears. What am I doing wrong?

<script type='text/javascript' src='https://c.la3-c1-was.salesforceliveagent.com/content/g/js/34.0/deployment.js'></script>
<script type='text/javascript'>
liveagent.init('https://d.la3-c1-was.salesforceliveagent.com/chat', '572o0000000L5LT', '00Do0000000XzpL');
</script>

<a id="liveagent_button_online_573o0000000L6Ig" href="javascript://Chat" style="display: none;" onclick="liveagent.startChat('573o0000000L6Ig')"><!-- Online Chat Content --></a><div id="liveagent_button_offline_573o0000000L6Ig" style="display: none;"><!-- Offline Chat Content --></div><script type="text/javascript">
if (!window._laq) { window._laq = []; }
window._laq.push(function(){liveagent.showWhenOnline('573o0000000L6Ig', document.getElementById('liveagent_button_online_573o0000000L6Ig'));
liveagent.showWhenOffline('573o0000000L6Ig', document.getElementById('liveagent_button_offline_573o0000000L6Ig'));
});</script>
Hi There,

I have a controller which is for an object, that has many children objects looking it up. The controller wraps the two children into a datatble. So far, everything on the page works, if I am inserting these records. I was wondering, what I would have to change within the controller, so that it can be used for editing records as well.

By editing, I essentially mean displaying the page, with all the inpput fields filled and the datatable full of child objects, how it looked just before save. I think i need to access the Fin record and all loan split and loan security records that look the Fin record up.

I am not sure how to phrase this, a point in the right direction would be much appreciated.

this is my controller:
 
public class FinanceNew{
    
    public Finance__c Fin { get; set; }
    public Finance_Loan_Security__c LoanSecurity { get; set; }
    public Finance_Loan_Split__c LoanSplit { get; set; }
    
    
    //Wrapper multi add try to implement
     public List<FinLoanSplitWrapper> wrappers {get; set;}
 public static Integer toDelIdent {get; set;}
 public static Integer addCount {get; set;}
 private Integer nextIdent=0;
 
 //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\Wrapper 2 identical - 1
       public List<FinLoanSecurityWrapper> wrappers2 {get; set;}
 public static Integer toDelIdent2 {get; set;}
 public static Integer addCount2 {get; set;}
 private Integer nextIdent2=0;
 //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\Wrapper 2 identical - 1
 
 ////////////////test
 
 public decimal AggregateLoanAmount{get;set;}
 public integer LoanSplitSize{get;set;}
 
 public void calculation()
{
AggregateLoanAmount = 0.00;
LoanSplitSize = 0;
  for (FinLoanSplitWrapper wrap : wrappers)
  {
  if(wrap.FinLoanS.Loan_Amount__c == null){
  wrap.FinLoanS.Loan_Amount__c = 0.00;
  }
   LoanSplitSize = LoanSplitSize + 1;
   AggregateLoanAmount = AggregateLoanAmount + wrap.FinLoanS.Loan_Amount__c;
  }
  

}

 

 
 ////////////////test
 
  
 public void delWrapper()
 {
  Integer toDelPos=-1;
  for (Integer idx=0; idx<wrappers.size(); idx++)
  {
   if (wrappers[idx].ident==toDelIdent)
   {
    toDelPos=idx;
   }
  }
   
  if (-1!=toDelPos)
  {
   wrappers.remove(toDelPos);
  }
 }
 
 //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\Wrapper 2 identical - 2
  public void delWrapper2()
 {
  Integer toDelPos=-1;
  for (Integer idx=0; idx<wrappers2.size(); idx++)
  {
   if (wrappers2[idx].ident2==toDelIdent2)
   {
    toDelPos=idx;
   }
  }
   
  if (-1!=toDelPos)
  {
   wrappers2.remove(toDelPos);
  }
 }
 //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\Wrapper 2 identical - 2
  
 public void addRows()
 {
  for (Integer idx=0; idx<addCount; idx++)
  {
   wrappers.add(new FinLoanSplitWrapper(nextIdent++));
  }
 }

  /* Remove for now, as it has been made redunant. keep for reference incase soemthing goes wrong
 public PageReference save()
 {
  List<Finance_Loan_Split__c> FLS =new List<Finance_Loan_Split__c>();
  for (FinLoanSplitWrapper wrap : wrappers)
  {
   FLS.add(wrap.FinLoanS);
  }
   
  insert FLS;
   
  return new PageReference('/' + Schema.getGlobalDescribe().get('Finance_Loan_Split__c').getDescribe().getKeyPrefix() + '/o');
 }
 */
  
 public class FinLoanSplitWrapper
 {
  public Finance_Loan_Split__c FinLoanS {get; private set;}
  public Integer ident {get; private set;}
   
  public FinLoanSplitWrapper(Integer inIdent)
  {
   ident=inIdent;
   FinLoanS=new Finance_Loan_Split__c(Loan_Split_Number__c=ident);
  }
 }
 
  //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\Wrapper 2 identical - 3
 public void addRows2()
 {
  for (Integer idx=0; idx<addCount2; idx++)
  {
   wrappers2.add(new FinLoanSecurityWrapper(nextIdent2++));
  }
 }
 
 
/* Remove for now, keep for ref
 public PageReference save2()
 {
  List<Finance_Loan_Security__c> LoanSecurity =new List<Finance_Loan_Security__c>();
  for (FinLoanSecurityWrapper wrap : wrappers2)
  {
   LoanSecurity.add(wrap.FinSecS);
  }
   
  insert LoanSecurity;
   
  return new PageReference('/' + Schema.getGlobalDescribe().get('Finance_Loan_Split__c').getDescribe().getKeyPrefix() + '/o');
 }
*/
  
 public class FinLoanSecurityWrapper
 {
  public Finance_Loan_Security__c FinSecS {get; private set;}
  public Integer ident2 {get; private set;}
   
  public FinLoanSecurityWrapper(Integer inIdent)
  {
   ident2=inIdent;
   FinSecS=new Finance_Loan_Security__c(Loan_Security_Number__c=ident2);
  }
 }
  //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\Wrapper 2 identical - 3
     //Wrapper multi add try to implement   

    
    
    
    

 public FinanceNew() {
    Fin = new Finance__c ();
    
     Fin.Finance_Office__c = ApexPages.currentPage().getParameters().get('OffId');
     Fin.Account__c = ApexPages.currentPage().getParameters().get('AccId');
    
    LoanSecurity = new Finance_Loan_Security__c ();
      wrappers=new List<FinLoanSplitWrapper>();
  for (Integer idx=0; idx<1; idx++)
  {
   wrappers.add(new FinLoanSplitWrapper(nextIdent++));
  }
      wrappers2=new List<FinLoanSecurityWrapper>();
  for (Integer idx=0; idx<1; idx++)
  {
   wrappers2.add(new FinLoanSecurityWrapper(nextIdent2++));
  }


      
    }
    
    
    public PageReference saveStandard() {
    
    Fin.Aggregate_Borrowings__c = AggregateLoanAmount;
    
    
     try {  
      upsert Fin;
        
        } catch (Exception e) {     
      
             ApexPages.addMessages(e);         
        }
        
 List<Finance_Loan_Split__c> FLS =new List<Finance_Loan_Split__c>();
  for (FinLoanSplitWrapper wrap : wrappers)
  {
   FLS.add(wrap.FinLoanS);
  }

 List<Finance_Loan_Security__c> LoanSecurity =new List<Finance_Loan_Security__c>();
  for (FinLoanSecurityWrapper wrap : wrappers2)
  {
   LoanSecurity.add(wrap.FinSecS);
  }
  
  for (Finance_Loan_Split__c FinLoanSplit: FLS)
  {
    FinLoanSplit.Finance__c = Fin.id;
   FinLoanSplit.Account__c = Fin.Account__c;
   FinLoanSplit.Office__c = Fin.Finance_Office__c;
  }
  
    for (Finance_Loan_Security__c LoanSec: LoanSecurity)
  {
    LoanSec.Finance__c = Fin.id;
   LoanSec.Account__c = Fin.Account__c;
   LoanSec.Office__c = Fin.Finance_Office__c;
  }            
        
        try { 
        
        upsert FLS;
        upsert LoanSecurity;
       
       
        PageReference pageRef= new PageReference('/apex/DestinyAccount?id='+fin.Account__c+'&Sfdc.override=1');
        return pageRef;
        } catch (Exception e) {     
      
             ApexPages.addMessages(e);         
        }
        
        
        
        return null;
    
    }
    
      
    public PageReference Cancel() {
   
        PageReference pageRef= new PageReference('/apex/DestinyAccount?id='+Fin.account__c+'&Sfdc.override=1');
        return pageRef;
     
    }

 
 
    
}

thank you in advance!
HI,

My requirement is to create an activity while Clicking on Submit Button can anyone please help me with code.

Thanks&Regards,
Abhinav.
HI all,
(System.Trigger.isInsert ||
(lead.Email != System.Trigger.oldMap.
get(lead.Id).Email)))
How can I understand this ?here get() is the method in the oldMap or how many methods are there  in oldMap? and where to use get ()put()set()??orelse we can use where ever we want ??

Please help me ..I am Learning Apex classes and Triggers
 
Hi,

how to add custom button in related list in page layout in salesforce, My button is not showing in avilable buttons, Is this somthing related permission issue. 
public class SalesOrder {
  public Order record{get;set;}
    public SalesOrder (ApexPages.standardcontroller std)
     { 
       record = new Order();           
     } 
  public pagereference dosave(){
      record.QuoteId = ApexPages.currentPage().getParameters().get('quoteID');
       insert record;
       ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM,'Record Created Successfully.Thank you!'));
       pagereference page=new pagereference('/apex/SalesOrder');     
       return page;        
    }     
  public pageReference Cancel(){        
         pagereference page = new pageReference('/apex/QuoteVfPage');
         page.setRedirect(true);
         return page;
     }   
}



here is the test class i have written correct me. i am new to salesforce

@istest
Private class TestSalesOrder{
 Static TestMethod void Dosave(){
  Test.startTest(); 
 PageReference pageRef = Page.SalesOrder;
Test.setCurrentPageReference(pageRef);
  String quoteId;
    if(!test.isrunningtest()) {
      quoteId = ApexPages.currentPage().getParameters().get('quoteID');
      Account a=new Account(Name='test1',Phone='9458383336');
     insert a;
     Order ord=new Order(AccountId=a.id,Name='test',status='draft',EffectiveDate=system.today());
     insert ord;
     }
     else
      {
      }
Test.stopTest();
}
Static TestMethod void Cancel(){
Test.StartTest();
PageReference pageRef = Page.QuoteVfPage;
Test.setCurrentPageReference(pageRef);
}
}
HI, This may seem like an elementary question but I have not seen this explained anywhere in Sales Force docs however I may have overlooked this topic:

Q) Do inactive triggers still get calculated in an organization's overall coverage ?
I was thinkng that since their meta-xml status has changed to "Inactive" , the Apex Test Execution is somehow notified to omit the inactive trigger as part of  the overall coverage thus possibly increasing the organization's overalll code coverage percentage.

Brief Explanation/Reason for my question:
We have to maintain and scrub our list of older triggers and classes which may no longer be  needed  (not sure yet) due to changes in process or due to software upgrades like Non-Profit Starter Pack(which changes the Contact-Account Relationship regarding Contact's Account ID lookup by making this lookup field obsolete since accounts are now regarded as affiliations ).

Thanks much.
Hi All,

How to upload a picture with a record in custom object.
Please help me
Hi,

Is there a way to make the columns in this visualforce page sortable?  It's simply a page that displays the open tasks owned by the current user.

controller:
 
public class tasksController{
    
    List<Task> tk; 
      // toggles the sorting of query from asc<-->desc


    public tasksController(ApexPages.StandardController Controller){
     }  
     
    public List<Task> getResults(){     
        return tk;
    }         
    public PageReference gettk(){
        String userId=UserInfo.getUserId();
        UserId=userId.Substring(0,15);
        tk=[Select Status, Subject, Priority, OwnerId, Owner.Name, WhatId, Response_Needed__c,What.Name, WhoId, Who.Name, ActivityDate from Task WHERE 
             Status != 'Completed' AND (ActivityDate = THIS_WEEK ) AND OwnerId =: UserId ORDER BY ActivityDate DESC LIMIT 25  ];
        return Null; 
    }
}



visualforce page:
 
<apex:page standardController="Task" extensions="tasksController" action="{!gettk}">
<apex:form >
    <html>
    &nbsp;&nbsp;<img src="/img/icon/home32.png"/>
    <font size="5">&nbsp;&nbsp;My Open Tasks Due This Week</font><br></br>

<apex:pageblock >


                    <apex:pageBlockTable value="{!results}" var="tsk">
                                <apex:column >
                                    <apex:outputlink value="/{!tsk.Id}">{!tsk.Subject}</apex:outputLink>
                                    <apex:facet name="header"> Subject </apex:facet>                                                                                                       
                                </apex:column>
                                <apex:column > 
                                    <apex:outputField value="{!tsk.Response_Needed__c}" />
                                    <apex:facet name="header"> Urgency                                      
                                    <span class="helpButton" id="example-title-_help">
                                    <img src="/s.gif" class="helpOrb"/>
                                      <script type="text/javascript">
                                        sfdcPage.setHelp('example-title', 'RED: Task is overdue by 1 day or more or has no due date.  YELLOW: Task is due today.  GREEN: Task is due on some day in the future. ');
                                      </script>
                                    </span>                                                                                                       
                                    </apex:facet>                                                                      
                                </apex:column>                                
                                <apex:column >
                                    <apex:outputLink value="/{!tsk.WhoId}">{!tsk.Who.Name}</apex:outputLink>
                                    <apex:facet name="header"> Name</apex:facet>
                                </apex:column> 
                                <apex:column >
                                    <apex:outputLink value="/{!tsk.OwnerId}">{!tsk.Owner.Name}</apex:outputLink>
                                    <apex:facet name="header"> Assigned To </apex:facet> 
                                </apex:column>
                                <apex:column value="{!tsk.ActivityDate}"/>                                                                                                                                                                                                   
                                <apex:column value="{!tsk.Status}"/>  
                    </apex:pageBlockTable> 
                    
                    
                    <br></br>                 
                    <apex:outputLink target="_blank" value="https://cs15.salesforce.com/00Oe0000000Ta99" id="theLink">View All My Open Tasks</apex:outputLink>

 </apex:pageblock>
                   


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

 
  • December 16, 2014
  • Like
  • 0
I creating an event in salesforce and sending the activity date and time from the UI.

It saving the same time in sandbox.I moved the same to production is showing a time difference of -7 hrs

My time zone for both production and sandbox is the same i.e:(GMT-07:00) Pacific Daylight Time (America/Los_Angeles)

but when i query the activity date and time it is showing the current time.

But in the UI it is displaying the wrong time.