• David Zhu
  • SMARTIE
  • 964 Points
  • Member since 2014

  • Chatter
    Feed
  • 26
    Best Answers
  • 1
    Likes Received
  • 11
    Likes Given
  • 10
    Questions
  • 239
    Replies
I have got a pageblock table with all parents records and all of them has a lineitem button linked to it, now the requirement is to display child records in the same pageblock table under the particular parent recordwhen this button is clicked.Both parent and child belongs to same object and they have self relationship.Thanks in advance
I use Workbench to run some SOQL queries to get data from my ContentDocument table. My first query simply lists all the records: 
"Select Id, Title from ContentDocument"
The number of records matchs what's returned by the SOQL API. However, if I select to include "Deleted and Archived Records" from the console, I see a couple more data. I am new to SFDC so this is a bit strange for me. But that wasn't the strangest part - the strangest part is by accident I ran into some DocumentIDs that were NOT included in the table, but if I search for them specifically, Workbench returns them! 

"Select Id, Title from ContentDocument where Id=<foo>"

I double-checked several times, using Title and ID so it's not my eyes. Plus there are more than 1 records missing.

So I have 2 questions: 
1> What do I need in my SOQL query to get everything from the table? I will only use API for production 
2> Why do I not see some records with a statement that should return everything (I come from vanilla SQL camp)?










 

 
Hi, is there any custom coding that can remove "on behalf of user@yourdomain.com" from the Salesforce alerts and reports email headers? Our email gateway blocks all emails that says mydomain.com generated from other domains. Salesforce admin settings cannot change this and couldnt find a feasible solution.  
hi, i have a scenario

please help me out

i want to change opportunity owner name based on another object field name. 
Example:

In opportunity i have a picklist list field that is realated to custom object. if i select a record in custom object in the custom record name become the opportunity field record name.

here the problem i have to work with three objects one opportunity, custom object and user object.

can any one help to solve this issue
I have the following trigger on Contacts to send an email to one of our managers when a contact 'deactivated', however I don't know how to test the Messaging.SingleEmailMessage() code and my test covereage is not enough:

trigger InactiveNotificationTrigger on Contact (after update) {
    
    for (Contact c : Trigger.new){
        
        if(Trigger.oldMap.get(c.id).Record_Status__c == 'Active' && c.Record_Status__c == 'Inactive'){

            List<ID> ModID = New List<ID>();
            ModID.add(c.LastModifiedById);
            string FullEmailTxt;

            List<User> ModUser = [Select ID, name from user where ID in: ModID];
            for(integer i = 0 ; i < ModUser.size(); i++){
                string emailTxt1 = 'Dear Development and Communications Director, ';
                string emailtxt2 = 'The contact, '+c.FirstName+''+c.LastName+', has been marked inactive by '+ModUser[i].name+' on '+c.LastModifiedDate+'.'; 
                string emailTxt3 = 'To review the contact please follow the link: '+System.URL.getSalesforceBaseUrl().toExternalForm()+'/'+c.Id+'.'; 
                FullEmailTxt = emailTxt1+'\n'+'\n'+emailTxt2+'\n'+'\n'+emailTxt3+'\n'+'\n'+'Cheers!';
            }
            
    
            List<User> DevComMng = [Select ID, email from user where Title = 'DevComm Director'];
// for testing only List<User> DevComMng = [Select ID, email from user where Name = 'System Administrator'];
            for(integer i = 0 ; i < DevComMng.size(); i++){
                
                String[] toAddresses = new String[] {DevComMng[i].email};
                    
                Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
                email.setToAddresses(toAddresses);
                email.setSenderDisplayName('Salesforce Administration');
                email.setSubject('Inactive Contact Allert');
                email.setBccSender(false);
                email.setPlainTextBody(FullEmailTxt);
                email.setSaveAsActivity(false);
                Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
                
            }
            
            Note n = new note();
                n.ParentID = c.id; n.Title = 'Inactive Notification Sent'; n.body = FullEmailTxt;
            insert n;
        }
    }
}

Here the test code I have now:
@isTest
private class TestInactiveNotificationTrigger {

    @isTest static void TestInactiveNotificationTrigger() {
        // Test data setup
        // Create a Board Campaign and assign and insert a current and former board member
        Contact con = new Contact(FirstName='Test',LastName='Contact');
        insert con;
        
        con.Status__c = 'Inactive';
//        con.Inactive_Reason__c = 'Deceased';
        update con;

        // Verify 
        // In this case the inserted contact record should have been updated as GRE Volunteer by the trigger,
        // so verify that we got back an empty search.
        List<ID> nID = New List<ID>();
        nID.add(con.id);
            List<Note> n = [SELECT id FROM Note WHERE ParentID in : nID];
            System.assert( (n.size() == 0), 'Notification Trigger failed.');
        
    }
}
I'm not that familiar create test class yet.  Hope you guys can help me with this.  Can you guys help me?
 
