• Vaasu
  • NEWBIE
  • 410 Points
  • Member since 2010

  • Chatter
    Feed
  • 13
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 93
    Replies
hello - I have class that adds the Lead ID to a custom object. However, it adds the same ID to very lead when I do a bulk upload because of this line: ldsubs.Lead__c = listOfLeadsSubIDs[0];

I can't figure how how to add the corect Lead Id to every lead inserted via bulk insert. Any assistance would be greatly appreciated. 

public class AddLeadSubmissionToLead {
    
    public static void addLStoLead (List<Lead> leadsFromTrigger) {
        
        Set<String> nameCompany = new Set<String>();
        List<Lead_Submission__c> listOfLeadsSubs = new List<Lead_Submission__c>();
        List<Id> listOfLeadsSubIDs = new List<Id>();
        
        for(Lead nwLead : leadsFromTrigger) {
            listOfLeadsSubIDs.add(nwLead.Id);
            nameCompany.add(nwLead.LastNameStreetAndZipCode__c );
        }
        
        List<Lead_Submission__c> ldSub = [SELECT Id, Lead__c, LastNameStreetAndZipCode__c
                                          FROM Lead_Submission__c 
                                          WHERE LastNameStreetAndZipCode__c =:nameCompany];
        
        System.debug('Lead Submission Found ' + ldSub);
        
        for(Lead_Submission__c ldsubs : ldSub) {
            if(ldsubs.Lead__c == null && !ldSub.isEmpty()) {
                ldsubs.Lead__c = listOfLeadsSubIDs[0];
                listOfLeadsSubs.add(ldsubs);
            }
        }
        update listOfLeadsSubs;
    }
}
I have added a visualforce page w/ tabs as a section on an account page. Records can be updated. \

section with tabs

However, when I hit the save button, it brings up the entire salesforce page within the section. How can I have it return the original visualforce page in the sectionpage within a section?

Hi,
I need to run some verifications in trigger "before update" against a remote API and perform future actions based on its response . I found that Apex class function cannot return any response due to synchronous / asynchronous issues between triggers and HttpResponse. Is there any way to go around?

public with sharing class Ctrl_myWrapper{

    public Id SaleBillId {get; set;}
    public list<ProductInvoiceWrapper> ProductsWrapped {get ; set; }
    public List<Product_Invoice__c> Like_Products { get; set; }
    public String Name { get; set; }
    Sale_Bill__c sb = new Sale_Bill__c();
    
    public Ctrl_myWrapper(ApexPages.StandardController controller) {
        
        Id SaleBillId = controller.getRecord().Id;
        Sale_Bill__c sb = [Select id,name from Sale_Bill__c where id = :SaleBillId Limit 1];
        ProductsWrapped = new List<ProductInvoiceWrapper>();
        Like_Products = new List<Product_Invoice__c>();
    }

    
    
    

    

    public PageReference searchProduct()
    {
        String likeName = '%'+Name+'%';
        Like_Products = [Select Id,Name,Product_Name__c,Quantity_Remaining__c,SellingPricePerUnit__c  From Product_Invoice__c where Product_Name__c Like :likeName];
        ProductsWrapped.clear();
        for(Product_Invoice__c p : Like_Products )
        {
            ProductsWrapped.add(new ProductInvoiceWrapper(p));
        }
        return null;
    }
    
    public PageReference selectedProducts()
    {
        List<Sale_Transaction__c> newSaleTransactions = new List<Sale_Transaction__c>();
        for(ProductInvoiceWrapper p : ProductsWrapped)
        {
            if(p.selected)
            {
                Sale_Transaction__c st = new Sale_Transaction__c();
                st.Bill_ID__c = sb.Id ;
                st.Product_Invoice__c = p.pinv.Id;
                st.Quantity__c = p.Quantity;
                newSaleTransactions.add(st);
            }
        }
        insert newSaleTransactions;
        return null;
    }

    public class ProductInvoiceWrapper{
    
        public Product_Invoice__c pinv {get; set;}
        public Boolean selected {get; set;}
        public Integer Quantity {get; set;}
        public ProductInvoiceWrapper(Product_Invoice__c a) 
        {
            this.pinv = a;
            selected = false;
            this.Quantity = 0;
        }
    
    
    }



}
Error : Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Bill_ID]: [Bill_ID]
Error is in expression '{!selectedProducts}' in component <apex:commandButton> in page my_wrapper_demo: Class.Ctrl_myWrapper.selectedProducts: line 49, column 1

