• JarrettK
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 11
    Replies

Can a custom componenet inheret the controller from the page the controller is embeded in?

I would like to know the best practices for querying data on an object if you do not know if any rows will be returned.

 

For example:

 

List<CustomObject__c> myObj = [select Id from CustomObject__c where customField__c = '1234' limit 10];

 

This may not return any results and will error out.

 

However assigning the data to an array does not care if there are zero results

 

CustomObject__c[] myArray = [select Id from CustomObject__c where customField__c = '1234' limit 10]; 

 

But I really want my data reutned in object format for DML and other benefits, what is the best way of converting an array to object notation?  

 

I am sure I am missing something really stupid, please advise.

 

Thanks!

 

I have installed XCode 4.3.1, downloaded the Mobil SDK for iOS from Github, installed with ./install.sh and ran 

sudo xcode-select -switch /Applications/Xcode.app/. I have no problems running the ContactExplorer app, but I am not able to get a simple Hybrid app running from the Hybrid template.

 

I create a new Hybrid project using the Hybrid template, run it with no changes and get this error:

2012-03-31 03:59:29.492 BFA-demo2[10961:13403] SFSmartStore initWithStoreName: defaultStore

2012-03-31 03:59:29.583 BFA-demo2[10961:13403] webViewDidFinishLoad: Loaded about:blank

2012-03-31 03:59:29.585 BFA-demo2[10961:13403] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'

 

I there is something simple I am missing, but I'm just too new to mobile programming.

 

Thanks.

 

 

 

Hi all,

 

I'm working on a development that gets a JSON file with a father and child objects information. After that, I could do some changes in the JSON file directly and after importing, I create with this new data a new father and child record. It used the old JSONObejct class and it was working fine, but I got a too many script statament error so I decide to take a look at the new JSON Winter'12 feature.

 

The current JSON.serialize(SObject) method works fine and returns me this:

 

{
    "attributes": {
        "type": "MyObject__c",
        "url": "..................................."
    },
    "Id": "a1SD00000005Hk5MAE",
    "Field1__c": "Test1-complex",
    "Field2__c": "Test2-complex",
    "MyObjectLineItems__r": {
        "size": 1,
        "totalSize": 1,
        "done": true,
        "records": [
            {
                "attributes": {
                    "type": "MyObjectLineItem__c",
                    "url": "............................................................."
                },
                "Id": "a1TD0000000FFAJMA4",
                "Field1__c": "text1",
                "Field2__c": 150,
                "Field3__c": 155.55,
                "Field4__c": true,
                "Field5__c": "2011-12-20",
                "Field6__c": "2011-12-20T15:24:00.000+0000",
                "Field7__c": "No",
                "MyObject__c": "a1SD00000005Hk5MAE"
            }
        ],
        "queryLocator": null
    }
}

 

But I don't know how to use the deserialize method because it's second argument is the type, and here I have two objects.

 

I tried to create my own deseriaze method, using the JSON.createParser(JSONString); but, in order to make my code as easier as possible, I wanted to use the parser.readValueAs() method. But I'm not sure how to do it because, I don't have in the JSON string the name of my father object, and if I try to do it with my child one, it doesn't work either.

 

This is my code:

 

List<MyObject__c> myObjectList = [Select Id,
                                                                             Field1__c, //Text
                                                                             Field2__c, //Text
                                                                            (Select Id, 
                                                                                          Field1__c, //Text
                                                                                          Field2__c, //Integer
                                                                                          Field3__c, //Decimal
                                                                                          Field4__c, //Checkbox
                                                                                          Field5__c, //Date
                                                                                          Field6__c, //DateTime
                                                                                          Field7__c, //Picklist
                                                                                          MyObject__c
                                                                             From MyObjectLineItems__r)               
                                                             From MyObject__c
                                                             Where Id = :myObjectId];
   
   if(myObjectList.isEmpty())
   {
               throw new MyJSONException('There is no object which ID is ' + myObjectId);   
   }
   else
   {
                String JSONString = JSON.serialize(myObjectList.get(0));
               

                // Parse JSON response
               JSONParser parser = JSON.createParser(JSONString);
    
               while(parser.nextToken() != null)
               {
                      if(parser.getCurrentToken() == System.JSONToken.FIELD_NAME)
                      {
                              if(parser.getText() == 'MyObjectLineItems__r')
                              {
                                             Type lineItem = Type.forName('MyObjectLineItem__c');
                                             MyObjectLineItem__c so = (MyObjectLineItem__c)parser.readValueAs(lineItem);       
                              }
                       }
                }
   }

 

