• Prateek Bhatt
  • NEWBIE
  • 25 Points
  • Member since 2014
  • Salesforce PD1 certified developer
  • Metacube

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 9
    Replies
I have a button update as below

<apex:commandButton id="UpdateButton" value="UPDATE" styleClass="UpdateButton" onclick="CheckAcceptOnUpdate()" action="{!doSave}"/>

on the apex class the do save does the update to the database perfectly.

But now I want that update to work only if accept checkbox is checked so I have written the onclick function

function CheckAcceptOnUpdate()
{


var accept = document.getElementById('{!$Component.formterm.terms}').checked;


  if(accept==false)
  {
  
  alert("please accept terms");
  
  
  }

}

The popup is working as expected and it is not preventing the update function.the action dosave is being called. If the accept checkbox is not checked, it should only show the pop up and do nothing else.

 
  • April 26, 2017
  • Like
  • 0
I am not able to convert the rtaimage URL into the base64 encoding URL. Please have a look into below code and provide me the help on below issue. 

HttpRequest req = new HttpRequest();
String url = system.URL.getSalesforceBaseUrl().toExternalForm() + '/secur/frontdoor.jsp?sessionId=' + UserInfo.getSessionId() + '&retURL="/servlet/rtaImage?eid=5007000000uEmHK&feoid=00N70000002UTY9&refid=0EMc0000000DDdk"';
req.setEndpoint(url);
req.setHeader('Authorization', 'OAuth '+UserInfo.getSessionId());
req.setMethod('GET');
Http binding = new Http();
HttpResponse res = binding.send(req);
Blob image = res.getBodyAsBlob();
String base64Encode = EncodingUtil.base64Encode(image); 


String caseDescription = '<img alt="" src="data:' + res.getHeader('Content-Type') + ';' + base64Encode + '"></img>';
CaseDescRichTextStage__c stgObj = new CaseDescRichTextStage__c(CaseNumber__c = 'C-121', CaseDescBase64__c = caseDescription);

I am getting the below error while save this record with base64Encode URL.