Sale_Transaction__c is a junction object between Product__Invoice__c and Sale_bill__c

Please do help

Thanks in advance
Allada Yeshwanth 
 
Hi, the Validation Rules look like they can get record-specific, but even though Validation Rules appear as a related list under the object customization screen, they cannot, or I'm not seeing how, you can reference them to just apply to specific fields and not the entire record.  I have an object that a large group of people have access to, but I only want the owner of that specific record to be able to change one of the fields, or the validation rule pops up.  

The validation rule that was sorta working was:
$User.Id <> OwnerId
And this worked but applied to all changes on the record while I just want it to apply to a specific field.  Any suggestions?
 
Hi everyone!

I'm not finding "$user" (minus the quotes) in the 3000+ page Salesforce Developer guide, nor am I finding it in this forum.  I know that certain calls can be made with the $User.ID, or $User.XYZ?  I'd like to know what a comprehensive list of those looked like so I coudl use them in a Validation Rule that I'm working on and just to have them for reference.  Any help appreciated!  They must be somewhere!

Hello,

 

I am sending a POST request to "https://webto.salesforce.com/servlet/servlet.WebToLead".

This works fine with a demo account i've setup. What I am sending looks like this: 


 

var options = {
    method: "POST",
    url: "https://webto.salesforce.com/servlet/servlet.WebToLead",
    qs: { encoding: "UTF-8" },
    headers: {
      "Cache-Control": "no-cache",
      "Content-Type": "application/x-www-form-urlencoded"
    },
    form: {
      oid: 'HIDDEN',
      lead_source: 'Website',
     '00N6A000001jcP1': 'HIDDEN',
     retURL: 'https://HIDDEN.com/thank-you/',
     first_name: 'teageaook',
     last_name: 'eao',
     email: 'test+500@me.com',
     phone: '515315315',
     '00N6A000001kwvX': '2-9',
     '00N6A000001kfX1': 'get_demo',
     '00N6A000001lGKW': 'en'
    }
  }

This works just fine on my demo salesforce account, but when i changed hte OID to my client's salesforce instance, it does not work. Any ideas?

Laslty, would just like to mention that I am now doing this via an API call from a server as opposed to a regular <form> but the fact that it worked on my install makes me wonder if it's just a configuration issue.
 
<apex:page StandardController="DemoRequest__c" showHeader="false" sidebar="false">
  <script type="text/javascript"> 
  if({!ApprovalStatus__c} == "New Request" ) {
      setTimeout(function() {
        alert("Please click Submit for Approval button");
      },750);
    }
    
  </script>
</apex:page>

 
Hi All,

First time playing around with Developer Console. I'm trying to delete all Tasks that have been created by a user (85,000 records). I can't use Data Loader since it will max out the number of records I want to delete so instead, I was able to create a query to find all the records. I'm now trying to use APEX Code to delete all the records listed and am having some trouble.

I am trying to find all tasks that were created by a user where the subject line does not equal "Initial Lead Notification Sent" or "Secondary Lead Notification Sent". Once its executed and I have a list, I would like to delete all records. Here's what I have so far:

APEX CODE
// fetching all Tasks Records via SOQL
List<task> TaskList = new List<task>();
TaskList = [SELECT Id, subject, WhoID, ActivityDate, FROM
   task WHERE CreatedByID = '0051400000Bazbn' AND subject != 'Initial Lead Notification Sent' AND subject != 'Secondary Lead Notification Sent'];
// SOQL query for given criteria

// Delete the fetched records
delete [SELECT Id FROM TaskList LIMIT 1000];

SOQL
select id, subject, WhoID, ActivityDate FROM task where CreatedByID = '0051400000Bazbn' AND subject != 'Initial Lead Notification Sent' AND subject != 'Secondary Lead Notification Sent'

