• tomcollins
  • NEWBIE
  • 105 Points
  • Member since 2012

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 40
    Replies

How do i do the unit testing for this.Unit testing does not go into this part. 

it is not being tested from response.getbody().

We are doing a lot of  json parsing please do help

Shine

 

************Code*******************

JSONParser parser = JSON.createParser(response.getBody());

while (parser.nextToken() != null)
{
if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) && (parser.getText() == 'total_records'))
{
// Get the value.
parser.nextToken();
// Compute the grand total price for all invoices.
total_records=integer.valueof(parser.getText());
// total_records=
}

 

************Code*******************

Hi,

 

I have to store 2 digit state name like (IL -Illinois, NY - New York...). Even though I entered in lower case, I need to store them in upper case.

Can we do this without apex code? or is this possible only with usual way of having a trigger to check the state codes and compare and update and return the upper case code.

Please let me know your thoughts.

 

Thanks,

JBabu.

 

  • July 23, 2012
  • Like
  • 0

public void save()

{

for (Integer j = 0; j < selectcategory.size(); j++)
         {

for (Integer i = 0; i< selectlayout.size(); i++)
         {
          system.debug('valuedata'+selectlayout[i].label1);
          str = '<widgetnode><widget Name='+ selectcategory[j].label +'><Imag='+ selectlayout[i].Image1 +' Field='+ selectlayout[i].label1 +'  result='+ selectlayout[i].value +'/></widget></widgetnode>' ;
         system.debug('stringgg'+str);     
       }
     }

}

     widgetpro.Displayed_Widgets__c = str;

}

  I'm getting only last value into str......but in debug I can get all the values.....How should I come out of this

Hello Everyone

 

Any help would be greatly appreciated

 

Error: Compile Error: Initial term of field expression must be a concrete SObject: LIST<Product_Detail__c> at line 274 column 24

 

  public string SelectedAccountId { get; set; }
     public void DeleteDetail()
   {
    // if for any reason we are missing the reference
      if (SelectedAccountId == null) {     
         return;
      }
    
      // find the detail record within the collection
      Product_Detail__c tobeDeleted = null;
     
      for(List<Product_Detail__c> a : products.values())
     // for(Product_Detail__c a : products)
       if (a.name = SelectedAccountId) {
         tobeDeleted = a.name;    <<<<<<Line 274
          break;         
        }     
      //if account record found delete it
      if (tobeDeleted != null) {
       Delete tobeDeleted;
      }
    
      //refresh the data
      //LoadData();
   }   

  • July 19, 2012
  • Like
  • 0

I think I'm seeing behavior where the system sets the Last Modified fields of a group of records when I do an upsert, even when I have only modified some of the records.

 

I'm using a SOQL statement to load an array of records.  I go through that array and make changes to some of the records.  I then upsert the array.  I'm seeing all of the records get their modified date/user set in that process.

 

Am I supposed to create another list of modified records, and only do the upsert on them?

What's the correct way to create a field that should not change after the record is created?

 

I see that there is an ISCHANGED() function for validation rules.  Should I just create a validation rule that sees if any of these fields have been changed?  Should I make the fields read-only?  Will either of those techniques prevent Apex code launched by a user from creating new records?

 

I'm guessing that a validation rule is more efficient than a trigger.

 

The fields are used as foreign keys to an external database, and need to be immutable.  Not even an administrator should be able to edit the field.

I'm trying to chart some Float values with Apex Charting.  My Y-axis has floating point values, but my charted data points get rounded (or possibly truncated) to the nearest integer.  When I roll over the tool tip, it shows an integer value for the marker.

 

Is this a bug in charting, or is there some attribute I can set in one of my apex tags to have the lineSeries plotted with Float values?

We're using Git to manage our project, since multiple developers are working with it and we want to have a revision history.

 

We're also using the Force.com IDE for development.

 

I'm now seeing "File only saved locally, not to server" warnings in the Problems tab for each file in the .git subdirectory, which exists at the same level as the src subdirectory.

 

I'm surprised that the IDE is trying to push those files up to the Salesforce server.  Is there any way to configure the IDE to ignore that directory?

 

I've successfully installed the Force.com IDE on my Mac, but now I can't figure out how to launch it!

 

I've looked in Applications and found both a Pulse and a salesforce.com folder.  The Pulse folder just has a copy of the installer and an uninstaller; salesforce.com has a Force.com IDE folder with an uninstaller.

 

If I launch the installer, there's an option to launch the IDE, but I'd like to just launch the IDE directly.

 

Where is it hiding?  After launching, I found "~/Library/salesforce.com/Force.com IDE.app" in my process list.  Is it OK to launch that directly?

I've tried to install the Force.com IDE on my Windows 7 32-bit laptop.  I have other eclipse-based IDEs installed and working fine on this machine.

 

