• WesNolte__c
  • SMARTIE
  • 1888 Points
  • Member since 2009
  • Director of Innovation and Thought Leadership
  • Accenture


Badges

  • Chatter
    Feed
  • 71
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 481
    Replies

 

Hi,

 

I have created one app and it consist of standard objects (For e.g. Campaign, Account, Contact.) and some custom objects.

 

I have customized these object as per requiremnt. For. e.g Added few custom fields to every object, Changed Label of Account object to Client etc.

 

I have created Managed Package. My question is when  particular user is going to install my package, does managed package Account object overrides the standard Account object in customers org?

 

Cheers,

Devendra S

why do we actually create a bean class in saleforce? what is the use of it.  can anybody please suggest me any site where a can get a complete onfo abt bean classes and their implementation in salesforce and what re the other classes required. Do i save bean classes as Apex classes only?

I have a related list for student (master-detail) of educational institutions the student has previously attended.

 

Since this list will vary for student to student, I would like to create some sort of repeater that will create a new line of fields that will be entered as new record in the related list.

 

The examples I saw using <apex:repeat> seem to just be to display a list of fields for one record, but not a repetition of the same fields for multiple records.

 

So, anybody know how I can do this?

 

thanks.

  • March 11, 2011
  • Like
  • 0

I've been working with network solutions on how to point a custom domain to a force.com site.  From what I understand, a cname record will only point the www version of the domain to the force.com site.  The non www version will go nowhere.  According to Network Solutions.

 

Does anyone out there have experience with this and know a way around it?  Is that true?  Certainly there are companies whose domains are registered with Network Solutions and are effectively using sites.  I really appreciate any guidance.  Thanks! 

Hi Friends ,

 

I am working on customising the Opportunity line Items functionality,

intially i created a products search page and selecting the products and after clicking on a button (Select) I need to display the selects products similar to the multi line layout .

 

For selecting multple products i have used selectCheckbox in a pagablock table . 

 

 

 <apex:pageBlockTable id="SearchResult" value="{!prodRes}" var="PR"  width="100%" rendered="{!pids.size > 0}">
                    <apex:column headerValue="Select All">
                        <apex:facet name="header">
                              <apex:inputCheckbox id="chkSelectAll" onclick="checkAll(this),checkSelect(this);" title="Select All" />
                         </apex:facet>
                                               
                          <apex:selectCheckboxes value="{!Selected}" id="ids" onclick="checkSelect(this);">
                          <apex:selectOption itemvalue="{!PR.ID}"  />
                          </apex:selectCheckBoxes>
                    </apex:column>  
                    

                    <apex:column rendered="false" >
                          <apex:facet name="header">Product Code   </apex:facet>
                          <apex:outputText value="{!IF((PR.Product2.ProductCode<>''),PR.ProductCode,' - ')}" />
                    </apex:column>

To select all the checkboxes I am using the following script

 

 

function checkAll(cb)
{
//alert(cb.checked);
var inputElem = document.getElementsByTagName("input");
//alert(inputElem.length);
for(var i=0; i<inputElem.length; i++)
{
if(inputElem[i].id.indexOf("ids")!=-1)
inputElem[i].checked = cb.checked;
}
//alert(inputElem[0].checked);
}   

 

 

 

In Order to retrieve the selected products I am using array property variable 'Selected' .

 

 

 public id[] Selected = new  id[]{};
    public id[] getSelected()
    {
       return Selected;
    }
    public void setSelected(id[] slctd)
    {
       this.Selected.addAll(slctd);
    }

 

 

This seems working fine until yesterday the QA team reported with lots of bugs around it, the checkbox selections are not passed onto the variable i used each and every time.  I verified the browser settings enabled the browser script errors. Every thing seems to be fine but the selections kept on  missing and they wont get populated when i hit the Select button and a blank screen with 0 records prevails:

 

Please help me out, is this any issue with selectcheckbox  or my approach is wrong ?

  • February 16, 2011
  • Like
  • 0

I am trying to set up an email template that uses a component which references a class. I think I'm very close, but I can't seem to pass the argument to the class. Any help would be greatly appreciated.

 

If I replace :partnerid in the class with an actual string value....it all works fine.

 

The Class

//```````````````````````````````````````````````````````````````

public with sharing class findPartnerAccountsByPartnerName {

private final List<Account> accounts;

public String partnerid {
      get; set;
    }    

public findPartnerAccountsByPartnerName() {
    
accounts = [select Name,ShippingCity,ShippingState,ShippingPostalCode,
            Type,industry,ShippingCountry,partner_id__c from Account

where Partner_ID__c = :partnerid
 and Inactive_Account__c = False
order by type asc, Name asc];

}
public List<Account> getAccounts() {
return accounts;
}

}

 

//````````````````````````````````````````````````````````````````

 

The Component (snipet)