Error:
Row 3 column 10, Unexpected token "=".
Hello Friends,

Anyone Please help!
//JavaScript Code
component.set("v.SelectedProcessRecords",response.getReturnValue());
console.log('v.SelectedProcessRecords ----> '+component.get("v.SelectedProcessRecords"));

I am getting this in console log.

v.SelectedProcessRecords ----> [{"Id":"a017F00000JjtWDQAZ","Name":"Test Process Step","Tmp__Team_Assigned__c":false,
"Tmp__Assigned_To_Role__c":"Accounting Manager","Tmp__Completed_Date__c":"2018-02-09","Tmp__Status__c":"Completed"}]

I want to remove 'Tmp__' from all keys if it is present somewhere, and i want a new array of object like this.
[{"Id":"a017F00000JjtWDQAZ","Name":"Test Process Step","Team_Assigned__c":false,
"Assigned_To_Role__c":"Accounting Manager","Completed_Date__c":"2018-02-09","Status__c":"Completed"}]

Any help would be greatly appreciated.

I want to create a button thatt would add myself as a case team member and fill out the appropriate fields.  What is the difference between MemberId and ParentId?

  • August 27, 2013
  • Like
  • 0

I have certain list views on the custom objects which I want only certain group of people to see. For example I have two list views LV1 and LV2. Certain group of users should only see LV1 and certain others should see only LV2.I have created two public groups and restricted the visibility to 'Certain groups' but still the users are able to see both the list views LV1 and LV2.

 

Upon investigation I found that the users have system permission 'Manage Public List Views' in their profile.

 

What can I do to restrict the users from viewing the list views they are not supposed to see?

Hi Guys,

 

i wrote a trigger which  is doing the job and i want  to know if there is a room to improve the code.

 

 

trigger aprUpdate on Annual_Progress_Report__c (after insert) {

Integer SC = 0;
    
//get previous month/year value
list<Annual_Progress_Report__c> lstname=new list<Annual_Progress_Report__c>();
for(Annual_Progress_Report__c a:[select id, Health_assessment_progress_score__c from Annual_Progress_Report__c order by id desc Limit 2])
 {
 
  // Assign value to temp variable
 SC = Integer.valueOf(a.Health_assessment_progress_score__c);    
 }    
Annual_Progress_Report__c APR=trigger.new[0];
Annual_Progress_Report__c updRP=[select id from Annual_Progress_Report__c where id = :APR.id];
updRP.Health_assessment_progress_score2__c= SC;
    //update the new value
    update updRP;
    

}

 

 

thanks,

HI,

 

   I would like to know is there any option to get the solution category for the solution in solution custom fields by using formula fields or any thing.

 

And also can we write triggers for categorynode/categorydata objects in salesforce.

 

 

  • May 03, 2012
  • Like
  • 0

Hi all,


           Iam struggling from the past 3 days to find the application name in the apex controller.Any help would be appreciated.


Thanks,

Srinivas

 

  • July 26, 2010
  • Like
  • 0
We have been doing work to connect our drupal website with salesforce and have connected 3 other Connected Apps for localhost, Develop, and Staging environments. Develop and Staging are both on Pantheon hosting.  All were available to connect within a few minutes of setting up and authenticated fine. Today we were deploying to production environment and we setup the production Connected App in salesforce, but we are not authenticating here for some reason. It is also hosted on Pantheon and has the same codebase as all the other environments.  The setup at salesforce for all the apps are exactly the same except for the oauth callback url and name of app.  It is labeled 'Production_API_Connection'.  Any ideas on what is going on? 

Error:
error=invalid_client_id&error_description=client%20identifier%20invalid
hello - I have class that adds the Lead ID to a custom object. However, it adds the same ID to very lead when I do a bulk upload because of this line: ldsubs.Lead__c = listOfLeadsSubIDs[0];

I can't figure how how to add the corect Lead Id to every lead inserted via bulk insert. Any assistance would be greatly appreciated. 

public class AddLeadSubmissionToLead {
    
