• R Z Khan
  • SMARTIE
  • 860 Points
  • Member since 2014
  • Salesforce Developer

  • Chatter
    Feed
  • 24
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 230
    Replies
Hello,

We've been receiving these emails since last few days, but are not sure what it is related to. The full error message is pasted below. Looking for some assistance here. Thanks.

Failed to invoke future method 'public static void podSwitchboard(Id)' on class 'et4ae5.phoenixSendControl' for job id '7071600002ukS2v'
caused by: System.JSONException: Unexpected character ('e' (code 101)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at input location [1,2]
 
Dear Gurus,

I need to make POST request.

This is the JSON format for POST

{"products":[{"id":1,"quantity":1}],"desc":"infomation"}

*
Blob headerValue = Blob.valueOf(username + ':' + password);
String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);

Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('http://*******:*****/prod/');
request.setMethod('POST');
request.setHeader('Authorization', authorizationHeader);
request.setHeader('Content-Type', 'application/json;charset=UTF-8');
request.setBody('{"products":[{"id":1,"quantity":1}],"user_id":"user11"}');
HttpResponse response = http.send(request);
//if (response.getStatusCode() != 201) {
//    System.debug('The status code returned was not expected: ' +
//        response.getStatusCode() + ' ' + response.getStatus());
//} else {
    System.debug(response.getBody());

This works well.But I want to replace id and quantity with Integar variable.

Please guide me.

Thanks,
Raghu
 
I tried starting the Release Spring 2016 trailhead and when I wanted to answer the challenge questions, it asked me to log into trailhead. I was already logged into the Developer's Community. I clicked on the loggin button and it would not let me login telling me to contact my admin. I am the admin! I can do these trailheads if it's not letting me log in. Any ideas why?
Hello, I earned badges for the Cultivate Equality at Work on Wednesday (with Trailhead account linked to my Salesforce email address - John Hislop 8) and the badges are not lighting on my profile - can you direct me to where I can get this fixed? Thanks!
 Hi,

I am using custom settings (Cloneaccounts__c ) to inlcude field API name  so they shoud not be cloned. there are few fields where api name is more than 40 characters and i am not able to save them. I created a field "Fieldname" on custom settings (Cloneaccounts__c ) so i can save fields api name in it. But how do i modify this controller to read the value of CloneAccounts__c field "Fieldname"
public with sharing class CloneaccController {

    public account objaccount {get;set;}        
    public string accountID;                        
   
    private account objNewaccount;
    private string queryString = '';
    public string strPrevCurrency {get;set;}
    Map<String, Schema.SObjectField> mapaccountFields;
    set<String> setexfields = new set<String>();

    public CloneaccController(ApexPages.StandardController controller) 
    {
                      
        accountID = ApexPages.currentPage().getParameters().get('id');
        
        
        if(accountID != null)
        { 
                mapaccountFields = Schema.SObjectType.account.fields.getMap() ;
                 List<Cloneaccounts__c > lstexfields = Cloneaccounts__c.getall().values();
                 
            for( Cloneaccounts__c exfield: lstexfields){
                setexfields.add(exfield.Name.toLoweraccount());
            }
          
            for(String s: mapaccountFields.keyset()){
                if(!setexfields.contains(s)){
                    if(queryString == ''){
                        queryString += s;
                    }else{
                        queryString += ',' + s;
                    }
                }
            }
                
                
       objnewaccount = Database.Query('Select ' + queryString + ' From account where id= \'' + String.escapeSingleQuotes(accountID) + '\'');   
                  
       objaccount = objNewaccount.clone(false,true,false,false);
             
        } 
 
         }
        
         public PageReference save()
    {
         insert objaccount;
        return new PageReference('/'+objaccount.id);
        
    }  
           
    }

Please help
I'm probably overlooking something simple, but in attempting to postback with a apex:selectList with a size set to 1, nothing happens.  Ever.

I got frustrated and started a brand new visualforce page that exactly mimicked the one found here: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_selectList.htm

That worked as expected. (The rerender was correct when selecting items from the selectList.)

Then I tweaked it ever so slightly to look like this:

First, the page:
<apex:page controller="sampleCon">
    <apex:form>
        <apex:selectList value="{!countries}" size="1" >
            <apex:selectOptions value="{!items}"/>
        </apex:selectList><p/>

        <apex:commandButton id="thisButton" value="{!countLabel}" action="{!test}" rerender="thisButton"/>

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