<apex:component controller="findPartnerAccountsByPartnerName" access="global">
<apex:attribute name="mypartnerid"
    description="This is the ID of the partner."
    type="String" assignTo="{!partnerid}" />
<apex:dataTable cellspacing="5"  value="{!Accounts}" var="a">

 

//````````````````````````````````````````````````````````````````

 

The Email Template

<messaging:emailTemplate subject="Current List of Tactician Customers and Prospects"
 recipientType="Contact" relatedToType="Account"
>
<messaging:htmlEmailBody >
 <html>
 <body >
<p>Below is a list of ...</p>

<c:PartnerCustomers mypartnerid="{!relatedTo.PartnerConnect__c}">
</c:PartnerCustomers>

</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

 

Hello.  I have set up a VF page that sends an e-mail...but am having one issue.  Is there any code that will allow me to omit the "no-reply@salesforce.com on behalf of XXX" text...and instead substitute my "from" e-mail address?


Thanks

I am making a public force site. how can i create a custom template?

I have a Hierarchy Custom setting with one field IsProcessed.

 

My batch apex will run only when the value of  IsProcessed is true. After processing I need to update the value to false. I doubt whether it is possible.

 

Is there a way I can update a custom setting field value using apex.

 

Appreciate your help.

I have a checkbox field, which in my Visualforce page am displaying as 2 radio fields (by request from the business).

 

When trying to set which option is checked, I am always getting the second checked, even if I have checked="false" or checked="".  I cannot seem to set checked=false.

 

 

<apex:pageBlockSectionItem labelStyleClass="checkboxLabel" dataStyleClass="myCheckbox" id="primary1YesBox">
    <apex:outputLabel value="Yes" for="primary1True"/>
        <input type="radio" name="primary1" value="True" id='primary1True'
        onclick="document.getElementById('{!$Component.customField__c}').checked=true" 
        checked="{!IF(opportunity.customField__c=true,'checked','')}" 
        />
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem labelStyleClass="checkboxLabel" dataStyleClass="myCheckbox">
    <apex:outputLabel value="No" for="primary1False"/>
        <input type="radio" name="primary1" value="False" id='primary1False'
        onclick="document.getElementById('{!$Component.customField__c}').checked=false" 
                       checked="{!IF(opportunity.customField__c=false,'checked','')}" />              
</apex:pageBlockSectionItem>

 

 

Right now, the 2nd options is always checked.  How can I get this running so that the first option is checked when customField__c is true?

 

Hello,

 

I have a visualforce page for editing an order-position with two amounts (one per day and one that ist calculated). For beeing new on force.com and with javascript I tried to calculate the second ammount with a very simple operation. But it doesn't work. Can anyone help? Here is my page:

 

<apex:page standardController="Auftragsposition__c" >
<script>
function changeMgges (input)
{
    document.edit-form.edit-block.edit-section.Mgges.value = input * 10 ;
}
</script>
    <apex:sectionHeader title="{!$ObjectType.Auftragsposition__c.label}" subtitle="{!Auftragsposition__c.name}"/>
    <apex:form ID="edit-form">
    <apex:pageBlock id="edit-block" title="{!$ObjectType.Auftragsposition__c.label} Detail" mode="edit">
        <apex:pageBlockButtons >
            <apex:commandButton action="{!save}" value="Speichern"/>
            <apex:commandButton action="{!delete}" value="Löschen"/>
            <apex:commandButton action="{!URLFOR($Action.Auftragsposition__c.Clone,Auftragsposition__c.id)}" value="Duplizieren"/>
        </apex:pageBlockButtons>
        <apex:pageBlockSection ID="edit-section" showHeader="false" columns="2">
            <apex:inputField value="{!Auftragsposition__c.Name}"/>
            <apex:inputField ID="MgTg" value="{!Auftragsposition__c.Gen_Menge_Stk_Tag__c}" onchange="changeMgges(this}');"/>
            <apex:inputField ID="Mgges" value="{!Auftragsposition__c.Gen_Menge_ges__c}"/>
            <apex:inputField value="{!Auftragsposition__c.Genehmigungsstatus__c}"/>
        </apex:pageBlockSection>
   </apex:pageBlock>
   </apex:form>  
 </apex:page>

 

Thanks

Harry

  • September 22, 2010
  • Like
  • 0

According to this page http://blog.sforce.com/sforce/2008/11/adding-a-visualforce-page-to-a-page-layout.html to add a visualforce page to a page layout the controller of the visual force page must match the object you want to add it to the page layout of.

 

What I have seen in reality is like this: if you want to add a VisualForce page to a page layout e.g. of Contacts then the standardcontroller must be set to Contact. At this point the VisualForce page appears in the page layout editor and it can be dragged in. After that you can then change the VisualForce page to have a custom controller and it will continue to work, and will continue to appear in the page layout editor.

 