After the install, the installer launches the IDE, but the window is titled "Eclipse Provisioning" and the install seems incomplete.  The Window menu just has a Preferences option, so I cannot switch to the Force.com Perspective.  The bottom of the window includes tabs for "Apex Test Runner" and "Execute Anonymous" that look like they're Force.com related, but I can't seem to do much else.

 

Has anyone else run into this problem?

 

-Tom

We're using Git to manage our project, since multiple developers are working with it and we want to have a revision history.

 

We're also using the Force.com IDE for development.

 

I'm now seeing "File only saved locally, not to server" warnings in the Problems tab for each file in the .git subdirectory, which exists at the same level as the src subdirectory.

 

I'm surprised that the IDE is trying to push those files up to the Salesforce server.  Is there any way to configure the IDE to ignore that directory?

 

 what is anonymous block?

Force community, 

 

I'm new to writing Apex triggers, and wanted to get some feedback on my issue. I currently have two Custom Objects - lets call those CO1 and CO2.

 

CO1 records are created as children of Opportunities, and contain about 20 fields. When my company signs on a client, we change a field called 'Type' on the Account object to 'Customer' instead of 'Prospect'. When this happens, I'd like to have an Apex Trigger create a new CO2 record, and copy all the data from existing CO1 records (which are, again, children of the opportunity), to CO2 records, which are merely related to Accounts.

 

I'm pretty new to this, but my two biggest questions are these: Do I have to compare a map to notice if the Type = Customer? And how exactly do I navigate related objects to find the correct CO1 record to copy? 

 

Thanks, any help is apprecaited! 

 

Hi,

 

i have .txt file and images files can we download the file in our system  instead of open in new window ?

 

Thanks

 

 

How do i unit test a Json Parser.We have a lot of json parser installed in out appliaction.Please do suggest some ways to install unit testing for  json parser

Regards

Punnoose

How do i do the unit testing for this.Unit testing does not go into this part. 

it is not being tested from response.getbody().

We are doing a lot of  json parsing please do help

Shine

 

************Code*******************

JSONParser parser = JSON.createParser(response.getBody());

while (parser.nextToken() != null)
{
if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) && (parser.getText() == 'total_records'))
{
// Get the value.
parser.nextToken();
// Compute the grand total price for all invoices.
total_records=integer.valueof(parser.getText());
// total_records=
}

 

************Code*******************

Hi,

 

I have to store 2 digit state name like (IL -Illinois, NY - New York...). Even though I entered in lower case, I need to store them in upper case.

Can we do this without apex code? or is this possible only with usual way of having a trigger to check the state codes and compare and update and return the upper case code.

Please let me know your thoughts.

 

Thanks,

JBabu.

 

  • July 23, 2012
  • Like
  • 0

Can someone please verify that the following code is returning an incorrect line reference in the NullPointerException.

 

boolean nullReferenceBoolean = null;
List<long> listOfLongs = new List<long>();
for(integer i = 0; listOfLongs != null && i < listOfLongs.size(); i++) {
	System.debug(LoggingLevel.Debug, 'i:' + i + ' testLong:' + listOfLongs[i] + ' listOfLongs.size():' + listOfLongs.size());
}
if(nullReferenceBoolean) {
	System.assert(false, 'Expected Null Pointer Exception');
}
System.assert(false, 'Expected Null Pointer Exception');

I get the fatal error:

18:48:47.040 (40006000)|FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null object
AnonymousBlock: line 3, column 1

I'd expect the error to be on line 6 and not 3.

 

The incorrect line number caused me to waste some time trying to debug the for loop rather than the next statement after it. The above is a greatly simplified version of the code I was working on so it wasn't immediately obvious what the issue was.

Hi,

 

I have developed a new webservice class to return a set of account records. Following is the code:

 