trigger primaryContactOwnership on MRG_Ownership__c (after insert,after update) 
{
    ownerTrigger();
    
    public void ownerTrigger(){
    List<Id> primaryOwnershipIdList = new List<Id>();
    List<Id> relatedPropertyIdList = new List<Id>();

    for(MRG_Ownership__c ownership : Trigger.New)
    {
        if(ownership.Primary_Contact__c == true && (Trigger.Old == null || Trigger.OldMap.get(ownership.Id) == null 
        || Trigger.OldMap.get(ownership.Id).Primary_Contact__c != true)) // To handle null scenario
        {
            primaryOwnershipIdList.add(ownership.Id);
            relatedPropertyIdList.add(ownership.Property__c);
            
            Property__c property= [select id, Primary_Contact__c from Property__c WHERE id =:ownership.Property__c limit 1];
            property.Primary_Contact__c=ownership.contact__c;
            update property;
        }
    }

    List<MRG_Ownership__c> relatedOwnershipList = [Select Id, Primary_Contact__c 
                                                    From MRG_Ownership__c 
                                                    Where Property__c in :relatedPropertyIdList
                                                    And Primary_Contact__c = true
                                                    And Id Not in :primaryOwnershipIdList];

    if(relatedOwnershipList.size() > 0)
    {
        for(MRG_Ownership__c ownership : relatedOwnershipList)
            ownership.Primary_Contact__c = false;

        update relatedOwnershipList;
    }
    
    
    }
}

 
Hi guys,
I have one requirments .Responsible object and contains status and response fields are there.
When the status is equal to accepted or not accepted then i want to give edit access to the user for response field.
How it is possible please help me.
Hi, I have the requirement: 2 tabs from Contacts: 1 of the tab is "Interlocutor" (spanish) and the another one is "Candidatos" both of them from contacts module.
I renamed the contacts for Interlocutor tab.
And for Candidatos one I created a new Tab (from contacts and through Visualforce: with follow code: <apex:enhancedList type="Contact" />)
What I need to do now is to filter the records for all the organization for each tab, I mean, as the origyn of the entire information is contact, i need to sepparate the data for each tab. If the user clicks on "Interlocutor" the system should filter "Automatically" the data from Contact with type = "Interlocutor"; and if the user clicks on the "Candidatos" the system should do the same but for contact type = "Candidato"
I guess this sould be done through visualforce in Candidatos tab, but I dont know how can I do this.
But for the Interlocutor tab, I have no idea! 
Can somebody help me on this subject? Please!!!!
Thanks!
Karelia.-
Is it possiblle to have set up trigger using REST API, when when condition meets, salesforce will callback to my service?
We are creating a service that will notify user when certain data in salesforce changed, the other option, not ideal, is we can have a worker that periodically poll the data to check the changes.
I created a custom field (formula) in order products and need to use it in the calculation formula for a rollup type field in order.
the only fields available in the list of available fields to aggregate are quantity, list price and unit price. Is there a way to access that custom field ?
I have a text field with a date in it (Opt_Out_Date_txt__c), and I'm trying to put that date into a Date-type formula field (Opt_Out_Date_Formula__c). The text field is in MM/DD/YYYY format. Here's what I have:

IF(OR(NOT(ISNULL(Opt_Out_Date_txt__c)), NOT(ISBLANK(Opt_Out_Date_txt__c))), DATEVALUE(RIGHT(Opt_Out_Date_txt__c, 4)+'-'+ LEFT(Opt_Out_Date_txt__c,2)+'-'+RIGHT(LEFT(Opt_Out_Date_txt__c,5),2)), NULL)

This is working fine when the text field is populated, but when it's blank I'm getting a #Error! message in the field (the syntax saves fine).

Any ideas? Thank you!
Hi everyone,

Im trying to generate table of all campaign members with their names and addresses, render as pdf (or html or whatever) but with fixed number of rows and columns per page. The idea is that I need this table to be printed on paper with stickers that could be used on envelopes and sent to those members.
I added custom button on Campaign layout generating the pdf, but Im struggling with the code (Im really no coder btw:). See below code, what I just started but got stuck, this only generates cells in one row... I just used Account and Email fields instead of address otherwise it is same. Could please somebody tell me how to modify to make grid 3x10 fixed? Many thanks

<apex:page standardController="Campaign" showHeader="false" renderAs="pdf" applyBodyTag="false">
  <span style="font-family: Arial Unicode MS">
     <table border="0" width="100%" id="table4">
           <apex:repeat value="{!Campaign.CampaignMembers}" var="line">         
           <td>{!line.Contact.Name}<br/>{!line.Contact.Account}<br/>{!line.Contact.Email}<br/></td>            
        </apex:repeat> 
    </table> 
  </span>  
</apex:page>
Hi every body,

I have followed this steps "https://developer.salesforce.com/page/Force.com_IDE_Installation" to intalled the Eclipes and create project, but i got htis error. Why?

Here is error screenshot:
User-added image
Hi,
 
 Wrote a below trigger after insert and after update for some reasons its not firing please suggest me what might be the issue. 
 
trigger territory_lookup on Lead (After Insert, After Update) 
{
  Try 
  {
 set<id> gid = new set<id>();
 Set<String> gzip = new Set<String>();
 Set<String> gstate = new Set<String>();
 Set<String> gcountry = new Set<String>();
 
 Integer intzip;

 lead ld = [select id,postalcode,state,country from lead where id = :Trigger.newMap.keySet() limit 1];

 intzip=Integer.valueof(ld.postalcode);

  system.debug(intzip);
 
 String ldstate;
 String ldcountry;
 
  ldstate = ld.state;
  ldcountry = ld.country;
  Territory_Lookup__c tl = [select Theater__c,Region__c,Area__c,User__c FROM Territory_Lookup__c
                           where Zip_Start__c <= :intzip and Zip_End__c >= :intzip and
                                 State__c in :gstate and Country__c in :gcountry limit 1];
                                

  list<lead> led = [select id,postalcode,state,country from lead where id = :Trigger.newMap.keySet() limit 1];
 
  for(lead uld : led)
  {
   uld.Territory_Area__c = tl.Area__c;
   uld.Territory_Region__c = tl.Region__c;
   uld.Territory_Theater__c = tl.Theater__c;
   }

  update led;

 }  
     
  catch(Exception ex){
  system.debug(ex);

  
  }    

}

Thanks
Sudhir