This is kind of strange behaviour. Does anyone know if it's possible to add custom controlled VisualForce pages to a page layout in a more orthodox way? Is this a bug? I basically want to be able to write one VisualForce page with custom controller and be able to add it to any page layout I like.

  • September 22, 2010
  • Like
  • 0

Hello.  I am fairly new to Apex programming and have been trying to cobble together a solution via an earlier post, in addition to other ideas seen on this board.  That said, I am still having issues.  I would be very appreciative for any guidance.

 

Specifically, I have two custom objects - one each for customers (Customer__c) and deliveries (Deliveries__c).  I am trying to update a field (NumberOfDeliv__c) in the customers object to reflect the current number of deliveries that have a status of “pending” for each customer.  This value is derived by totaling the number of occurrences of “Deliveries__c” records for each customer that have a “DelivStatus__c” value of “pending”.  Due to a separate reason, I must do this update via Apex.

 

I am doing this in two phases. 1) Doing an AggregateResult function to total the number of pending deliveries for each customer…and then 2) Using a map to update the respective value for each customer. 

 

My initial problem is that I am getting an error message "Initial term of field expression must be a concrete SObject: MAP<Id,Customer__c>".

 

Any suggestions on why I am getting this error - or also alternate code ideas to arrive at my overall goal - would be very appreciated.  Thanks.

 

**********************************

 

trigger CountCustomers on Deliveries__c (before insert) {

       
    Map <String, Integer> DeliveryCount = new Map <String, Integer> ();
   
    String DelivID = null;
    Integer nbr = null;
   

 

list<string> DelivList = new list<string>();
for (Deliveries__c dlv : Trigger.new){
if (dlv.DelivStatus__c != null)
DelivList.add(dlv.DelivStatus__c);
}

 

//Counting the occurrences of pending deliveries for each cusotmer (using CustomerID__c)

//The CustomerID__c field is simply a string representation in the Deliveries__c object of the customer record ID


    for (AggregateResult agr: [SELECT  CustomerID__c, count(Id) NumOfCust FROM Deliveries__c
        WHERE CustomerID__c in :DelivList
         AND (DelivStatus__c = 'pending')
           GROUP BY CustomerID__c]){
           
        DelivID = string.valueOf(agr.get('CustomerID__c'));
        nbr = integer.valueOf(agr.get('NumOfCust'));
        DeliveryCount.put (DelivID, nbr);   
        }

List<Id> Cstmrs = new List<Id>{};

 


//Creating Map of CustomerObject
Map <ID, Customer__c> CustFields = new Map <ID, Customer__c>([select id, NumberOfDeliv__c from Customer__c where id in:Cstmrs]);

 

//Looping through the DeliveryObject 
    for(Deliveries__c Deliv : Trigger.new)
    {
    if (Deliv.CustomerID__c != null){
   
//Holding the field updates for each MenuTemsObject
    Customer__c cust = CustFields.get(Deliv.CustomerID__c);
     
              IF(cust.NumberOfDeliv__c == null || (Trigger.isupdate && cust.NumberOfDeliv__c == Trigger.oldMap.get(Deliv.id).Integer.valueOf(DeliveryCount.get(CustFields.Id))))

              cust.NumberOfDeliv__c =  Integer.valueOf(DeliveryCount.get(CustFields.Id));
             
              CustToUpdate.add(cust);
              }
    }
     
              }

I have a visual force page which is displaying results and form based on webservice. Which is working fine.

 

Now i have a scenario. There is a apex command button which should be visible only to User A and not to other users.

 How to make this scenario work in the visual force page??

Hi,

 

I am trying to know if we can catch privilege based exceptions.

 

For example: Assume that , I have a Button ('Testing')on Lead Detail page that calls my Apex Class. The Apex class enforces sharing.The class has Update Operation .

The user has "Read only" Permission to the Lead Record. The user when clicks the Button('Testing'), as described above, would definitely raise an exeption saying insufficient privileges.

 

How can i catch these kind of exceptions and display a message that says "Contact your system Admin".

Any sample code/ ideas is highly appreciated.

 

Thanks,

Sales4ce

 

 

 

Hey guys

 

I just created a new custom object in my sandbox, but it is not visible by other user profiles.

 

The custom object is set to Deployed status and Field Accessibility for the object is set to Read-Only/Required for all profiles.  The custom object is not visible via the APEX Explorer for other user profiles either.

 

Only the Sys Admin profile can see it.

 

Did I forget to set something?

I first tried installing the IDE plugin into RAD since that's what I already had installed.  For some reason, it couldn't actually open the perspective.

 

Then downloaded and unpacked the Eclipse 3.5.2 package.  I added the Force site to Eclipse and it started the plugin install.  However, about halfway through it failed with a repeated error:  "unpack facility not configured" for every package.  Running on XP.   Any suggestions?

 