Now my controller:
public class sampleCon {
        String[] countries = new String[]{};
        public String countLabel {get; set;}

        private Integer iClicks {get; set;}
             
        public sampleCon() {
        	iClicks = 1;
        	countLabel = 'Test ' + iClicks;
        }

        public PageReference test() {
        	iClicks++;
        	countLabel = 'Test ' + iClicks;
            return null;
        }
             
        public List<SelectOption> getItems() {
            List<SelectOption> options = new List<SelectOption>();
            options.add(new SelectOption('US','US'));
            options.add(new SelectOption('CANADA','Canada'));
            options.add(new SelectOption('MEXICO','Mexico'));
            return options;
        }
             
        public String[] getCountries() {
            return countries;
        }
             
        public void setCountries(String[] countries) {
            this.countries = countries;
        }      
    }

You'll see that clicking the commandButton does absolutely nothing to the label, nothing changes.  However, if you simply remove the size="1" attribute from the selectList everything will function perfectly. (At least that's what I'm seeing.)

Can anyone else verify, (or refute) this?
 
Source Object - Activity
Source Field - FT_Emp__c
Destination Object - Contact
Destination Field - Employees__c
trigger Update_employee_count_in_contact on Task (after insert, after update) {
    // set up lists you will need
    List<Contact> consToUpdate = new List<Contact>();    
    
    Map<Id, Task> taskMap = new Map<Id, Task>();

    // go through the list of tasks that were inserted
    for (Task t: Trigger.New)
    {
            taskMap.put(t.WhoId, t);
    }
    
    if (taskMap.size() > 0)
    {
        // get all of the contacts related to the tasks
        // Code logic to update Employees__c field of Contact field
        .
        .
        .
        
        if (consToUpdate.size() > 0)
        {
            update consToUpdate;
        }
    }
}

I want Employees__c to be equal to FT_Emp__c when FT_Emp__c is updated. 

Can anybody help me complete the above the code snippet?
Hello,

I have a Visualforce page that is using a tab panel and contains 5 individual tabs right now. On tab 5 I'm displaying a few fields using a combo of apex:repeat and a fieldset to limit what is shown. I've included apex:commandbuttons for edit and save on this tab.

What I'd like to have happen is when people click the Edit button people are sent to a second VF page (an edit page basically) i've created that contains only inputfields bounded by the same fieldset I mentioned above.

I've tested the second VF page manually and it works well. The only thing I'm missing is how to send users from the first VF page to the second one when they hit that Edit button.

Any ideas?

Thanks,

Mike
I have a batch class that runs once a day to send me emails.
global class getCreatedLeadsSummary implements Database.Batchable<AggregateResult>, Database.Stateful {
    public string leadSummary;
    global Iterable<AggregateResult> start(Database.batchableContext info){
        // just instantiate the new iterable here and return
        return new AggregateResultIterable();
    }

    global void execute(Database.BatchableContext BC, List<AggregateResult> scope)
    {
        try
        {
            leadSummary = '<table bgcolor="silver" border="2" cellpadding="2"><tr><td><b>Lead Source</b></td><td><b>Count</b></td></tr>';
            for(AggregateResult ar: scope)
            {
                string src = (string) ar.get('LeadSource');
                Integer cnt = (Integer) ar.get('cnt');
                leadSummary = leadSummary + '<tr><td>' + src + '</td><td>'+ cnt.format() +'</td></tr>';
            }
            leadSummary = leadSummary + '</table>';            
        }
        catch(Exception ex)
        {
            System.Debug('Some Exception >'+ ex.getMessage());
        }
    }

    global void finish(Database.BatchableContext BC)
    {
        // Get the AsyncApexJob using JobId 
        AsyncApexJob a = [SELECT Id, Status, NumberOfErrors, JobItemsProcessed, TotalJobItems, CreatedBy.Email, ExtendedStatus   
                            FROM AsyncApexJob 
                            WHERE Id = :BC.getJobId()];  
                                    
        if(a.Status == 'Completed')           
            utilMail.sendNotificationMail('Lead Summary Job Result',a,leadSummary);   
        else
            utilMail.sendNotificationMail('Job Did not Complete!',a,'Failure');   
    }   

    global class AggregateResultIterable implements Iterable<AggregateResult> {
        global Iterator<AggregateResult> Iterator(){
            return new AggregateResultIterator();
       }
    }

    global class AggregateResultIterator implements Iterator<AggregateResult> {
        AggregateResult [] results {get;set;}
        Integer index {get; set;} 

        global AggregateResultIterator() {
            index = 0;
            String query = 'Select COUNT(Id) cnt, LeadSource From Lead WHERE CreatedDate = YESTERDAY GROUP BY LeadSource';
            results = Database.query(query);            
        } 
        
        global boolean hasNext(){ 
           return results != null && !results.isEmpty() && index < results.size(); 
        }    
        
        global AggregateResult next(){ 
            return results[index++];            
        }       
    }    
}

