• SBK
  • NEWBIE
  • 75 Points
  • Member since 2010

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 15
    Replies

I am developing a Site and I do a callout to get some information.

 

I use the Apex JSONParser from : http://code.google.com/p/apex-library/source/browse/trunk/JSONObject/src/unpackaged/classes/JSONObject.cls

to parse the HttpResponse. I downloaded the code installed it my environment

and using it.  However I run into  System.Exception: Too many script statements: 200001.

 

Is there any other JSONParser which does a better job in parsing, so I do not hit the limitation?

 

I do not understand why the JSONParser is not part of the Apex System package so

it does not compete with the user limitations.

 

Thanks, 

 

  • March 06, 2010
  • Like
  • 0

I took Jeff's sample code (http://blog.jeffdouglas.com/2008/11/25/dependent-multilevel-selectlists/) and made a

minor change which is highlighted in red.

 

The multilevel select stopped working after the change. It does not work either in Chrome or Firefox.

 

It doesn't work in IE because of the event="onchange" attribute.

 

What am I doing wrong?

 

 

<apex:page standardController="Opportunity" extensions="MultiSelectController"> <apex:sectionHeader title="Opportunity" subtitle="{!opportunity.name}"/> <apex:form > <apex:pageBlock title="Opportunity" mode="edit"> <apex:outputText value="{!opportunity.Cat1__c}" rendered="false"/> <apex:outputText value="{!opportunity.Cat2__c}" rendered="false"/> <apex:outputText value="{!opportunity.Cat3__c}" rendered="false"/> <apex:pageBlockButtons location="both"> <apex:commandButton value="Save" action="{!save}" /> <apex:commandButton value="Cancel" action="{!cancel}" /> </apex:pageBlockButtons> <apex:pageMessages /> <apex:pageBlockSection title="Master Categories" columns="1"> <apex:pageBlockSectionItem > <apex:outputLabel value="Category 1" for="cbxlevel1"/> <apex:outputPanel styleClass="requiredInput" layout="block"> <apex:outputPanel styleClass="requiredBlock" layout="block"/> <apex:selectList value="{!selectedLevel1}" id="cbxlevel1" size="1" required="true"> <apex:selectOptions value="{!level1items}"/> <apex:actionSupport event="onchange" rerender="cbxlevel2"/> </apex:selectList> </apex:outputPanel> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="Category 2" for="cbxlevel2"/> <apex:selectList value="{!selectedLevel2}" id="cbxlevel2" size="1"> <apex:selectOptions value="{!level2items}"/> <apex:actionSupport event="onchange" rerender="cbxlevel3"/> </apex:selectList> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="Category 3" for="cbxlevel3"/>

<apex:inputText required="true" id="username" value="{!username}"/>

</apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>

 

  • March 04, 2010
  • Like
  • 0

I have multiple select lists. I want the second select list to be rendered only after the user makes a selection in the first list. How would I make it happen using VisualForce, any examples would be appreciated.

 

Since the second list is populated after the first, how can I communicate between the first selection and the controller. I do not want the contoller methods associated with the second list execute before user action in the first.

 

Thanks. 

  • March 04, 2010
  • Like
  • 0

This code works in chrome, not in IE. How would I make it work in IE?

 

 

<apex:pageBlockSectionItem >

<apex:outputLabel value="Value 1" for="cbxlevel1"/>

<apex:outputPanel styleClass="requiredInput" layout="block">

<apex:selectList value="{!selectedId}" id="cbxlevel2" size="1">

<apex:selectOptions value="{!availableValues}"/>

<apex:actionSupport event="onclick" action="{!getStuff}" rerender="cbxlevel2"/>

</apex:selectList>

</apex:outputPanel>

</apex:pageBlockSectionItem>

 

 getStuff does not get fired when I pick something from the selectList. It works on chrome though

 

 Any help would be appreciated. 

 

  • March 04, 2010
  • Like
  • 0

I am sure this is a very simple issue and can be solved easily.

 

I have multiple PageBlocks in my VisualForce page...

 

 

<apex:form >

<apex:pageBlock title="New" mode="edit" id="newCampaignPageBlock">

<apex:pageBlockButtons location="bottom">

<apex:commandButton value="Save" action="{!add}" immediate="true"/>

<apex:commandButton value="Cancel" action="{!cancel}" />