George

  • August 13, 2010
  • Like
  • 0

Hi guys,

 

I want users to see a pop-up window after their login, and they can only click the "ok" button on the message before they go on to the homepage. Is it possible to do it with VF or there are other ways?

Thanks very much!

 

Hi all,

 

I have some code that looks at CaseTeamTemplates and behaves differently depending on those CaseTeamTemplates. I'm trying to test the code but to do that I need to insert some CTTs. However, I can't do that and then insert, for example, Cases as I get a MIXED_DML_OPERATION error - basically, I can't insert setup objects and non-setup objects in the same test. So.... how can I give my code the necessary test coverage?

 

Anybody encountered this before and managed to work around it?

  • July 26, 2010
  • Like
  • 0

One for the admins.

 

By changing the class declaration of my page controllers (with/without sharing) I can give my classes access to standard objects that customer portal users shouldn't have access to. I'd like to know if this is a security hole and if I'm in danger of it being closed as that would mean vastly changing the user experience for my 1.7 million portal users.

 

Wes

Hello,

 

I've run into some trouble trying to fetch related object fields from a dynamic query using SObjects e.g.

 

 

String qs = 'SELECT account.name FROM Contact LIMIT 1';
SObject s = database.query(qs);

String name = s.get('account.name'); // OR
SObject account = s.get('account');

 So neither of the bottom two lines execute and I really need to fetch that information out and into a generic SObject. Anyone have a solution?

 

Wes

 

 

 

Hello,

 

In this article it's suggested that we use CNAME records to send traffic on custom domain names to our Force.com Sites. With GoDaddy the use of CNAME records for top-level domains is forbidden so I've been forced to use domain forwarding. This is okay for traffic but it seems that because there's a delegated forwarder that Google Analytics thinks all traffic to my domain is coming from this one source. Anyone have some experience with this?

 

Wes

I've thought about this for some time and if the plugin is open sourced we could have many developers creating a handful of features that would help us in our daily development tasks.

 

If you agree please vote for my idea to 'Open source the Force.com IDE'

 

Wes

Hello

 

I've noticed some inconsistencies so I'm a little confused as to what I should believe. The type of code in question might be:

 

 

for(Account a: [SELECT id, (SELECT id FROM Contact) FROM Account]){
// TODO
}

 If I run this query in an anonymous block the profile information says that I've only run one query. If I use this in my Apex code I very quickly hit the query limit. According to the documentation:

 

2 In a SOQL query with parent-child relationship sub-queries, each parent-child relationship counts as an additional query.

 

Has anyone else experienced this? I assume that the documentation is right, but am I interpreting it correctly i.e. I think it means that for each account record that is selected in the above query an addition query is run for it's child contacts. So if I had 2 Accounts with a contact each I would incur a cost of 3 querys.

 

Wes

 

 

For some time I've wondered what the argument might be to use SOSL instead of SOQL. I can't find anything that says it's faster, and it's limited in the field types it can search, and the flexibility of the search results. As far as I've seen every situation that could be contrived as a use-case for SOSL can be done very neatly with SOQL. 

 

I suppose what I'm trying to say is, can you convince me that sometimes I should be using SOSL?

 

Wes

Hey

 

I'd like to make an API call to login, and then redirect a user to a visualforce page that is only available to authenticated users. I can think of one tricky way to do it, but latency would probably be impacted. I'm sure it's as simple as setting some http header parameters and redirecting to the URL but I can't find out what these headers might be called. I did come across an alternative:

 

 

A couple of things to think about:

Is this page going to be hosted on your website?
Is this going to be used for multiple salesforce organizations?
One thing you can do is use the login() API call to get a session id. You will be able to tell if the login fails, and alert the user appropriately.

From there, you will have to redirect the user through the "frontdoor.jsp" page which has the following format:

https://[host].salesforce.com/secur/frontdoor.jsp?sid=[session_id]&retURL=[start_page]
Where:

[host] - varies by organization. Some that I've seen are na1, na2, .... If you are only building this for 1 organization, you could hard-code this value. If you are building the for multiple organizations, you could parse it from the serverUrl property of the returned LoginResult.
[session_id] - get this from the returned LoginResult
[start_page] - this is optional but can be used to "deep link" a user to a page after they've logged in.

 But I'm worried that some part of this URL and/or JSP could change without notice. Any ideas or info you could point me to?

 

Wes

 

Hello

 

I want to authenticate Customer Portal users via the API from a Java platform, but I'd like to hand the user over to a Salesforce customer portal without having to re-authenticate. I've thought of some trickery that might work, but I wondered if there might be a direct way to pass the session id to some Force.com functionality (exposed as a web service perhaps) and have the user seamlessly continue their journey.

 

Wes