Invalid data specified, the provided data does not seem to be a valid image: [B@254f39ef

I have also checked the value of res.getHeader('Content-Type'). It's giving me "text/html;charset=UTF-8" instead of 'image/png'
I have a button update as below

<apex:commandButton id="UpdateButton" value="UPDATE" styleClass="UpdateButton" onclick="CheckAcceptOnUpdate()" action="{!doSave}"/>

on the apex class the do save does the update to the database perfectly.

But now I want that update to work only if accept checkbox is checked so I have written the onclick function

function CheckAcceptOnUpdate()
{


var accept = document.getElementById('{!$Component.formterm.terms}').checked;


  if(accept==false)
  {
  
  alert("please accept terms");
  
  
  }

}

The popup is working as expected and it is not preventing the update function.the action dosave is being called. If the accept checkbox is not checked, it should only show the pop up and do nothing else.

 
  • April 26, 2017
  • Like
  • 0
Please tell me How to query all Chatter Files attached to a record by PHP.

=== Sample Code ===
$sforce_connection = new SforcePartnerClient();  
$soap_client = $sforce_connection->createConnection(PARTNER_WSDL_FILE, null);  
echo("ConectClassOK<br>");

try {  
    $login = $sforce_connection->login(LOGIN_ID, LOGIN_PASS); 
    $login_info = get_object_vars($login);  
    $session_id = $login_info['sessionId'];  
    echo "LoingOK -> Session Id : " . $session_id . "<br>";  
} catch (Exception $e) {  
    var_dump($e); 
}

try{
    $query = 'SELECT PostCount, ParentId FROM ChatterActivity';
    $response = $sforce_connection->query($query);
    $queryResult = new QueryResult($response);

    for ($queryResult->rewind(); $queryResult->pointer < $queryResult->size; $queryResult->next()) {
        print_r($queryResult->current()->ParentId);
    }

    ・・・ The point which isn't understood ・・・
======
Hi, 
I have created a Trigger on the Child Object having 2 parent objects. Below is the Relationship
  • evt__Attendee__c - Child Object 
  • evt__Special_Event__c - Parent Object
  • Contacts - Parent Object 
Both the parents Object (Special Event and Contacts) has a realtionship with the child Object (Attendee)

So, I want to do is to create a trigger after the attendee Record is created. The tirgger will look for some fields on the Special Events and Contacts and if the criteria is met then update some fields on the Contact Object.

I have created the trigger but it looks like not working. It is not giving me any error also. 

Below is the code of the Trigger.  


 trigger AttendeeITK on evt__Attendee__c (after insert)
{

    List<Contact> contactsToUpdate = new List<Contact>();
    Set<Id> ContactIds = new Set<Id>();
    Set<Id> SEIds = new Set<Id>();

    for(evt__Attendee__c attendee :trigger.new)
    {
       ContactIds.add(attendee.evt__Contact__c);
       SEIds.add(attendee.evt__Event__c);
    }
     
    Map<Id, Contact> ContactMap = new Map<Id, Contact>([SELECT Id,Assignment_Queue__c,Law_Student__c,Stage__c,Contact_Type__c FROM Contact WHERE Id IN :ContactIds]);
    Map<Id, evt__Special_Event__c> SEMap = new Map<Id, evt__Special_Event__c>([SELECT Id,Non_Recruitment_Event__c FROM evt__Special_Event__c WHERE Id IN :SEIds]);
    
    for(evt__Attendee__c attendee : System.Trigger.New)
    {          

        Contact tempContact = ContactMap.get(attendee.evt__Contact__c);
        evt__Special_Event__c tempSE = SEMap.get(attendee.evt__Event__c);
             
        if (tempSE.Non_Recruitment_Event__c == False && 
            tempContact.Assignment_Queue__c == null && 
            tempContact.Law_Student__c == False && 
            tempContact.Stage__c == null &&
            tempContact.Ownerid == '005G0000002wYvi' &&
            (tempContact.Contact_Type__c != 'Faculty' || tempContact.Contact_Type__c == null))   
        {
           
            tempContact.Assignment_Queue__c = 'Inside Track Graduate';
            tempContact.Stage__c = 'New';
            tempContact.Lead_Status__c = 'Not Attempted';
            tempContact.Contact_Type__c = 'Prospect';
            tempContact.Most_Recent_Inquiry_Date__c = date.today();
            tempContact.Non_Law_Student__c = True;
            contactsToUpdate.add(tempContact);
        }               
    }
     
          update contactsToUpdate; 


I will really appreciate if somebody can help me in developing the right code. 

Thanks 
Hi -

I'm trying to set the Corresponding_Sales_VP__c trigger to a specific user record by using their ID. How do i do it?
 
trigger Set_Corresponding_VP on Compensation_Request__c(after insert) {
	List<Compensation_Request__c> requestsToUpdate = new List<Compensation_Request__c>();
    for(Compensation_Request__c reqs : Trigger.new){
        reqs.Corresponding_Sales_VP__c = //User Record with id 005j000000FmuFu
            requestsToUpdate.add(reqs);
    }
    update requestsToUpdate;
}

 
Hi all,
Can we make the Role field as madetory, While creating user. Actually it shows as madatory but it is not madatory. Can anyhelp how we can make Role field as mandatory other than using validation rule(If I'm wrong correct me.)

Thanks in advance,

Regrads,
mac.
I have a database with an object Voter_File_TX with over 15 million records and have over 700,000 contacts. I need to connect records that have the same First Name, Last Name, and Zipcode across these two via a look up field. 

I had to write a batch apex class that I execute anonymously beacuse of the enormous size of my database. I was told that the only way to do this is to do a batch class that will allow me to query more than 50,000 records at a time in order to match them up against each other. I was able to do this and have them connected in my sandbox where I do not have 15 million records.

However when I ran this into my production enviroment it failed because of SF limit of of 10,000 DML, or ability to change records, at a time. I was then also told that I need to write a batch class within this batch class in order to get over this limit as well. 

Can you please help me out with this I am stuck with this part. 

Below is the Apex Batch Class code. 
 
global class UpdateVoterFileonContacts implements Database.Batchable<sObject>{
    global Database.QueryLocator start(Database.BatchableContext BC){
        String query = ' Select ID,First_Name__c, Last_Name__c,Zipcode__c from Voter_File_TX__c';
        return Database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext info, List<Voter_File_TX__c> scope){
        Set<String> set_Str = new Set<string>();
        Map<String,Contact> mp_Cont;

        for(Contact Cont : [Select ID,FirstName,LastName,MailingPostalCode, Voter_File_ID__c From Contact where Contact.voter_File_ID__c = null AND Contact.RNC_ID__c != null LIMIT 50000] ){
            if(mp_Cont==null){
                mp_Cont = new Map<String,Contact>();
            }
            mp_Cont.put(Cont.FirstName +''+ Cont.LastName +''+Cont.MailingPostalCode,Cont);
        }
        for(Voter_File_TX__c VoterList : scope){
            if(mp_Cont!=null && mp_Cont.containsKey(VoterList.First_Name__c +''+ VoterList.Last_Name__c+''+ VoterList.Zipcode__c))
            
            {
                mp_Cont.get(VoterList.First_Name__c +''+ VoterList.Last_Name__c +''+ VoterList.Zipcode__c).Voter_File_ID__c = VoterList.id;
            }
        }
        /* if(mp_Cont!=null && mp_Cont.values()!=null){
            update mp_Cont.values();
        }
        */
        
        if(!mp_Cont.isEmpty()){
            update mp_Cont.values();
        }
    }
    
    global void finish(Database.BatchableContext info){
        
    }
}


I was told that I need to add this type of call to my apex code but I am not sure where how this would transalte into my apex batch class code because I am already currently writting an apex batch class and because i do not know where exactly to add it. 

 

Example Code to add: 

List abc = [Select Id from Contact where Amount =100]; 
for(i=0; i<=abc.size(); i++) 
{ 
List a = abc[i]; 
a.add(abc); 
}

Can anyone please help implment this or tell me of another way wherre I can get around Salesforce govern limit of only updating 10,000 records at a time?

Thanks!