</apex:pageBlockButtons>

<apex:pageBlockSection>

.............. 

</apex:pageBlockSection>

</apex:pageBlck>

<apex:pageBlock title="Update" mode="edit" id="updateCampaignPageBlock">

<apex:pageBlockButtons location="bottom">

<apex:commandButton value="Save" action="{!update}" immediate="true"/>

apex:commandButton value="Cancel" action="{!cancel}" />

</apex:pageBlockButtons>

 <apex:pageBlockSection>

..............

</apex:pageBlockSection> 

  </apex:pageBlck>

 

 

 

 

 

 

 

 

 

 One does "Add" and other "Update".

 

 User can do an Add or Update.

 

 In the above code, when the user just wants to update an existing record and does not

 want to do a new, the page complains that some of the required fields for Add are required.

 

 How would I prevent this? 

 

  • February 25, 2010
  • Like
  • 0

I need the currentTime as a DateTime object to use it my SOQL like :

 

m.End_Time__c < :currentTime

 

where End_Time__c is of type "DateTime".

 

Here is the relevant piece of code

 

 

public Datetime getCurrentDateTime() {

return DateTime.valueOf(System.now().format('yyyy-MM-dd\'T\'hh:mm:ss\'Z\''));

}

 

 

testmethod static void test() {

ApexPages.StandardController controller = new ApexPages.StandardController(new My_Custom_Object__c());

MyController mc = new MyController(controller);

System.debug('>>>>>>>>>>>>>>>> ' + mc.getCurrentDateTime());

 

 When I run the test, I get the following exception :

 

 System.TypeException: Invalid date/time: 2010-02-25T09:50:30Z in the line highlighted red

 

 What is wrong with the date format? Looks ok to me...

 

  Thanks a bunch.. 

 

  • February 25, 2010
  • Like
  • 0

I have a <apex:form> and two <apex:pageBlock> in a page.

 

The reason for having two <apex:pageBlock> is, each get their own <apex:pageBlockButtons> 

 

Here is what my code looks like :

 

 

<apex:form >

<apex:pageBlock title="New" mode="edit" id="newPageBlock">

<apex:pageBlockButtons location="top">

<apex:commandButton value="Save" action="{!add}" rerender="current_data"/>

<apex:commandButton value="Cancel" action="{!cancel}" />

</apex:pageBlockButtons>

<apex:pageBlockSection title="new data" columns="1">

........ </apex:pageBlockSection>

</apex:pageBlock>

 

<apex:pageBlock title="Update" mode="edit" id="current_data">

<apex:pageBlockButtons location="top">

<apex:commandButton value="Save" action="{!add}"/>

<apex:commandButton value="Cancel" action="{!cancel}" />

</apex:pageBlockButtons>

<apex:pageBlockSection title="update data" columns="1">

<apex:outputPanel>

........

</<apex:outputPanel> </apex:pageBlockSection>

</apex:pageBlock>

 

 The idea is to rerender any new data in the update data.

 

 The above code does not work.

 

 My question is can I rerender between page blocks? How would I resolve this problem?

 

 Thanks a million 

 

  • February 24, 2010
  • Like
  • 0

I have a custom object and I want to implement add, update, delete operations on my custom controller.

 

Questions:

 

1. I am not using any of the standard objects, so I do not have to extend any of the standard controllers right?

 

2.  How will I get access to the StandardController in my custom controller. The reason I need the StandradController is to take advantage of the getRecord() and save() function it offers.

 

3. For some reason this code does not work..

 

 

public with sharing class MyController {

public MyCustomObject__c myCustomObject {get;set;}

public MyController() {}

 

pulic PageReference add() {

try {

insert myCustomObject;

} catch (Exception ex) {

ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, ex.getMessage()));

return null;

}

return null;

}

}

 

 There is no exception thrown in my VisualForce page and the record does not insert as well.

 

  Any help in this regard would be appreciated. 

 

  • February 24, 2010
  • Like
  • 0

I am developing a "Site" (a customer portal) on Force.com, I am new and learning

by trying it out. 

 

There are some pages which use a custom controller and an associated VisualForce page.

 

I also have a custom tab created for a custom object.

 

Is there anyway I can link this  custom tab to a link in my site? How do I get the link (URL?) for the custom

tab?

 

Can I do this in my Site page?

 