    public static void addLStoLead (List<Lead> leadsFromTrigger) {
        
        Set<String> nameCompany = new Set<String>();
        List<Lead_Submission__c> listOfLeadsSubs = new List<Lead_Submission__c>();
        List<Id> listOfLeadsSubIDs = new List<Id>();
        
        for(Lead nwLead : leadsFromTrigger) {
            listOfLeadsSubIDs.add(nwLead.Id);
            nameCompany.add(nwLead.LastNameStreetAndZipCode__c );
        }
        
        List<Lead_Submission__c> ldSub = [SELECT Id, Lead__c, LastNameStreetAndZipCode__c
                                          FROM Lead_Submission__c 
                                          WHERE LastNameStreetAndZipCode__c =:nameCompany];
        
        System.debug('Lead Submission Found ' + ldSub);
        
        for(Lead_Submission__c ldsubs : ldSub) {
            if(ldsubs.Lead__c == null && !ldSub.isEmpty()) {
                ldsubs.Lead__c = listOfLeadsSubIDs[0];
                listOfLeadsSubs.add(ldsubs);
            }
        }
        update listOfLeadsSubs;
    }
}
I need to upload a csv file from Apex to a global bucket in s3 and keep the URL.

Below described is my approach for the same using AWS request signing process.
 
public static void uploadCSVFileToS3(String csvFile, String filename, String awsAccessKey, String awsSecretKey, String bucketname){
        try{
            String formattedDateString = Datetime.now().format('EEE, dd MMM yyyy HH:mm:ss');
            String requestType = 'PUT';
            String contentType = 'text/csv';
            String filePath = 'https://s3.amazonaws.com' + '/'+ bucketname + '/' + 'demo.csv';
            
            HttpRequest req = new HttpRequest();
            req.setMethod(requestType);
            req.setHeader('Host','https://s3.amazonaws.com');
            req.setEndpoint(filePath);
            req.setHeader('Content-Length', String.valueOf(csvFile.length()));
            req.setHeader('Content-Type', contentType);
            req.setHeader('Date', formattedDateString);
            req.setHeader('ACL', 'public-read-write');
            Blob CSV = Blob.valueof(csvFile);
            req.setBodyAsBlob(CSV);
            
            String auth = createAuthHeader(requestType, contentType, filename, formattedDateString, bucketname, awsAccessKey, awsSecretKey);
            
            Http http = new Http();
            
            HTTPResponse res = http.send(req);
            System.debug('RESPONSE STRING: ' + res.toString());
            System.debug('RESPONSE STATUS: ' + res.getStatus());
            System.debug('STATUS_CODE: ' + res.getStatusCode());
        } catch(System.CalloutException e) {
            system.debug('AWS Service Callout Exception: ' + e.getMessage());
            system.debug('AWS Service Callout Exception: ' + e.getCause());
            system.debug('Exception: ' + e.getStackTraceString());
        } catch(Exception e) {
            system.debug('Exception: ' + e.getMessage());
            system.debug('Exception: ' + e.getStackTraceString());
        }  
    }

    public static String createAuthHeader(String method, String contentType, String filename, String formattedDateString, String bucket, String key, String secret){
        string auth;
        
        String stringToSign = method+'\n'+bucket+'/'+filename+'\n';
        Blob mac = Crypto.generateMac('HmacSHA1', blob.valueof(stringToSign), blob.valueof(secret));
        String sig = EncodingUtil.base64Encode(mac);
        auth = 'AWS' + ' ' + key + ':' + sig;
        
        
        return auth;
    }