This is my test metohd I created.
 
static testmethod void testmethod1() {
            
            List<Lead> allLeads = new List<Lead>();
            for(integer i =0; i< 199; i++)
            {
                            Lead l = new Lead();
                            l.FirstName = 'TEST ' + i.format();
                            l.LastName = 'Lead';
                            l.Lease_Amount__c = 240;
                            l.LeadSource='2055 - Website';
                            l.Company = 'Testing Batch Jobs';   
                            l.Title = 'Dr';
                            l.Phone='5556667777';
                            allLeads.Add(l);
            }
       
       insert allLeads;

       Test.startTest();
       Database.executeBatch(new getCreatedLeadsSummary());     
       Test.stopTest();

       Integer i = [SELECT COUNT() FROM Lead WHERE CreatedDate=Today];
       System.Debug(i);       
       System.assertEquals(i, 199);
    }
After executing this test method, my coverage is at 56% (17/30) lines. So I found that the execute method is not being covered. How can I cover the execute method in my test class and attempt to reach 100% coverage?
 
I am confused of what is being asked here can someone help me please.
What are some of the differences between single org implementations and products for distribution?
I'm getting the following error when I try to set an opportunity to closed won:

Error:Apex trigger Create_followup caused an unexpected exception, contact your administrator: Create_followup: execution of BeforeUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, editSchedule: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0 with id 00oU0000002ulNkIAI; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id] Trigger.editSchedule: line 144, column 1: []: Trigger.Create_followup: line 88, column 1

The two triggers mentioned in the error are both triggers I wrote. Can anyone tell me what this type of error might be caused by?

Thanks
We have the following  VF component that lists out unit availability for our company.  It returns results and switches out English text for French text in our autoresponse:

<apex:repeat value="{!lstRentals}" var="item">
<tr>
<td style="text-align:left;padding:5px;"> {!CASE(item.strSiteType,"Bachelor","1 1/2","Junior 1 Bedroom","2 1/2","1 Bedroom","3 1/2","2 Bedroom","4 1/2","3 Bedroom","5 1/2","4 Bedroom","6 1/2","Parking","stationnement","unknown")}</td> <td style="text-align:left;padding:5px;"> {!item.strRent} </td>
<td style="text-align:left;padding:5px;"> {!if(item.strAvailableDate='immediate','immédiatement',item.strAvailableDate)}</td>
</tr>
</apex:repeat>

This is working great, but I need to do the same in a slightly different component.  Currently that component does not translate, and looks like this:

<td style="text-align:left;padding:5px;"> {!n.result['Suite_Type__c']} </td>

I tried the version below without success, not surprisingly as I am a novice at this.

{!CASE(!n.result['Suite_Type__c'],"Bachelor","1 1/2","Junior 1 Bedroom","2 1/2","1 Bedroom","3 1/2","2 Bedroom","4 1/2","3 Bedroom","5 1/2","4 Bedroom","6 1/2","Parking","stationnement","unknown")}

Any ideas on how to map the {!n.result['Suite_Type__c']} so the text is modified as above?
The challenge says the API name has to have 2 underscores in it, but the Developer module is saying you can't have two underscores together in the API name.  Help?
Hello, i'm sucking up my pride a little bit, but the code below appears to correct but I get a Save error: illegal assignment from Ext_Warranty__c to Unit__c when I try to compile it. If anyone could help with this I would appreciate it as I am going out my mind trying to figure out why  this code is failing.
 