Salesforce has some great articles at developer.force.com and the Force.com community has chipped in with some excellent content but there is still something missing.  There’s a beginning book for Salesforce users (Salesforce.com for Dummies) and an advanced Force.com development book (Development with the Force.com Platform) but there is no comprehensive guide for analysts and developers just coming on to the platform. This is the niche that Wes and I want to fill with our new book:

The Salesforce Handbook
A newcomer’s guide to building applications on Salesforce.com and the Force.com Platform

We are targeting this book for business owners, analysts and developers  just getting started. Just think of all the new Vmforce Java developers that will be investigating the Force.com platform in the coming months! So if your boss walks into your office and says, “Let’s look at this Salesforce.com thing and see if we can build something”. We want this to be a reference that you can pick up and essentially find out everything you need to know about Salesforce from a high level with links to other articles, sample code, blogs, Salesforce docs, etc. that interest you.

Salesforce has some great articles at developer.force.com and the Force.com community has chipped in with some excellent content but there is still something missing.  There’s a beginning book for Salesforce users (Salesforce.com for Dummies) and an advanced Force.com development book (Development with the Force.com Platform) but there is no comprehensive guide for analysts and developers just coming on to the platform. This is the niche that Wes and I want to fill with our new book:

The Salesforce Handbook
A newcomer’s guide to building applications on Salesforce.com and the Force.com Platform

We are targeting this book for business owners, analysts and developers  just getting started. Just think of all the new Vmforce Java developers that will be investigating the Force.com platform in the coming months! So if your boss walks into your office and says, “Let’s look at this Salesforce.com thing and see if we can build something”. We want this to be a reference that you can pick up and essentially find out everything you need to know about Salesforce from a high level with links to other articles, sample code, blogs, Salesforce docs, etc. that interest you.

Hello Force.com

 

I've seen many questions on the topic of form validation around the boards and have found quite a neat solution. If you're interested there's a simple (yet fancy-pants) solution available from jQuery, and an article on how to implement it can be found here.

 

Wes 

Hello

 

I've had this issue before with commandLinks but now I'm having it with commandbuttons too. This used to work. Looking at the code it seems some javascript submits the form, but something is a tad wrong there. If I click the button the form submits, but most users are trying to press enter(like they used to do). This seems to be a problem on na7 but not on na6. My page,

 

 

<apex:page controller="EditStandardObjSites" cache="false"> <apex:form > <apex:pageblock > <apex:pageBlockSection > <apex:outputLabel value="{!acc.id}"/> <apex:inputText value="{!name}"/> <apex:commandButton value="Save" action="{!save}" /> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>

 

The controller just has a public string property and and account object, along with a method to save said object. Note: this updates the account name when I press the button, but not if I simply press enter.

 

Any ideas?

 

Wes

 

 

Hey

 

I am able to do the above, but was wondering if it might be a hole that will be closed. Currently if I use the following in sites,

 

 

<apex:page controller="EditStandardObjSites" showHeader="false" cache="false"> <apex:form > <apex:outputLabel value="{!acc.id}"/> <apex:inputText value="{!name}"/> <apex:commandButton value="Save" action="{!save}" /> </apex:form></apex:page>

 

public class EditStandardObjSites{ public String name{get;set;} public Account acc{get;set;} public EditStandardObjSites(){ acc = [SELECT id, name FROM Account LIMIT 1]; } public void save(){ acc.name = name; upsert acc; }}

 Note I've tried with 'with sharing' as well. 

 

From what I've read I shouldn't be able to edit standard objects in Sites. Is this correct? Is the functionality I'm using a hack or expected behaviour?

 