global class AccountMinesiteWebService
{

// Object to be returned by the webservice
global class Minesite{
webservice String msId;
webservice String msName;
webservice String msMineType;
webservice String msMineral;
webservice String msExternalId;
webservice String msAccountStatus;
webservice String msPhone;
webservice String msFax;
webservice String msParentName;
webservice String msIsActive;
webservice String msMineLatitude;
webservice String msMineLongitude;
}


webservice static List<Minesite> minesiteDetails(){
List<Minesite> minesites = new List<Minesite>();
Minesite ms;

//Query for the minesite Accounts
List<Account> accountList = new List<Account>([SELECT Id, Name, Mineral__c, External_ID__c, Mine_Type__c,
Account_Status__c, Phone, Mine_Latitude__c, Mine_Longitude__c,
Fax, Parent.Name, Is_Active__c, Jitterbit_Update__c
FROM Account
WHERE Type = 'Mine Site' AND Jitterbit_Update__c = 'YES']);

// Add all the minesite Accounts to the webservice class object that will be sent out to the external system
for(Account acc: accountList){
ms = new Minesite();
ms.msId = acc.Id;
ms.msName = acc.Name;
ms.msMineType = acc.Mine_Type__c;
ms.msMineral = acc.Mineral__c;
ms.msExternalId = acc.External_ID__c;
ms.msAccountStatus = acc.Account_Status__c;
ms.msPhone = acc.Phone;
ms.msFax = acc.Fax;
ms.msParentName = acc.Parent.Name;
ms.msIsActive = String.valueOf(acc.Is_Active__c);
ms.msMineLatitude = acc.Mine_Latitude__c;
ms.msMineLongitude = acc.Mine_Longitude__c;
minesites.add(ms);
}

return minesites;

}

public static testMethod void testAccountMinesiteWebService(){
List<Minesite> testMinesites = new List<Minesite>();
testMinesites = AccountMinesiteWebService.minesiteDetails();
}
}

 

When I run the test, it is just covering 18% of the class. The reason is, it is not entering the for loop at all (which means the accountList has no records in it). But I executed the same query in developer console, there it is successfully returning the records that satisfy the query conditions and it is entering the for loop as well. I can't figure out why the same query is failing to return any records in the webservice class (there are some account records in our sandbox that satisfy the query conditions). Please help me if there is any mistake in my code! Thanks much.

public void save()

{

for (Integer j = 0; j < selectcategory.size(); j++)
         {

for (Integer i = 0; i< selectlayout.size(); i++)
         {
          system.debug('valuedata'+selectlayout[i].label1);
          str = '<widgetnode><widget Name='+ selectcategory[j].label +'><Imag='+ selectlayout[i].Image1 +' Field='+ selectlayout[i].label1 +'  result='+ selectlayout[i].value +'/></widget></widgetnode>' ;
         system.debug('stringgg'+str);     
       }
     }

}

     widgetpro.Displayed_Widgets__c = str;

}

  I'm getting only last value into str......but in debug I can get all the values.....How should I come out of this

Hello all, I am new to apex programming. I am trying to capture information from web form / html and save it to SF object as a new record

1. Create form to be embedded on the customers website. form POST to a SFDC Site. 
2. Create a site on SFDC. This site will receive the request, process it and create the record of the object.
3. Redirect user to the appropriate page.
Please help me with some example code.
Thanks!

Hi every one i have one http request in apex class below .is thr any way to send a html as a querystring .

 

here i get fr as  a html .

http:/abc.com/SendItineraryEmail?opportunityId='+fr.Opportunity__c+'&flightRequestID='+fr.Id+'&emailTo='+fr.Email_To__c+'&emailCc='+fr.Email_Cc__c+'&emailFrom='+fr.Email_From__c+'&subject='+fr.Subject__c+'&fr='+fr);

 

any idea let me know

 

I've tried to install the Force.com IDE on my Windows 7 32-bit laptop.  I have other eclipse-based IDEs installed and working fine on this machine.

 

After the install, the installer launches the IDE, but the window is titled "Eclipse Provisioning" and the install seems incomplete.  The Window menu just has a Preferences option, so I cannot switch to the Force.com Perspective.  The bottom of the window includes tabs for "Apex Test Runner" and "Execute Anonymous" that look like they're Force.com related, but I can't seem to do much else.

 

Has anyone else run into this problem?

 

-Tom

Hi I need so expert help...

 

I have an APEX REST POST method that is being called from an external system 'A'.

 

Processing this POST I need to callout to another external system 'B' and based on its response continue with my application logic, eventually returning the result to system 'A'.

 

The problem is that I'm getting an Error:  "System.CalloutException: Callout loop not allowed"

 

This is really important.

Any suggestion how can I achieve the flow I described?

 

Many thanks

 

Kruvi

  • February 15, 2012
  • Like
  • 0

I have a VF Page that refrences an APEX Class to get a list of picklist values for a survey question. How can I convert the below code so that the fields are now multi select radio button (Multiple choices can be picked) as opposed to a regular radio button

 

  public List<SelectOption> getInterestOptions(){
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('Virtual Phone System','Virtual Phone System'));
        options.add(new SelectOption('Online Data Backup','Online Data Backup'));
    options.add(new SelectOption('Hosted Email','Hosted Email'));
    options.add(new SelectOption('Email Marketing','Email Marketing'));
        return options;

 

Thank you in advance,

V

Is anyone doing this successfully?  We're at a point where I'd like to migrate from just using regular code comments to using full blown javadoc-accessible documentation, to make it easier and more appealing for our devs to reuse code.

 

Can anyone provide any examples of generating javadoc html from the .cls files stored by Eclipse?