• DCS
  • NEWBIE
  • 25 Points
  • Member since 2009

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 19
    Questions
  • 12
    Replies

I am doing a real time callout to a SAP webservice. If there is an error during the callout a friendly message is displayed to the user. We do not come to know about this error unless the user notifies us or it comes to the attention of people responsible for the external webservice.

 

I tried handling the exception at Apex side by inserting a record in  a custom Error object (which has built in workflow rules) or sending out email to the developers/administrators so that the developers/Admins are notified instantly.

 

But none of these(sending email or DML ) is not supported during a callout which is really bad. I hope there is a workaround to this. Has someone come across this ? If so how are you handling this.

  • April 06, 2010
  • Like
  • 0

I have a custom object called 'Sample Request' which has look up  relationship to lead object and contact object. There are many record types for Contact and also for Lead as my company has business in different regions. Due to the same reason there are different page layouts and record types for 'Sample Request' object also.

 

 

 

To make it simple for Ex: say there are

2 rec types and page layouts for Contact - C1 and C2 and there are

2 rec types and page layouts for Lead  - L1 and L2 and there are

4 rec types and page layouts for Sample Request - R1, R2, R3, R4

 

I have created a custom button (VF page and controller) called 'Create sample Request' in Lead and Contact page that takes user to the appropriate 'Sample Request' page depending on the originating record type of contact or Lead. 

 

The apex controller code checks various record types as below

if the record type is C1 forward the user to page with Rec type as R1

if the record type is C2 forward the user to page with Rec type as R2

if the record type is L1 forward the user to page with Rec type as R3

if the record type is L2 forward the user to page with Rec type as R4

 

When there is a new rec type added for a different business unit, changes are needed in the code to handle the new Rec Type. This needs code deployment to production apart from config changes.  

 

I am looking into creating a custom object that will hold setting like this that can be used by the Apex controller to forward user to the correct page layout. In this case it is a simple mapping of Rec type to Rec type in the custom object. This will make the code generic enough, prevent the hardcoding of record types in the code and reduce maintenance with future config changes. When there is a new record type, a new record need to be added in the custom object and we are good to go.  

 

I looked into using custom settings, but I am not able to figure out if that can be used for something like this. I am sure this hardcoding in code is something that everyone runs into at one point or other. I would like to know how others are handling scenarios like this. Any suggestions/comments would be very helpful.

 

Thanks!

 

 

 

 

 

 

 

Message Edited by DCS on 04-01-2010 06:18 AM
  • April 01, 2010
  • Like
  • 0

I have a requirement where I need to send sample requests to Contact or Lead which is achieved with a 'Sample Request' custom object with look up relationship to 'Contact' as well as 'Lead'. There will a 'Sample Request' button in the Contact Page and also one on the Lead Page. When user clicks on Sample Request from Contact, I should show only Contact look up whereas when it comes from Lead, it should show only the Lead look up. I had to create 2 page layouts to accomplish this and assign unique record types  for the 'Sample Request' custom object.

 

I am wondering if this can be achieved similar to how 'Name' field works in 'Task' UI. In 'Task' standard object there is field called name which is of datatype ' Lookup(Contact,Lead)  ' This provides a UI which  contains  a dropdown with 'Lead' or 'Contact' values together with a text field and a lookup icon.

 

Doing some research I do not think this is a standard feature available.

 

If this can be done, I need only one page layout.

 

Any suggestions

  • March 16, 2010
  • Like
  • 0

This is more kind of best practice question. I my application, there are apex classes that is making outside webservice calls. Currently the endpoint url is within the apex class. The endpoint urls from the test sandbox calls out to test webservice whereas production calls out to the production webservice.

 

Since the endpoint urls are different, before deploying to production, I need to change the class to call production endpoint url and then later change in test sandbox to call test webservice. 

 

 

What is the  best place to store similar configuration setting so that this remain outside of the apex code.I have read in the forum to use seperate custom configuration objects? Is there another way?

  • November 12, 2009
  • Like
  • 0

I am using CVS for version control and have a plugin with Eclipse. When I try to Sync with CVS, all my apex classes and pages show up as outgoing changes. When I double click the file and see the comparison, there are no differences between the remote version and local version. I do 'Overide and Update' from CVS and the file disappear for a moment. But then the workspace starts building ( I have enabled the option 'Build automatically' in my IDE) and the file show up again as outgoing change in 'Synchronize' view.

 