I have followed the link here (https://developer.salesforce.com/forums/?id=906F0000000BMDFIA4) for the approach used.

I am able to upload the file to same bucket from ruby or javascript using the aws sdk's, but it is giving me a response code of 400 (Bad Request).
I think this is a problem of the process of signing request.

It will be highly appreciated if someone can help me here.
I am writing a batch class to send the emails based on certian criteria. I see that the parameters are passed right, no errors, but I end up receiving multiple duplicate emails when I run it. Here is the code

Two issues that I am trying to resolve

1. When there are less than 10 emails to be sent out, the code works fine, but sends duplicate emails
2. When there are more than more than 10 emails in the list that I am sending to, I get an error saying 'FATAL_ERROR|System.LimitException: Too many Email Invocations: 11'
 
global void execute(Database.BatchableContext BC, List<OrderApi__Badge__c> scope){
     
		system.debug('scope'+scope.size());  
     for(Order_c fbdge : [select Id,Description__c,Type__c,Contact__c,
 			ontact__r.Date__c,Contact__r.FirstName,Contact__r.LastName,
        	Contact__r.Years__c,Contact__r.Email,Active__c,Type__r.Name
From Order__c where (Type__r.Name ='A' or Type__r.Name ='B') and OrderApi__Is_Active__c =true 
                                and Date__c = 2017-06-30
        			  			and Contact__r.Date__c = 2017-06-30 and Contact__r.Years__c<10.00
                                and (Contact__r.Cat__c <> ' Life')]){
                                          system.debug('create list');
                                     bge.add(fbdge);
                                     system.debug('Bge' +bge.add(fbdge));
                                     contact.put(fbdge.Contact__c, fbdge.Contact__r.Email);
                                  
                                      }
     if(contact.size()>0){
         
     			 List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
                                 List<String> email = new List<String>();
                                 List<String> ccemail = new List<String>();
          Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); 	
         try{
             for(Id ids : contact.keyset()){

          email.clear();
                 for(Order__c bdg :[select id,Contact__r.Email from Order__c where Contact__r.Email=:contact.get(ids) LIMIT 1]){
                     email.add(bdg.Contact__r.Email);
                     system.debug('size of emails' +email.size());
                 }
                                                                           
    Contact c = [select id, Email from Contact where email <> null limit 1];
     							
     EmailTemplate templateId = [Select id from EmailTemplate where name = 'Test'];
                                                            
                                            system.debug(email);
                                            system.debug(email.size());
                                            mail.setToAddresses(email);
                                            mail.setccAddresses(ccemail);
                                       
                                           	mail.setTargetObjectId(c.Id);
           									mail.setTreatTargetObjectAsRecipient(false);
                                           	mail.setTemplateID(templateId.Id); 
                                            mail.setSaveAsActivity(false); 
                                            mails.add(mail);
                                            system.debug(mail);
                         
     							//	messages.add(mail);
    if(mails.size())>0{                        
     Messaging.sendEmail(mails);
        						system.debug('mails');
        system.debug(mails.size());
           
 }        
}         
         } catch(exception ex){
             system.debug('Exception occured'+ex.getMessage());
         }
     }
 }
 global void finish(Database.BatchableContext BC){
    }
}

 
  • February 16, 2018
  • Like
  • 0
I have added a visualforce page w/ tabs as a section on an account page. Records can be updated. \

section with tabs

However, when I hit the save button, it brings up the entire salesforce page within the section. How can I have it return the original visualforce page in the sectionpage within a section?
Hello,
I was stupid and edited a process builder flow in visual flow which of course means that I can no longer see the flow in either. I tried using workbench to see the flow and its versions so I can at least make it inactive (since it is stopping all my other flows from running) but it doesn't show up. All my other flows are there but that one is missing. When I use Rest Explorer, I can find the active version of the flow since I have the id but I don't know the ids for the inactive versions so I can't delete anything or deactivate anything.

Can someone please tell me how I can either deactive an active version through Rest Explorer or how to find the ids of the inactive versions of the flow when it won't show up in workbench metadeta?

Thanks.
  • February 16, 2018
  • Like
  • 0
I am trying to create an additional record type for Person Accounts. According to the Release Notes: "When person accounts are enabled, a default person account record type is automatically created. You can modify this default person account record type, and you can also add more person account record types."

When I make a new Record Type on the Account object, there is no choice for Business Account or Personal Account, and any new Record Type I create has the isPersonType field set to false.

Is there a declarative way to create a new Record Type for Person Accounts?
 

Hi,
I need to run some verifications in trigger "before update" against a remote API and perform future actions based on its response . I found that Apex class function cannot return any response due to synchronous / asynchronous issues between triggers and HttpResponse. Is there any way to go around?