<apex:outputLink value="<URL to custom tab>">Custom Object</apex:outputLink> 

 

I really appreciate your help. 

  • February 22, 2010
  • Like
  • 0

I am new to this environment.

 

Here is my controller

 

 

public with sharing class MyController { public ApexPages.StandardSetController setCon { get { if(setCon == null) { setCon = new ApexPages.StandardSetController(Database.getQueryLocator([Select m.Start_Time__c, m.Name__c, m.Name From My_Campaign__c m])); } return setCon; } set; } public String getMyName() { My_Campaign__c mc = [Select m.Name From My_Campaign__c m Where Type__c = 'SALE']; return mc.name; } public Integer getMyCount() { Integer count = getMyCampaigns().size(); return count; } public List<My_Campaign__c> getMyCampaigns() { List<My_Campaign__c> campaigns = (List<My_Campaign__c>) setCon.getRecords(); String output = ' '; for (My_Campaign__c mc : campaigns) { output += ' ' + mc.Name__c + ' '; } System.debug('\n\n>>>>> Output : \n' + output); return campaigns; }}

 

 Here is my visualForce markup

 

 

<apex:page title="My Campaign Page {!$User.FirstName}" showHeader="false" controller="MyController">This is your new page for the {!name} controller. <br /> This is your new page for the [{!$User.userName}] controller. <br /> This is MyUser {!myUser} controller. <br /> This is the count {!myCount} controller. <br /> This is the name [{!myName}] <br /> <apex:pageBlock title="Campaigns"> <apex:pageBlockTable value="{!myCampaigns}" var="c"> <apex:column value="{!c.Start_Time__c}" /> <apex:column value="{!c.Name__c}" /> <apex:column value="{!c.Name}" /> </apex:pageBlockTable> </apex:pageBlock></apex:page>

 

Everything prints (including myName, myCount) except the "pageBlockTable"!!, so this might not be a security issue.
 
I know I am doing something stupid, but not sure what.
 
How do you go about debugging these kind of problems?
 
Thanks  a bunch!! 

 

 

  • February 20, 2010
  • Like
  • 0

I am new to this environment.

 

I am developing a Site and have enabled user registration and authentication for a user.

 

I have to develop a controller with some of my custom objects I have created for the site. I need

access to the User object (not the standard 'Account' object). I am not sure if I should develop

a custom controller or extend a standard controller to get the user attributes.

 

In any case how can I access the User object for the site  in my controller?

 

Thanks, 

 

 

  • February 19, 2010
  • Like
  • 0

I developed a custom object and a "Page Layout" for the custom object. I also see it in the tab of my app.

 

I am creating a Site and am wondering how would I integrate this tab to my site. I can get the URL for

the page layout and call it from my site, but that does not give me the flexibiltiy to customize my Site.

 

Also, if I take the "controller" approach how will i get the Apex code for the page layout? I can implement

a custom controller and cut and paste the Apex code and put it in my page for the site,

 

Thanks,

SBK

  • February 18, 2010
  • Like
  • 0

In the absence of a binary data type like blob for a custom object, do I have any other option other than trying to store as a long text?

 

Thanks,
SBK 

  • February 18, 2010
  • Like
  • 0

I am in the process of developing a site where the user logs in if he or she has an account, if not registers. 

 

I am using the standard out of the box login and registration controllers.

 

Once registered and authenticated, if the user wants to access other pages, how would I enforce single sign-on?

 

Is there an out-of-the-box solution for this?


Thanks,

SK 

  • February 15, 2010
  • Like
  • 0

I took Jeff's sample code (http://blog.jeffdouglas.com/2008/11/25/dependent-multilevel-selectlists/) and made a

minor change which is highlighted in red.

 

The multilevel select stopped working after the change. It does not work either in Chrome or Firefox.

 

It doesn't work in IE because of the event="onchange" attribute.

 

What am I doing wrong?

 

 