I am not sure if CVS picks up the file as an outgoing change due to the datetime change in the file when the build happens. I am curious to know if someone else has the same issue and how to resolve it. It would be nice to see only those files that are changed when you sync with CVS.

 

 

  • October 22, 2009
  • Like
  • 0

I am writing a test method in which I am inserting a user.  When I try to set a value for the CommunityNickname

field, it gives a compilation error message as follows

 


Save error: Invalid field communityNickname for SObject User 

 

Is this field not accessible?  

 

  • October 14, 2009
  • Like
  • 0

I want to pass one parameter when user clicks on a command button.

 

I tried the following

 

                   <apex:commandButton action="{!registerForEvent}" value="Register" title="Register">
                        <apex:param name="eventId" value="{!r.id}" assignTo="{!eventId}"/>
                    </apex:commandButton>    

 

It does not work. The eventid value is coming as null in the controller. 

 

I was searching through the posts and found a few that says that this is a bug and parameters cannot be passed with command button. Some posts say, it works using assignTo attribute and having proper getter and setter methods for the assignTo variable. It is not working for me.

 

Is it working for anyone? Please let me know.

 

  • July 29, 2009
  • Like
  • 0

In the visual force controller,  I want to get to the default record type of contact object that user can create.

 

Any idea how can I query that. 

 

User profile lists the default recordtypes for all the standard and custom objects. So I guess from userprofile this information would be available. But I am not able to figure it out. Any help?

  • July 16, 2009
  • Like
  • 0

If I insert record through a controller from a visual force page and does not specify the owner id,

who would be the owner of the inserted record ? - The executing user? or the owner of the controller class?

 

  • June 18, 2009
  • Like
  • 0

Can some one please clarify  execution mode of controller extension. In Visual force reference, it is documented as below.

My understanding is controller extension enforces the sharing rules of the user. but the line in blue below is misleading. 

Does this mean that custom methods in the extension controller will execute in system mode? Some one please clarify.

 


• A controller extension is a class written in Apex that adds to or overrides behavior in a standard or custom controller.
Extensions allow you to leverage the functionality of another controller while adding your own custom logic.
Because standard controllers execute in user mode, in which the permissions, field-level security, and sharing rules of the
current user are enforced, extending a standard controller allows you to build a Visualforce page that respects user permissions.

Although the extension class executes in system mode, the standard controller executes in user mode. As with custom
controllers, you can specify whether a user can execute methods in a controller extension based on the user's profile.

  • June 17, 2009
  • Like
  • 0

I have an apex command button as below calling a custom controller method

 

<apex:commandButton value="Save" id="Save" action="{!save}" onclick="this.disabled=true;"/>

 

The method saves the item and navigate to another page. It is not a partial page update call.

 

I would like to disable button after the first click. I tried using onclick and calling a javascript to set the disabled status as true. When I use onclick even to make the javascript call, the button becomes disabled, but the save method on the controller is not being called.

 

I changed the button onclick event  to just alert 'hi' as below and it works. It alerts and then also makes the method call

 

<apex:commandButton value="Save" id="Save" action="{!save}" onclick="alert('hi');"/> 

 

But when I added the code to disable the button too as shown below, it stops calling the controller method.

 

<apex:commandButton value="Add Item(s)" id="addItem" action="{!addItems}" onclick="alert('hi');this.disabled=true;"/>

 

Is there a different way to solve this?

Message Edited by DCS on 05-07-2009 02:03 PM
  • May 07, 2009
  • Like
  • 0

I am trying to convert a Scontrol to Visual force page. I have some trouble getting the same look and feel as of the scontrol in Visual force.

 

The Scontrol uses the style of the custom20tab in style sheet  

/sCSS/12.0/Theme2/allCustom.css.

 

'body' element of scontrol has class attribute as custom20tab - <body class="Custom20Tab  editPage" Onload="display();"> 

When this SControl page opens, it selects one the of custom tabs in the application, but has the coloring scheme of the custom20tab selector.

 

I use the 'tabstyle' attribute in <apex:page> component for the converted visual force page so that the one of the existing tabs gets selected. But I am not able to successfully override the styles with the 'custom20tab' styles.

 

Any ideas?

 

 

  • May 01, 2009
  • Like
  • 0

I need to call  an external service from VF. I am trying to generate apex classes from WSDL and running into issues for import and includes as shown below.

 

Failed to parse wsdl: Unknown element: import

Failed to parse wsdl: Found schema import from location CLiteratureItems.xsd. External schema import not supported