I know that I could go throw each line, and read the field and the value, but I would like to do as quicker as possible.

 

Can someone help me?

 

 

Many thanks in advance.

 

When JSON support was added in APEX, I was one of those guys who jumped up and down. Started using heavily for one of my integration project and everything was fine and dandy for couple week. Since yesterday, I have been noticing some weired behavior. The first time I noticed it, I thought it was one of those APEX issues I love to call "APEX weirdness" and hoped that it will fix itself (READ: getting fixed without us knowing). That hasn't happened. :(

 

Here is the issue. 

 

My JSON parsing code looks like this:

class SomeApexWrapper {

public static SomeApexWrapper getInstance(String jsonString)

JSONParser parser = JSON.createParser(jsonString);       

SomeApexWrapper w = (SomeApexWrapper) parser.readValueAs(SomeApexWrapper.class);

}

}

 

This code was working fine until two days ago. It stops working If I change any class that uses this class to parse json string. The error I get is "[Source: java.io.StringReader@21363a13; line: 1, column: 1] Don't know the type of the Apex object to deserialize"

 

Just saving the SomeApexWrapper  class again fixes the issue. 

 

Has anyone had/having this issue? Is there a permanent solution for this?

  • November 07, 2011
  • Like
  • 0

Hi all,

 

Help me to slove this issue....

 

My coding works fine, when i create as unmanaged pacakge, but when i create as managed pacakage and deploy into production, it shows the following error

 

"SObject row was retrieved via SOQL without querying the requested fielld:Opportunity.Account"

 

 Note:- Am getting this error when am create as managed package.





Can a custom componenet inheret the controller from the page the controller is embeded in?

I would like to know the best practices for querying data on an object if you do not know if any rows will be returned.

 

For example:

 

List<CustomObject__c> myObj = [select Id from CustomObject__c where customField__c = '1234' limit 10];

 

This may not return any results and will error out.

 

However assigning the data to an array does not care if there are zero results

 

CustomObject__c[] myArray = [select Id from CustomObject__c where customField__c = '1234' limit 10]; 

 

But I really want my data reutned in object format for DML and other benefits, what is the best way of converting an array to object notation?  

 

I am sure I am missing something really stupid, please advise.

 

Thanks!

 

knowing that the callout limit is 10 per Apex transaction, I just wanted to confirm that this would be per batch execution, and not 10 total for the whole batch.

 

For instance, if I have a batch that is to iterate over 10 records in a table, and I set the batch scope to 1, I'd be able to execute a max of 10 callouts per record that I'm iterating in the batch.  Does that sound right?

 

I'm looking to "synch" our community from a 3rd party platform via webservices, every couple hours, rather than execute callouts on every page load that needs the data, so we can reduce latency on Visualforce pages where this content can be "cached" in Salesforce objects instead of on demand.

As an ISV, say you introduce references to Person Account fields in your Apex code in a managed package.

 

Does this imply that any customer wishing to install your package needs to enable Person Accounts??  If so, what are the best practices or workarounds for this?  Obviously we cannot assume that all potential customers will want to enable Person Accounts in their orgs...

 

Thanks.


Dave

 

  • June 17, 2010
  • Like
  • 0

Hi there,

 

I'm experiencing a strange problem. In a Visualforce Page there is a large number of custom buttons. They were implemented as <apex:commandLink> and work well in Firefox, Safari, Opera, Internet Explorer 7.

But the same button doesn't work in IE 8! I tried the Developertools from the extras menu in IE 8 and opened the page in IE 7 mode, everything works as expected.

I also tried to change the <apex:commandLink> in a <apex:commandButton>, but there is no reaction.

The action invoked is just similar to any other working Button (a simple pageReference which sets a field value).


Is there any known problem or a workaround to fix this problem?

 

Any suggestions welcome ;-)

 

Best regards,

Tobias Forstmeier

Hi there

 

I'm trying to hide pageblock buttons in my visual force page using my custom <style></style>. But when I`m rendering it as a pdf, button still appears on the pdf.

 

Could anyone have any idea?

 

I appreciate any comment.

  • March 12, 2010
  • Like
  • 0