<apex:page standardController="Opportunity" extensions="MultiSelectController"> <apex:sectionHeader title="Opportunity" subtitle="{!opportunity.name}"/> <apex:form > <apex:pageBlock title="Opportunity" mode="edit"> <apex:outputText value="{!opportunity.Cat1__c}" rendered="false"/> <apex:outputText value="{!opportunity.Cat2__c}" rendered="false"/> <apex:outputText value="{!opportunity.Cat3__c}" rendered="false"/> <apex:pageBlockButtons location="both"> <apex:commandButton value="Save" action="{!save}" /> <apex:commandButton value="Cancel" action="{!cancel}" /> </apex:pageBlockButtons> <apex:pageMessages /> <apex:pageBlockSection title="Master Categories" columns="1"> <apex:pageBlockSectionItem > <apex:outputLabel value="Category 1" for="cbxlevel1"/> <apex:outputPanel styleClass="requiredInput" layout="block"> <apex:outputPanel styleClass="requiredBlock" layout="block"/> <apex:selectList value="{!selectedLevel1}" id="cbxlevel1" size="1" required="true"> <apex:selectOptions value="{!level1items}"/> <apex:actionSupport event="onchange" rerender="cbxlevel2"/> </apex:selectList> </apex:outputPanel> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="Category 2" for="cbxlevel2"/> <apex:selectList value="{!selectedLevel2}" id="cbxlevel2" size="1"> <apex:selectOptions value="{!level2items}"/> <apex:actionSupport event="onchange" rerender="cbxlevel3"/> </apex:selectList> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="Category 3" for="cbxlevel3"/>

<apex:inputText required="true" id="username" value="{!username}"/>

</apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>

 

  • March 04, 2010
  • Like
  • 0

I have multiple select lists. I want the second select list to be rendered only after the user makes a selection in the first list. How would I make it happen using VisualForce, any examples would be appreciated.

 

Since the second list is populated after the first, how can I communicate between the first selection and the controller. I do not want the contoller methods associated with the second list execute before user action in the first.

 

Thanks. 

  • March 04, 2010
  • Like
  • 0

This code works in chrome, not in IE. How would I make it work in IE?

 

 

<apex:pageBlockSectionItem >

<apex:outputLabel value="Value 1" for="cbxlevel1"/>

<apex:outputPanel styleClass="requiredInput" layout="block">

<apex:selectList value="{!selectedId}" id="cbxlevel2" size="1">

<apex:selectOptions value="{!availableValues}"/>

<apex:actionSupport event="onclick" action="{!getStuff}" rerender="cbxlevel2"/>

</apex:selectList>

</apex:outputPanel>

</apex:pageBlockSectionItem>

 

 getStuff does not get fired when I pick something from the selectList. It works on chrome though

 

 Any help would be appreciated. 

 

  • March 04, 2010
  • Like
  • 0

I am sure this is a very simple issue and can be solved easily.

 

I have multiple PageBlocks in my VisualForce page...

 

 

<apex:form >

<apex:pageBlock title="New" mode="edit" id="newCampaignPageBlock">

<apex:pageBlockButtons location="bottom">

<apex:commandButton value="Save" action="{!add}" immediate="true"/>

<apex:commandButton value="Cancel" action="{!cancel}" />

</apex:pageBlockButtons>

<apex:pageBlockSection>

.............. 

</apex:pageBlockSection>

</apex:pageBlck>

<apex:pageBlock title="Update" mode="edit" id="updateCampaignPageBlock">

<apex:pageBlockButtons location="bottom">

<apex:commandButton value="Save" action="{!update}" immediate="true"/>

apex:commandButton value="Cancel" action="{!cancel}" />

</apex:pageBlockButtons>

 <apex:pageBlockSection>

..............

</apex:pageBlockSection> 

  </apex:pageBlck>

 

 

 

 

 

 

 

 

 

 One does "Add" and other "Update".

 

 User can do an Add or Update.

 

 In the above code, when the user just wants to update an existing record and does not

 want to do a new, the page complains that some of the required fields for Add are required.

 

 How would I prevent this? 

 

  • February 25, 2010
  • Like
  • 0

I need the currentTime as a DateTime object to use it my SOQL like :

 

m.End_Time__c < :currentTime

 

where End_Time__c is of type "DateTime".

 

Here is the relevant piece of code

 

 

public Datetime getCurrentDateTime() {

return DateTime.valueOf(System.now().format('yyyy-MM-dd\'T\'hh:mm:ss\'Z\''));

}

 

 