Failed to parse wsdl: Unsupported Schema element found http://www.w3.org/2001/XMLSchema:include. At: 7:57

 

I have seen some posts on these and suggestion is to rework on the wsdl to bring in the external wsdl's into the same. 

 

Is there any documentation on how to get this resolved. 

 

Really appreciate your help.

Message Edited by DCS on 04-23-2009 01:55 PM
  • April 23, 2009
  • Like
  • 0
System log does not seem to work consistently. Is anyone else facing the same problem? Is there a way to see the debug logs other than from the 'System log' link at the top of the page
Message Edited by DCS on 04-21-2009 11:50 AM
  • April 21, 2009
  • Like
  • 0
Can I create an array of checbox (group of checkbox with the same name ) with <apex:checkbox> component?
  • April 21, 2009
  • Like
  • 0

Do I need to use setter method to get the value of  <apex:inputText> in visual force? For ex: I have a VF page which has a search input field and a search command button

 

       <apex:pageBlock >
         
            <apex:inputText id="searchText" size="50" />
            <apex:commandButton action="{!doSearch}" value="Search" reRender="productList" status="status" />
           
       </apex:pageBlock >  
      
      
      

In the controller, I have a doseacrch() method, but I am not able to get the searchText value as  

public void doSearch()

{

 

 String searchText = ApexPages.currentPage().getParameters().get('searchText');

 

}

 