trigger UpdateUnitExtWarranty on Unit__c (before insert, before update) {

 // Step 1: Create a set of all emails of Users to query
  Set<String> allpc = new Set<String>();
  for (Unit__c newUnit :Trigger.new) {
    if (newUnit.Product_Code__c != null) {
      allpc.add(newUnit.Product_Code__c);    }
  }

  // Step 2: Query for all the extended warranties in Step 1
  List<Extended_Warranty__c> potentialextwrnty = [SELECT Id, Product_Code__c FROM Extended_Warranty__c
                                 WHERE Product_Code__c IN :allpc];

  
  // 
  Map<String, Extended_Warranty__c> extwrntyMap = new Map<String, Extended_Warranty__c>();
  for (Extended_Warranty__c e : potentialextwrnty) {
    extwrntyMap.put(e.Product_Code__c, e);
  }
  
  
  for (Unit__c newUnit : Trigger.new) {
    if (newUnit.Product_Code__c == null) {
      Unit__c extendedwarranty = extwrntyMap.get(newUnit.Product_Code__c );
      if (extendedwarranty != null) {
      	//rename extended_warranty fieldbelow on unit page
        newUnit.Ext_Warranty__c = extendedwarranty.Id;
      }
    }
  }
}

 
  • February 12, 2016
  • Like
  • 0
Hello,

I have what I think is a simple question. I am trying to do the following:
  1. Have the formula look at MK_Days_When_Postmarked__c
  2. If it is blank, run throught the 4 calculations regarding trial date messages
  3. If it is not blank, run TEXT(MK_Days_When_Postmarked__c) (ie. show the number in that field)
 
IF( ISNULL(MK_Days_When_Postmarked__c),

IF(  MK_Days_Into_Trial__c = 0 , "Not Yet Shipped" ,

IF(  MK_Days_Into_Trial__c < 46 , "Day " + TEXT(MK_Days_Into_Trial__c) , 

IF(  MK_Days_Into_Trial__c < 51 , "Manually Calculate (~" + TEXT(MK_Days_Into_Trial__c) +" Days)" , 

IF(  MK_Days_Into_Trial__c > 50 ,"Out of Trial (" + TEXT(MK_Days_Into_Trial__c) + " Days)",

TEXT(MK_Days_When_Postmarked__c)

)
)
)
)
)

There's a good chance I'm making a simple mistake here, just can't seem to find it.

Thanks!
When trying to deplo a class this message appears?
User-added image
How to auto -populate user look up field on the case object? using the Web Email field on case object
I have a web email or SuppliedEmail standard fiel which holds the email address of the user 
Using this field I want to auto populate the respective user lookup
 
I have the following code in the dev console, but it doesn't compile because it doesn't like my attempts to cast the aggregateresult into something I can evaluate (numerous other formats tried).  Because of what it's doing, I can't use "HAVING" - if an email appears only once in lead and once in contact, I need to know that also.  How can the 2 evaluation statements be changed so that they compile and execute?

Map<String, AggregateResult> LeadsByEmail = new Map<String, AggregateResult>([SELECT Email Id, Count_distinct(Id) Cnt
                                                                              FROM Lead
                                                                              WHERE IsConverted != true
                                                                              GROUP BY Email]);
Map<String, AggregateResult> ContactsByEmail = new Map<String, AggregateResult>([SELECT Email Id, Count_distinct(Id) Cnt
                                                                                 FROM Contact
                                                                                 GROUP BY Email]);
for (AggregateResult arl : LeadsByEmail) {
    if (LeadsByEmail.get(arl.Id) > (AggregateResult)'1') {
        system.debug('Duplicate email - '+ arl.Id);
    }
    if (ContactsByEmail.containsKey(arl.Id)) {
        system.debug('Duplicate email - ' + arl.Id);
    }
}
for (AggregateResult arc : ContactsByEmail) {
    if (ContactsByEmail.get(arc.Id) > (AggregateResult)'1') {
        system.debug('Duplicate email - '+ arc.Id);
    }
    if (LeadsByEmail.containsKey(arc.Id)) {
        system.debug('Duplicate email - ' + arc.Id);
    }
}
I am using Stripe SDK for Salesforce. I created my webhook listener and provided the apex rest url to Stripe. I generated a connected app in my salesforce instance. How do i provide the client secret and key to Stripe? 
I think i am missing something simple, any hints?

Thanks in advance
Hi All,

I'm deploying Account and Contact layouts to production using Eclipse Ide. While validating i'm facing issue like  "ActionId specified was invalid for ActionType QuickAction". Please let me know how to resolve the issue.

Thanks
I’ve tried so many ways to try to make this work but can’t get it to behave.  Other posts seem to indicate that this doesn’t work. But i really need it so here goes..