testmethod static void test() {

ApexPages.StandardController controller = new ApexPages.StandardController(new My_Custom_Object__c());

MyController mc = new MyController(controller);

System.debug('>>>>>>>>>>>>>>>> ' + mc.getCurrentDateTime());

 

 When I run the test, I get the following exception :

 

 System.TypeException: Invalid date/time: 2010-02-25T09:50:30Z in the line highlighted red

 

 What is wrong with the date format? Looks ok to me...

 

  Thanks a bunch.. 

 

  • February 25, 2010
  • Like
  • 0

I have a custom object and I want to implement add, update, delete operations on my custom controller.

 

Questions:

 

1. I am not using any of the standard objects, so I do not have to extend any of the standard controllers right?

 

2.  How will I get access to the StandardController in my custom controller. The reason I need the StandradController is to take advantage of the getRecord() and save() function it offers.

 

3. For some reason this code does not work..

 

 

public with sharing class MyController {

public MyCustomObject__c myCustomObject {get;set;}

public MyController() {}

 

pulic PageReference add() {

try {

insert myCustomObject;

} catch (Exception ex) {

ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, ex.getMessage()));

return null;

}

return null;

}

}

 

 There is no exception thrown in my VisualForce page and the record does not insert as well.

 

  Any help in this regard would be appreciated. 

 

  • February 24, 2010
  • Like
  • 0

I am developing a "Site" (a customer portal) on Force.com, I am new and learning

by trying it out. 

 

There are some pages which use a custom controller and an associated VisualForce page.

 

I also have a custom tab created for a custom object.

 

Is there anyway I can link this  custom tab to a link in my site? How do I get the link (URL?) for the custom

tab?

 

Can I do this in my Site page?

 

<apex:outputLink value="<URL to custom tab>">Custom Object</apex:outputLink> 

 

I really appreciate your help. 

  • February 22, 2010
  • Like
  • 0

I am new to this environment.

 

Here is my controller

 

 

public with sharing class MyController { public ApexPages.StandardSetController setCon { get { if(setCon == null) { setCon = new ApexPages.StandardSetController(Database.getQueryLocator([Select m.Start_Time__c, m.Name__c, m.Name From My_Campaign__c m])); } return setCon; } set; } public String getMyName() { My_Campaign__c mc = [Select m.Name From My_Campaign__c m Where Type__c = 'SALE']; return mc.name; } public Integer getMyCount() { Integer count = getMyCampaigns().size(); return count; } public List<My_Campaign__c> getMyCampaigns() { List<My_Campaign__c> campaigns = (List<My_Campaign__c>) setCon.getRecords(); String output = ' '; for (My_Campaign__c mc : campaigns) { output += ' ' + mc.Name__c + ' '; } System.debug('\n\n>>>>> Output : \n' + output); return campaigns; }}

 

 Here is my visualForce markup

 

 

<apex:page title="My Campaign Page {!$User.FirstName}" showHeader="false" controller="MyController">This is your new page for the {!name} controller. <br /> This is your new page for the [{!$User.userName}] controller. <br /> This is MyUser {!myUser} controller. <br /> This is the count {!myCount} controller. <br /> This is the name [{!myName}] <br /> <apex:pageBlock title="Campaigns"> <apex:pageBlockTable value="{!myCampaigns}" var="c"> <apex:column value="{!c.Start_Time__c}" /> <apex:column value="{!c.Name__c}" /> <apex:column value="{!c.Name}" /> </apex:pageBlockTable> </apex:pageBlock></apex:page>

 

Everything prints (including myName, myCount) except the "pageBlockTable"!!, so this might not be a security issue.
 
I know I am doing something stupid, but not sure what.
 
How do you go about debugging these kind of problems?
 
Thanks  a bunch!! 

 

 

  • February 20, 2010
  • Like
  • 0

I am new to this environment.

 

I am developing a Site and have enabled user registration and authentication for a user.

 

I have to develop a controller with some of my custom objects I have created for the site. I need

access to the User object (not the standard 'Account' object). I am not sure if I should develop

a custom controller or extend a standard controller to get the user attributes.

 

In any case how can I access the User object for the site  in my controller?

 

Thanks, 

 

 

  • February 19, 2010
  • Like
  • 0

I am in the process of developing a site where the user logs in if he or she has an account, if not registers. 

 

I am using the standard out of the box login and registration controllers.

 

Once registered and authenticated, if the user wants to access other pages, how would I enforce single sign-on?

 

Is there an out-of-the-box solution for this?


Thanks,

SK 

  • February 15, 2010
  • Like
  • 0