whereas if I have a hidden field in the form, I can get the value using ApexPages.currentPage().getParameters().get('hiddenfieldname);

 

Can some one please explain

    

Message Edited by DCS on 04-17-2009 01:27 PM
  • April 17, 2009
  • Like
  • 0
I am new to Visual force. I am confused with the state of controller. Is controller like a session bean in java? Does it maintain the state of member variables  during the entire session. Or does each request reinitialize the member variables?
  • April 17, 2009
  • Like
  • 0
Pagination does not work on the search results in the developer.force.com sites, ex: if there are 18 results for the search term, and say 10 results displays per page, clicking on page no 2, refreshes the screen and displays page 1 again.
  • April 14, 2009
  • Like
  • 0
Can I add a custom field on User Roles. I do not see an option to do that. Can some one please confirm?
  • March 19, 2009
  • Like
  • 0

I am doing a real time callout to a SAP webservice. If there is an error during the callout a friendly message is displayed to the user. We do not come to know about this error unless the user notifies us or it comes to the attention of people responsible for the external webservice.

 

I tried handling the exception at Apex side by inserting a record in  a custom Error object (which has built in workflow rules) or sending out email to the developers/administrators so that the developers/Admins are notified instantly.

 

But none of these(sending email or DML ) is not supported during a callout which is really bad. I hope there is a workaround to this. Has someone come across this ? If so how are you handling this.

  • April 06, 2010
  • Like
  • 0

I have a custom object called 'Sample Request' which has look up  relationship to lead object and contact object. There are many record types for Contact and also for Lead as my company has business in different regions. Due to the same reason there are different page layouts and record types for 'Sample Request' object also.

 

 

 

To make it simple for Ex: say there are

2 rec types and page layouts for Contact - C1 and C2 and there are

2 rec types and page layouts for Lead  - L1 and L2 and there are

4 rec types and page layouts for Sample Request - R1, R2, R3, R4

 

I have created a custom button (VF page and controller) called 'Create sample Request' in Lead and Contact page that takes user to the appropriate 'Sample Request' page depending on the originating record type of contact or Lead. 

 

The apex controller code checks various record types as below

if the record type is C1 forward the user to page with Rec type as R1

if the record type is C2 forward the user to page with Rec type as R2

if the record type is L1 forward the user to page with Rec type as R3

if the record type is L2 forward the user to page with Rec type as R4

 

When there is a new rec type added for a different business unit, changes are needed in the code to handle the new Rec Type. This needs code deployment to production apart from config changes.  

 

I am looking into creating a custom object that will hold setting like this that can be used by the Apex controller to forward user to the correct page layout. In this case it is a simple mapping of Rec type to Rec type in the custom object. This will make the code generic enough, prevent the hardcoding of record types in the code and reduce maintenance with future config changes. When there is a new record type, a new record need to be added in the custom object and we are good to go.  

 

I looked into using custom settings, but I am not able to figure out if that can be used for something like this. I am sure this hardcoding in code is something that everyone runs into at one point or other. I would like to know how others are handling scenarios like this. Any suggestions/comments would be very helpful.

 

Thanks!

 

 

 

 

 

 

 

Message Edited by DCS on 04-01-2010 06:18 AM
  • April 01, 2010
  • Like
  • 0

I am writing a test method in which I am inserting a user.  When I try to set a value for the CommunityNickname

field, it gives a compilation error message as follows

 


Save error: Invalid field communityNickname for SObject User 

 

Is this field not accessible?  

 

  • October 14, 2009
  • Like
  • 0

I want to pass one parameter when user clicks on a command button.

 

I tried the following

 

                   <apex:commandButton action="{!registerForEvent}" value="Register" title="Register">
                        <apex:param name="eventId" value="{!r.id}" assignTo="{!eventId}"/>
                    </apex:commandButton>    

 

It does not work. The eventid value is coming as null in the controller. 

 

I was searching through the posts and found a few that says that this is a bug and parameters cannot be passed with command button. Some posts say, it works using assignTo attribute and having proper getter and setter methods for the assignTo variable. It is not working for me.

 

Is it working for anyone? Please let me know.

 

  • July 29, 2009
  • Like
  • 0

Hi:

 

I'm new to Visualforce and I'm trying to retrieve the size of a VisualforceArrayList.

 

I'm aware that I can use the <apex:repeat> component this way:

 

<apex:repeat value="{!Opportunity.OpportunityLineItems}" var="line">
  <tr>
   <td>{!line.PricebookEntry.ProductCode}</td>
   <td>{!line.PricebookEntry.Name}</td>
   <td>{!line.Quantity}</td>
   <td><apex:OutputField value="{!line.UnitPrice}"/></td>
   <td><apex:OutputField value="{!line.TotalPrice}"/></td>
 </tr>
</apex:repeat>

 

But what if I just want to know the number of LineItems inside my Opportunity.OpportunityLineItems VisualforceArrayList?

 

Is there a way to achieve this?

Something like .size() for ArrayLists or .length for Arrays in Java?

 

The other problem I have is that I'm using a Professional Edition License and it seems that I'm not able to create a Visualforce Custom Controller so I need to do it from the actual visualforce page.

 

Help would be very appreciated.

 

 

 

  • July 29, 2009
  • Like
  • 0

In the visual force controller,  I want to get to the default record type of contact object that user can create.

 

Any idea how can I query that. 

 

User profile lists the default recordtypes for all the standard and custom objects. So I guess from userprofile this information would be available. But I am not able to figure it out. Any help?

  • July 16, 2009
  • Like
  • 0

Can some one please clarify  execution mode of controller extension. In Visual force reference, it is documented as below.

My understanding is controller extension enforces the sharing rules of the user. but the line in blue below is misleading. 

Does this mean that custom methods in the extension controller will execute in system mode? Some one please clarify.

 


• A controller extension is a class written in Apex that adds to or overrides behavior in a standard or custom controller.
Extensions allow you to leverage the functionality of another controller while adding your own custom logic.
Because standard controllers execute in user mode, in which the permissions, field-level security, and sharing rules of the
current user are enforced, extending a standard controller allows you to build a Visualforce page that respects user permissions.

Although the extension class executes in system mode, the standard controller executes in user mode. As with custom
controllers, you can specify whether a user can execute methods in a controller extension based on the user's profile.

  • June 17, 2009
  • Like
  • 0

I have an apex command button as below calling a custom controller method

 

<apex:commandButton value="Save" id="Save" action="{!save}" onclick="this.disabled=true;"/>

 

The method saves the item and navigate to another page. It is not a partial page update call.

 

I would like to disable button after the first click. I tried using onclick and calling a javascript to set the disabled status as true. When I use onclick even to make the javascript call, the button becomes disabled, but the save method on the controller is not being called.

 

I changed the button onclick event  to just alert 'hi' as below and it works. It alerts and then also makes the method call

 

<apex:commandButton value="Save" id="Save" action="{!save}" onclick="alert('hi');"/> 

 

But when I added the code to disable the button too as shown below, it stops calling the controller method.

 

<apex:commandButton value="Add Item(s)" id="addItem" action="{!addItems}" onclick="alert('hi');this.disabled=true;"/>

 

Is there a different way to solve this?

Message Edited by DCS on 05-07-2009 02:03 PM
  • May 07, 2009
  • Like
  • 0
Pagination does not work on the search results in the developer.force.com sites, ex: if there are 18 results for the search term, and say 10 results displays per page, clicking on page no 2, refreshes the screen and displays page 1 again.
  • April 14, 2009
  • Like
  • 0