I've guessed that the page is running in the user context, and the class in the system context and that's why this is all working( as well as why it doesn't work if I use the object fields directly within the page).

 

I would like to use this code, but am worried that if it's flagged at some later stage as a hole it might be closed and as a result kill my app.

 

Wes 

 

 

 

Hello

 

We have sites and customer portal set up in our production environment. I just created a developer sandbox from this instance but it seems that no matter what I do re: customer portal and sites setting I end up getting the 'authorsiation required' page if I browse to the URL. This happens with both the secure and non-secure URL.

 

Browsing the settings I've noticed that all the settings are correct, and that the only difference is the sites URL(which is correct). Anyone come across this before? I've even removed all Sites profile access and recreated it, but still I get nada.

 

Wes 

Hello

 

Any ideas how I might know the max and current number of license within an Org? I'd like to redirect to a custom page if I've run out.

 

Cheers,
Wes

Hey

 

My usual discussion forum account (wesnolte) is a bit broken. Each time I login is asks me to verify the account. I click the button and I assume it sends the email, but I don't get it.

 

I do however get replies to ancient threads that I've participated in. Any ideas why I'm not getting the verification email? I'd love to get my account back:)

 

Wes

Hi Team,

 

I wrote one batch apex it was working fine in developer sandbox but if i move that code to Test sandbox it is showing error saying "Apex heap size too large".Please help me in this  and below is the code i wrote.

 

 

  • July 25, 2011
  • Like
  • 0

 

Hi,

 

I have created one app and it consist of standard objects (For e.g. Campaign, Account, Contact.) and some custom objects.

 

I have customized these object as per requiremnt. For. e.g Added few custom fields to every object, Changed Label of Account object to Client etc.

 

I have created Managed Package. My question is when  particular user is going to install my package, does managed package Account object overrides the standard Account object in customers org?

 

Cheers,

Devendra S

One for the admins.

 

By changing the class declaration of my page controllers (with/without sharing) I can give my classes access to standard objects that customer portal users shouldn't have access to. I'd like to know if this is a security hole and if I'm in danger of it being closed as that would mean vastly changing the user experience for my 1.7 million portal users.

 

Wes

Hi All,

 

is there any possibility to use an object in a visualforce page without named as the standardController?

 

Thanks in Advance

--

Chamil Madusanka

 

why do we actually create a bean class in saleforce? what is the use of it.  can anybody please suggest me any site where a can get a complete onfo abt bean classes and their implementation in salesforce and what re the other classes required. Do i save bean classes as Apex classes only?

Hi,

 

I have written a trigger which creates new records(Payment Schedule object, which has master-detail relationship with opportunity) based on some conditions. In addition it also sends email(a notification email) to all the opportunities related those newly created records.

 

Is there any better approach to do this? Each email will contain data with respect to that opportunity. So I cannot use email templates and workflow to fire it.

 

Kindly suggest whether this is best practice..

Hello,

 

I've run into some trouble trying to fetch related object fields from a dynamic query using SObjects e.g.

 

 

String qs = 'SELECT account.name FROM Contact LIMIT 1';
SObject s = database.query(qs);

String name = s.get('account.name'); // OR
SObject account = s.get('account');

 So neither of the bottom two lines execute and I really need to fetch that information out and into a generic SObject. Anyone have a solution?

 

Wes

 

 

 

Hi

I am a newbe on visualforce and controller so I hope an expert can answer me quickly

My issue is in class campaign_member_set,  mycontact.Email does not exist or mylead.Email

So how do I get new input from my user ?

I can only update mycampaignmember with no error

 

Here is my controller code

public class EventController {

    private String myid;
    private Contact mycontact;
    private Account myaccount;
    private Lead mylead;
    private CampaignMember mycampaignmember;
    private Campaign mycampaign;
    String itsacontact;
    String itsalead;
    String initialemail;

    // Extract ID of URL
    public EventController ()
    {
        myid= ApexPages.currentPage().getParameters().get('id');
        mycampaignmember= [select CampaignId, ContactId, LeadId from CampaignMember where id=:myid];
        if (mycampaignmember.ContactId != null)
        {
            itsacontact='true';
            itsalead='false';
        }
        else
        {
            itsacontact='false';
            itsalead='true';
        }
           
    }
   
    public String getitsacontact() {
              return itsacontact;
    }
   
    public String getitsalead() {
              return itsalead;
    }
 
   
    // Liste des options AM,PM,All day
    List<String> Event_selection= new List<String>();
    public void setEvent_selection(String[] Event_selection)
    {
        this.Event_selection = Event_selection;
    }
 
    public String[] getEvent_selection()
    {
        return Event_selection;
    }
   
    public List<SelectOption> getEvent_items()
    {
        List<SelectOption> options = new List<SelectOption>();
        if (mycampaign.Option_1_Name__c != null)
        {
        options.add(new SelectOption('1',mycampaign.Option_1_Name__c));
        }
        if (mycampaign.Option_2_Name__c != null)
        {
        options.add(new SelectOption('2',mycampaign.Option_2_Name__c));
        }
        return options;
    }
   
    public CampaignMember getMycampaignmember() {
      mycampaignmember=[select Option_2__c, Option_1__c, Nom_accompagnant__c, Accompagnant__c from CampaignMember where id=:myid];
      return mycampaignmember;
    }
   
    public Contact getMycontact() {
      if (itsacontact=='true')
      {   
          mycampaignmember=[select ContactId from CampaignMember where id=:myid];
          mycontact=[select Phone, LastName, FirstName, Email, AccountId From Contact where id=:mycampaignmember.ContactId];
          initialemail=mycontact.Email;
          return mycontact;
      }
      else
      {
          return null;
      }
     
     
    }
  
   public Account getMyaccount() {
       if (itsacontact=='true')
      {
          mycampaignmember=[select ContactId from CampaignMember where id=:myid];
          mycontact=[select AccountId From Contact where id=:mycampaignmember.ContactId];
          myaccount=[select Name from Account where id=:mycontact.AccountId];
          return myaccount;
      }
      else
      {
      return null;
      }
     
    }
   
    public Lead getMylead() {
       if (itsacontact=='false')
      {
      mycampaignmember=[select LeadId from CampaignMember where id=:myid];
      mylead=[select Phone, LastName, FirstName, Company, Email From Lead where id=:mycampaignmember.LeadId ];
      initialemail=mylead.Email;
      return mylead;
      }
      else
      {
      return null;
      }
     
    }

   
    // Update Campaign or create a lead
    public Pagereference campaign_member_set()
    {
         String newemail;
        
         try{
         update mycampaignmember;
        
         if (itsacontact=='true')
         {
            
newemail=mycontact.Email;
         }
         else
         {
             newemail=mylead.Email;
         }
        
         PageReference p = Page.Success_page;
         p.setRedirect(true);
         return p;
        }
        catch (Exception e)
        {
         PageReference p = Page.Failure_page;
         p.setRedirect(true);
         return p;
        }
        
     }

 

Here is my visualforce page

<apex:page showHeader="false" controller="EventController">
<script>
function setCheck (input) {
     //alert(input.checked);
     //alert(input.value);
     //myname=input.name;
     //document.getElementsByName(myname)[2].checked = true;
}

</script>

 

    <apex:pageBlock rendered="{!itsacontact}">
    <apex:form >
    <apex:panelGrid columns="2">
      Prénom<apex:inputText value="{!mycontact.FirstName}"/><p/>
      Nom <apex:inputText value="{!mycontact.LastName}"/><p/>
      Email <apex:inputText value="{!get .Email}"/><p/>
      Téléphone <apex:inputText value="{!mycontact.Phone}"/><p/>
      Société <apex:inputText value="{!myaccount.Name}"/><p/>
      </apex:panelGrid>
      </apex:form >
     </apex:pageBlock>
    
    <apex:pageBlock rendered="{!itsalead}">
    <apex:form >
    <apex:panelGrid columns="2">
      Prénom<apex:inputText value="{!mylead.FirstName}"/><p/>
      Nom <apex:inputText value="{!mylead.LastName}"/><p/>
      Email <apex:inputText value="{!mylead.Email}"/><p/>
      Téléphone <apex:inputText value="{!mylead.Phone}"/><p/>
      Société <apex:inputText value="{!mylead.Company}"/><p/>
      </apex:panelGrid>
      </apex:form >
     </apex:pageBlock>
     
     <apex:form >
       <apex:selectCheckboxes layout="lineDirection" value="{!Event_selection}" onclick="setCheck (this);">
            <apex:selectOptions value="{!Event_items}" />
       </apex:selectCheckboxes><p/>
      <p/>
      <apex:outputPanel >
        <label>Accompagnée de : </label><input id="option4" type="checkbox"/>
        <apex:inputText value="{!mycampaignmember.Nom_accompagnant__c}"/>
      </apex:outputPanel>
      <p/>
     <apex:commandButton value="Valider" action="{!campaign_member_set}"/>
    </apex:form>
</apex:page>

 

 

I am trying to develop a flow of successive pages to collect opportunity data and external data on separate pages.  The external data needs to be collected in an iframe pointing to my own site as there is a strict requirement for this.  Is it possible to override the save/save and new to always collect the basic force.com data and then display a separate visual force page right after that when either button is selected.  In the case of save and new, it would go to the second step before displaying a new data entry page.  Thanks in advance

I have a related list for student (master-detail) of educational institutions the student has previously attended.

 

Since this list will vary for student to student, I would like to create some sort of repeater that will create a new line of fields that will be entered as new record in the related list.

 

The examples I saw using <apex:repeat> seem to just be to display a list of fields for one record, but not a repetition of the same fields for multiple records.

 

So, anybody know how I can do this?

 

thanks.

  • March 11, 2011
  • Like
  • 0

I'm struggling with the order-of-execution during a VisualForce AJAX postback request and the appropriate way to nest-components that might need to rerender each other.

 

The documentation (http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_postback_request.htm ) has 4 key steps:

 

  1. View Deserialization
  2. Evaluate expressions and all method calls including those on custom component controllers
  3. Evaluate the action that triggered the postback
  4. Render view -> HTML sent to browser

 

I'm getting frustrated by the second step, specifically all method calls.  From what it appears, any public methods (specifically a getter) that are used in a view are called before the action method gets call even if these methods are not binding anything in the View State.

 

The example below illustrates that getDisplayedList method gets called immediately after view state deserialization and then again during the rendering of the view.  In my toy example, I lazy-load a list of strings based on the iCount member variable.  In my real-world application I'm actually using a SOQL query to dynamically fetch a list of S-Objects to display to the user. 

 

 

<apex:page controller="LazyLoadController">

<apex:form id="theWrapper">
	<apex:repeat value="{!DisplayedList}" var="s">
		{!s}
	</apex:repeat>
	
	<apex:commandLink value="refresh" rerender="theWrapper" />
	
	<div>
	iCount : <b>{!iCount}</b>
	</div>
</apex:form>

</apex:page>

public with sharing class LazyLoadController {

	public LazyLoadController(){
		this.iCount = 5;
	}

	public Integer iCount {get; set;}
	
	private Transient List<String> t_theList;
	
	// I want to be able to gurantee getDisplayedList() only gets executed during the rendering of the Component and not during "Postback" validation
	public List<String> getDisplayedList(){
		if(this.t_theList == null){
			// The real use case would Query the Database for the appropriate objects.
			
			this.t_theList = new List<String>();
			for(Integer i=0 ; i< this.iCount; i++){
				this.t_theList.add('[' + String.valueOf(i) + ']');
			}
		}
		iCount++;
		return this.t_theList;
	}
	
	
	public PageReference refresh(){
		// In theory I want to be able to execute code here that is guranteed to be executed before getDisplayedList
		return null;
	}
}

 

Unfortuntaely, because getDisplayedList gets called before I execute any code in my post-back method, I do not have the opportunity to do any additional logic before the Transient list of strings ( t_theList) gets initalized.

 

One quick and obvious solution would be to set the Transient list to null in the postback method and force the list to be regenerated or remove the lazy-loading indirection and initalize the list directly.

 

I typically would do this except for the fact I want this controller to be a component-controller that can be easily dynamically rerendered.  I've outlined the at the high-level what I want to do below.

 

 

<apex:page controller="ParentController">
	<!-- Code that will create a new Task and 
		re-render the component that should display 
		a list containing the newly created task 
		-->
	<apex:commandLink value="addNewTaskAndRefreshList" rerender="componentWrapper" />
	
	<apex:outputPanel id="componentWrapper">
		<c:lazyLoadComponent 
			countOfTasks=5/>
		</c:lazyLoadComponent>
	</apex:outputPanel>
	
</apex:page>

 

public with sharing class ParentController {
	public PageReference addNewTaskAndRefreshList(){
		Task t = new Task();
		//...
		insert t;
		return null;
	}
}

 

 

Pretend for example, that my LazyLoadController is now displaying a list of tasks that are dynamically loaded from the database.  I'd like to be able to put this component onto my page and re-render it so that it dynamically refreshes the list of Tasks.  For example, in the ParentController I want to insert a new task, refresh the child-component and display the new task.  Currently, the Lazy-Loading happens in Step 2 (method calls) of the order of execution before Step 3 (Invoke PostBack method).

 

Does anyone have a suggestion for how I can re-design my code so that I can achieve the above behavior?

 

Thanks

Parker

 

I've been working with network solutions on how to point a custom domain to a force.com site.  From what I understand, a cname record will only point the www version of the domain to the force.com site.  The non www version will go nowhere.  According to Network Solutions.

 

Does anyone out there have experience with this and know a way around it?  Is that true?  Certainly there are companies whose domains are registered with Network Solutions and are effectively using sites.  I really appreciate any guidance.  Thanks! 

I recently ran into a problem where a Visualforce page was throwing a cryptic error message related to a custom picklist (apex:selectList).  The complete error was something like:

 

j_id0:frmSelectProductsServicesw:filterSection:j_id10:j_id15:selectedPF:Validation Error: Value is not valid

 

After some digging and research here in the forums, testing and a call to Tech Support it seemed the cause and solution for similar problems didn't quite apply.  I eventually found the solution (in my case) and wanted to share it in hopes that it would help others.

 

The cause was due to a conflict between the underlying stored data in SFDC and how certain controls behave when rendered to HTML.  In this case, there was a double space embedded in the underlying data between the Z and I in the value Product.Family field (eg. ‘S&U Z  Internal’). 

 

Background:

  1. For Visualforce controls (ie. apex.outputField, apex.outputText, apex:selectList) and modes (ie. edit and view), every control ultimately must renders as HTML.  Typical HTML rendering behavior suppresses any extra spaces within text.  That is why it is common practice to use the &nbsp to chain multiple spaces together. 
  2. In this case, the underlying stored data in the Product.Family field included a double space:
          ‘S&U Z  Internal’
    however when it was rendered to the screen, the HTML took control and used only a single space:
          ‘S&U Z Internal’
  3. Once the user clicked the submit button to begin the search, the picklist in this case tried to cross-reference the selected value with the actual data that was bound to the control and found no match, thus the cryptic error that was returned - “selectedPF:Validation Error: Value is not valid”.
          ‘S&U Z  Internal’ != ‘S&U Z Internal’

 

Funny thing is, when the underlying data is rendered in a input textbox (ie. apex.inputText), the double space is displayed.  Once I removed the double space from the underlying data, the error was fixed.

 

Hopefully this solution helps.

Thanks to Sreenivas Voore in Premiere Tech Support.