In the apex controller code MainControllerClass…
public Boolean ABCCheckbox {get; set;} 
public Boolean IsABC { 
       get{if (appl==null) return false;     
           if (appl.rating__c==‘ABC’) return true; return false;} set;}   

…startup, so not null or otherwise wonky...
ABCCheckbox           = false; 

…later & before page loads, ABCCheckbox set true…
if (appl.rating__c==‘ABC’) ABCCheckbox = true;
In the page...
<apex:page controller="MainControllerClass" >
 <apex:form id="abcForm">
 <apex:pageBlock >
  <apex:outputPanel styleClass="panelWrapper" layout="block">
…
 <apex:outputPanel id="abcDetailPanel" layout="block">
    <apex:pageblocksection id="abcDetail"> 
…            
        <apex:pageBlockSectionItem >
          <apex:outputLabel value=“Check if ABC applies?”/>
          <apex:inputCheckbox value="{!HBCheckbox}" selected="{!IsABC}"/>
       </apex:pageBlockSectionItem>
…
    </apex:pageblocksection>
  </apex:outputPanel>
...
  </apex:outputPanel>
  </apex:pageBlock>
  </apex:form>
</apex:page>
I've also tried this...
<apex:pageBlockSectionItem >
          <apex:outputLabel value=“Check if ABC applies?”>
          <apex:outputPanel layout="block">
             <apex:actionRegion >
            <apex:inputCheckbox value="{!ABCCheckbox}" selected="{!IF(appl.rating__c==‘ABC’,true,false)}" >
             </apex:actionRegion>
          </apex:outputPanel>       
       </apex:pageBlockSectionItem>
…and if i do this, it is checked but that doesn’t help except shows me “selected” *can* work sometimes…
<apex:pageBlockSectionItem >
          <apex:outputLabel value=“Check if ABC applies?”>
          <apex:outputPanel layout="block">
             <apex:actionRegion >
            <apex:inputCheckbox value="{!ABCCheckbox}" selected=“true” >
             </apex:actionRegion>
          </apex:outputPanel>       
 </apex:pageBlockSectionItem>

When i check the value of ABCCheckbox, it is indeed checked if the user checks it. I just can’t load the page with it already checked.


 
I am working with a Non Profit client that has the NonProfit Starter Package installed.  When any user besides Sys Ad tries to edit a record in the Account Object (which is renamed 'Households' in their org), they see this message:

No such column 'npo02__Household__c' on entity 'Contact'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. 
An unexpected error has occurred. Your solution provider has been notified. (npsp)


I'm a little bit at a loss here and certainly don't know much about modifying managed packages.  Thanks!
I tried starting the Release Spring 2016 trailhead and when I wanted to answer the challenge questions, it asked me to log into trailhead. I was already logged into the Developer's Community. I clicked on the loggin button and it would not let me login telling me to contact my admin. I am the admin! I can do these trailheads if it's not letting me log in. Any ideas why?
Hi,
I am new to SF REST API. I am trying to create an angular app and retrieve data from salesforce rest api with SF OAuth authentication. I get the bearer access token after authentication and have set it in the header for the api request. However, everytime I made a $http.get from angular, I get no data. The dev tool console shows this error:
XMLHttpRequest cannot load https://na34.salesforce.com/services/data. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.

However, when I look at the network tab in chrome dev tool, I see the status was 200 OK. I tested the request from fiddler and postman and I am able to get the data without problem. I also added my localhost:8080 to whitelist in CORS from the SF. Any idea what I am missing? Thanks!
Source Object - Activity
Source Field - FT_Emp__c
Destination Object - Contact
Destination Field - Employees__c
trigger Update_employee_count_in_contact on Task (after insert, after update) {
    // set up lists you will need
    List<Contact> consToUpdate = new List<Contact>();    
    
    Map<Id, Task> taskMap = new Map<Id, Task>();

    // go through the list of tasks that were inserted
    for (Task t: Trigger.New)
    {
            taskMap.put(t.WhoId, t);
    }
    
    if (taskMap.size() > 0)
    {
        // get all of the contacts related to the tasks
        // Code logic to update Employees__c field of Contact field
        .
        .
        .
        
        if (consToUpdate.size() > 0)
        {
            update consToUpdate;
        }
    }
}

I want Employees__c to be equal to FT_Emp__c when FT_Emp__c is updated. 

Can anybody help me complete the above the code snippet?