• lnryan
  • NEWBIE
  • 85 Points
  • Member since 2008

  • Chatter
    Feed
  • 3
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 58
    Questions
  • 77
    Replies

I have a dynamically generated soql statement. At the end of the statement I add 'AND Contract_Member__c ... 'and I get this error... System.QueryException: unexpected token: '{'  

 

String corpMemberQuery = 'SELECT ID, Corporate_Contract__r.Name, Contract_Member__c FROM Corp_Contract_Member__c WHERE Is_Active__c = true';

 

Database.query(corpMemberQuery+
                    ' AND Contract_Member__c IN ('+memMap.keySet()+')' ))

 

Any ideas on

1. If i can use keyset() in an 'IN' clause, keySet() returns a set??

2. Can I cast a Set to a List ??

Hi,

 

Is there a way to prepopulate and show a read only field on the new/edit form (where the data is entered for the record)

 

Thanx

I have a select list and I want it to set the value of a query string parameter. The ideal (obvious) option is not available ...ie <apex:selectRadio value="{!$CurrentPage.parameters.variablename}" ></apex:selectRadio>

 

I've also tried including an actionsupport both at the select option and the select list level and neither work.

  • March 30, 2011
  • Like
  • 0

I'm trying to create a single page or two page wizard (without a custom controller) that will provide inline editing for both accounts and the account's contacts but it seems i cannot add inline editing support tag to the data table containing the account's contacts. Can anyone confirm whether or not the inline editing support is limited to the controlling object or to a single dataset?

Thanks.

  • February 18, 2011
  • Like
  • 0

We have a visualforce dashboard that shows a pre-filtered list of recently updated (ie Approved/Denied) or submitted approvals. It's controlled with a controller that explicitly specifies 'without sharing'. It works fine in the sandbox displaying both open and completed approvals, but in the production environment it only show the given user's pending approvals.

 

Any ideas on how to fix this?

  • January 20, 2011
  • Like
  • 0

We are experiencing a problem with how Images within Rich Text fields display in custom VF Email Templates: when we preview the templates the images render fine, but when we test sending them out, the images display only the typical broken-image icon (ie white box, red X).

 

Does anyone know how to fix this? Is there a setting in the <apex:outputField> or a way to use a custom controller to 'unpack' the image references within the rich text field and replace them with resource references, actual image tags, etc?

 

Additional Details:

  • The rich text field is already being rendered using the <apex:outputField> tag
  • The field occurs within a custom VF component embedded in the email
  • The VF component also uses a custom controller.
  • I have already confirmed that the rendering issue is unrelated to the component / controller

 

  • October 25, 2010
  • Like
  • 1

I'm trying to find away around the fact that there's no StandardListController for the CampaignMember object (wtf!?).

 

I need to create a custom button that passes IDs for the selected campaign members to a visualforce page (or if that's really impossible, an apex class).

 

Can someone please advise on how I could do this?

 

Thanks,

Lindsay

 

  • October 15, 2010
  • Like
  • 0

The following formula isn't properly recognizing blank currency fields.

 

Here's the formula:

Adjustment__c*BLANKVALUE(TieredPrice__c, ListPrice)

 

Where Adjustment is a percent field, TieredPrice__c is a currency field. When TieredPrice__c is blank, the result of the formula is 0.00. The same applies when i try to use null instead. We can't rely on TieredPrice__c=0 as the condition, because 0.00 is a valid TieredPrice__c sometimes.

 

Is this a bug? TieredPrice__c isn't a formula field so there's no option to specify whether to treat blanks as null or 0.

  • September 30, 2010
  • Like
  • 0

I have a procedure that can be triggered by an update to or deletion of any one of several inter-related objects based around Opportunities. The trigger retrieves the related Opportunity and all the relevant sub-records in all the relevant objects by way of a single query in the form of

 

 

Opportunity[] opps = Database.query('SELECT [...fields and children...] FROM Opportunity WHERE Id IN (SELECT Opportunity__c FROM '+childObjectName+' WHERE Id IN :triggeredIds)');

 

The trouble, of course, is that when this is coming from a delete trigger, it finds no Opportunities related to the deleted record. I tried putting in the keyword 'ALL ROWS' but when this was placed outside the WHERE clause subselect it returned no records and when it was placed within the WHERE clause subselect (shown below), I received the error "Expecting ')'. Found ALL"

 

FROM Opportunity WHERE Id IN (SELECT Opportunity__c FROM '+childObjectName+' WHERE Id IN :triggeredIds ALL ROWS)');

 

 Does anyone know If there is a proper syntax for retrieving non-deleted parents of deleted child records using subselects?

  • September 24, 2010
  • Like
  • 0

I recently installed the stand-alone Force IDE application for mac and since then it crashes erratically. I'm generally just typing something, though sometimes it happens when I'm trying to restore a view. Can someone point me to some documentation that might help? thanks.

 

  • August 31, 2010
  • Like
  • 0

I'm getting a null pointer exception when I try to use evaluate a checkbox field from my BusinessChannels__c custom setting and the checkbox is unchecked. It seems like kind of a joke to have to set up an if statement like

 

if(null!=bc.get('somefield__c')&&(Boolean) bc.get('somefield__c'))...

 instead of simply

if((Boolean) bc.get('somefield__c'))...

 or simpler

if(bc.get('somefield__c'))...

 

 

am i missing something obvious? thanks!

 

  • August 26, 2010
  • Like
  • 0

A Little Background:

We have developed some feedback loops that aggregate (textual) categorical information from Opportunity Line Items and push it back to the Opportunity, Account, and Contact objects. These feedback fields and their source fields are only used by 2 out of 5 of the groups in our company that use Opportunities, so we've created a Custom Settings dataset for storing the opt-in status of these different groups for various automated enhancements we've developed.

 

The Scenario:

From an after-update Trigger on Opportunities, I need an efficient way to check whether any of the record types within the batch qualify for the feedback summary automation. This controls what fields are included in the SOQL query to fetch extended opportunity data and whether the summary ,method is invoked from the trigger at all. Which is a better way to do this. I could

  1. Perfrom and Aggregate Query grouped by RecordTypes and filtered by the Opportunity IDs from the Trigger. This would then provide a much reduced set of values to iterate through, but would count against my query governor limits without truly providing new data. 
  2. Iterate through the entire set of Opportunities to cull the set of distinct record types. This seems like a bit of a waste since the Opportunity records themselves don't contain any other information that could be processed at this time and they will all have to be iterated over again later when they've been returned with their extended details.
  3. Iterate through the set of Opportunities until a single RecordType qualifies for the extended details. This would solve the immediate scenario and provide minor efficiencies over #2, but is less extensible - ie if we later introduce another automated, opt--in, enhancement this would become a bit useless.

 

What do people think? Personally, I have a strong preference for #1, but I try to make a habit of questioning my preferences...  

    • August 26, 2010
    • Like
    • 0

    How do you get access in APEX to the same global variables that are available in formulas and VisualForce. I'm looking for a non-SOQL based way to access this org-wide and environment-based settings. Particularly, is there a corresponding settings variable to $RecordType?

    • August 24, 2010
    • Like
    • 0

    Hi,

     

    I want to create a page that has the following: 1 enhanced list, 1 panel below that displays a list of detail fields for the records selected from the enhanced list.

     

    How do I get the Ids from the enhanced list without leaving the page? 

    Hi Guys,

     

    I've created a visualforce template that's used with Campaign Members to help coordinate workflows between Sales & Marketing.

     

    The only problem is filling in my name for {!recipient.FirstName} instead of the Lead/Contact Owner that it's addressed to... Any ideas?

     

    I'd put sample code but it's pretty much the merge part i put above....help please...this is just a tad bit urgent for us.

    Questions:

    Is it possible to capture the Lead Convert information in a Before Update trigger in order to override the user's selections:for instance to unflag create opportunity option? If not, could this be integrated into a trigger on the Opportunity that could selectively prevent the opportunity creation and what's the best way to do that? a before trigger or an after trigger?

     

    Context: We've extended the Campaign Management process so that customers who respond to campaign invitations through a web-form on our site reintegrated into the salesforce campaign: their status is updated and an opportunity relating to the campaign offering is created. The one problem we have with this is with Lead campaign members. These require that the sales teams convert the lead before the opportunity can be created. We've also created a lookup to the Opportunity on the Campaign Member record to work around some of the reporting limitations on Campaigns & Campaign Members.

     

    When users forget to check the 'Do not create Opportunity' option, this creates a default opportunity but bypasses the customized opportunity logic we have created specifically for these campaigns. We'd like to capture the lead convert action beforehand in these cases in order to

     

    In the last few weeks, I've noticed an odd behavior within my Force.com IDE Projects. When I save changes to the server it goes through the save process as if successful, but the changes do not get saved to the server and the asterix still appears beside the code file.

     

    Has anyone else experienced this? Is there a way to fix this.

     

    I updated my projects to the lastest reslease prior to the emergence of this issue. I noticed that my production environment projects give a warning that they need to be updated; however this save issue appears even in my sandbox projects that updated successfully and have thrown no warnings.

     

    Thanks in advance.

    I have two methods within the same class that pass a generic sObject, like so...

    public void updateRecord(sObject s){
    
    /*...do some stuff...*/
    
    //check if s is a Lead and if so try to convert
    Boolean yay = this.tryToConvertLead(s);
    
    /*...do some more stuff */
    
    }
    
    public void tryToConvertLead(sObject cl){
    /*...tries to convert the lead...*/
    //if converted
    if (convertSuccess) cl = [Select ID,... FROM Contact Where Id IN (Select ConvertedContactID From Lead Where IsConverted=true AND Id = :cl.Id];
    return;
    }

     

    My understanding was that sObject instances are automatically passed by reference and that because of this I don't need to explicitly pass back the sObject that has now been assigned a fresh record, but this is not working.

     

    Is this because it's what i'm passing is a generic sObject and not a specific sObject (ie Lead / Contact)?

    Is this some nuanced behavior where the passing by reference aspect actually applies to the record rather than the declared instance (cl / s)?

    Have i just missed something idiotic?

     

    Thanks for any help!

     

    Lindsay

    How do I go about filtering out these kind of messages (ie every last method entry /exit line in all of Apex-dom):

    19:24:28.435|METHOD_ENTRY|[1,15]|DateTime.newInstance(Integer, Integer, Integer) 19:24:28.436|METHOD_EXIT|[1,15]|newInstance(Integer, Integer, Integer) 19:24:28.436|METHOD_ENTRY|[2,15]|DateTime.newInstance(Integer, Integer, Integer) 19:24:28.436|METHOD_EXIT|[2,15]|newInstance(Integer, Integer, Integer)

     

    So that I don't get this:

     

    *********** MAXIMUM DEBUG LOG SIZE REACHED ***********

     

    Before the debug log gets to what I really want, which is:

     

     

    19:20:27.907|USER_DEBUG|[45,1]|DEBUG|My custom debug message

     

     

    and:

     

     

    Number of SOQL queries: 2 out of 100 Number of query rows: 6052 out of 10000 ******* CLOSE TO LIMIT Number of SOSL queries: 0 out of 20 Number of DML statements: 1 out of 100 Number of DML rows: 1513 out of 10000 Number of script statements: 10605 out of 200000

     

    ???

     

    I'd also love to know how to filter for custom method / class entries and exits without having to wade through method / class entries and exits for say new Account() and MAP:String,SOBJECT:get(). Is it possible?

     

     

    Thanks!

    • March 09, 2010
    • Like
    • 0

    We have a number of objects which all have child records designating specialized Responsibilities for working with the given object. The Responsibilities are defined in a centralized table which includes a picklist for designating for which objects a given responsibility should also be the record owner. The idea here is to ensure sychronization of Responsibility and Owner assignments. For all of these objects, the interaction between parent object and responsibility children is the same and the child responsibilty objects have been set up identically, including the child relationship names, specifically so that we can leverage dynamic apex and centralize the underlying code controlling the behaviors of these records.

     

    The problem is when we try to retrieve the child records from a query of the parent records + related child responsibilities (using parents[0].getSObject('Responsibilities__r') )we get an error that the relationship is not recognized. Since we're dealing with multiple potential parent object types, we've constructed the query as a string and retrieved the records using Database.query(str). I've tested the query in the schema browser and it retrieves the children there..

     

    My code's below. any guidance would be much appreciated. The documentation only had examples for retrieving parent records from children not the other way around, so I'm at a loss:

     

    public static void enforceOwnershiponResponsibility(sObject[] parents){ String sObjectName = ''+parents[0].getSObjectType(); //we only need to get one result because we are only using it to deduce which child responsibility object we're working with String q = 'Select Id, OwnerId, (Select Id, User__c From Responsibilities__r Where Responsibility__r.Ownership__c includes (:sObjectName)) FROM '+sObjectName+' WHERE ActiveResponsibilities__c>0 Limit 1'; sObject[] parentWithRespie = Database.Query(q); SET<ID> pids = new SET<ID>{}; String respieName = ''+parentWithRespie[0].getSObject('Responsibilities__r').getSObjectType(); //collect ids of responsibilities to change for (sObject p: parents){ pids.add(p.Id); } //retrieve respies to update String parentField = respieName.replace('Responsibility__c',''); sObject[] respies = Database.Query('Select ID, OwnerID '+parentField+'__r.OwnerId From '+respieName+' Where '+parentField+'__r.Id IN(:pids) AND Responsibility__r.Ownership__c includes (:sObjectName))'); for (sObject r: respies){ r.put('User__c',r.getSObject(parentField+'__r').get('OwnerId')); } update respies; }

     

    Hi,
     
    I'm hoping for a little clarification on how governor limits are tallied up over sequential resubmits of a page by a user. We have a very large dataset, just under 2000 records, that would be most helpfully managed by the users when filterable by various attribute fields. The probability is they would want to filter the same record set 6 or 7 times in the course of going through the datalist.
     
    If they remained on the same visualforce page and were actually re-querying through SOQL each time, would each of these filter actions count against the same VF page governor limits (apart from the daily limits) or would they count as a refreshing of the page and thus have their own limits?
     
    Thanks
    • December 22, 2008
    • Like
    • 0
    I noticed that my Visualforce page threw the following error when I tried to add a related list that was perfectly well defined in the object's setup but happened not to be in the Page Layout: 'SubContracts__r' is not a valid child relationship name for entity Licensing Contract

    This appears to be an undocumented restriction on the use of <apex:relatedList> not to mention one that could potentially cause some nasty issues in a production environment should an admin update a page layout or create a new one after the orginal page is deployed. Likewise, if they create new recordtypes or recordtype/profile assignments. This restriction is not intuitive; one generally thinks of Visualforce as an alternative to a Page Layout, not as an extension that is bound to it and inherents its content restrictions. Additionally, for developers who have over-ridden all page-layouts for an object with VF pages, it is counter-intuitive to have to edit a Page Layout that is not in use simply to include the list in their VF pages.

    Could someone respond back with some clearer details on how this actually works? Does Visualforce simply require that one page layout include the related list or does it require the page layout for the given record type include it. Wouldn't it be more robust to simply define the apex:related list to display based on user permissions rather than throw an error if the list is not found in the related page layout.


    Message Edited by lnryan on 12-16-2008 01:12 PM
    • December 16, 2008
    • Like
    • 0

    We are experiencing a problem with how Images within Rich Text fields display in custom VF Email Templates: when we preview the templates the images render fine, but when we test sending them out, the images display only the typical broken-image icon (ie white box, red X).

     

    Does anyone know how to fix this? Is there a setting in the <apex:outputField> or a way to use a custom controller to 'unpack' the image references within the rich text field and replace them with resource references, actual image tags, etc?

     

    Additional Details:

    • The rich text field is already being rendered using the <apex:outputField> tag
    • The field occurs within a custom VF component embedded in the email
    • The VF component also uses a custom controller.
    • I have already confirmed that the rendering issue is unrelated to the component / controller

     

    • October 25, 2010
    • Like
    • 1

    Hello All,

     

    I have a Visualforce Page which  when viewed as an Admin works fine, the page has a rerender portion when on selecting a value from a drop down a couple of text boxes get rerendered.

     

    I logged in as a different user and the page shows up fine, when i change the drop down the rerender gets called and i end up getting the message

     

    "Insufficient Privileges You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary. "

     

    The VF page, the apex class, the extension class, the objects used (have C R E D), all have the permissions for this profile. Also, all fields of the associated objects are visible to this profile.

     

    With this error message i am unable to get any clue of what is happening actually, it's just supposed to rerender a few text boxes which are not associated with any access privileages.

     

    Moreover, the debug log says "SUCCESS" and all getter and setter methods are called fine. Its only when the page refreshes itself that something goes wrong somewhere.

     

    Please let me know your thoughts.

     

    Thanks,

    Edwin

    I'm trying to create a single page or two page wizard (without a custom controller) that will provide inline editing for both accounts and the account's contacts but it seems i cannot add inline editing support tag to the data table containing the account's contacts. Can anyone confirm whether or not the inline editing support is limited to the controlling object or to a single dataset?

    Thanks.

    • February 18, 2011
    • Like
    • 0

    I'm trying to find away around the fact that there's no StandardListController for the CampaignMember object (wtf!?).

     

    I need to create a custom button that passes IDs for the selected campaign members to a visualforce page (or if that's really impossible, an apex class).

     

    Can someone please advise on how I could do this?

     

    Thanks,

    Lindsay

     

    • October 15, 2010
    • Like
    • 0

    Hi All,

     

    I want to add a button to the Opportunity Page that, when clicked, checks that certain fields have valid data.

     

    If they don't, then I will display an error message.

     

    If they do they I'll do something else.

     

    So, is the right way to do this:

     

    1) User clicks button which calls URL to a VF page

    2) VF page calls the controller to check validation

    3) If not valid, set errors on Opportunity and redirect user back to Opportunity page (somehow)

    4) If valid, do the other action and send user back to Opportunity (somehow)

     

    This feels wrong. For a start the VF page is purely there for calling the controller class and never actually displays anything.

     

    What's the 'right' way to do this?

     

    TIA

    The following formula isn't properly recognizing blank currency fields.

     

    Here's the formula:

    Adjustment__c*BLANKVALUE(TieredPrice__c, ListPrice)

     

    Where Adjustment is a percent field, TieredPrice__c is a currency field. When TieredPrice__c is blank, the result of the formula is 0.00. The same applies when i try to use null instead. We can't rely on TieredPrice__c=0 as the condition, because 0.00 is a valid TieredPrice__c sometimes.

     

    Is this a bug? TieredPrice__c isn't a formula field so there's no option to specify whether to treat blanks as null or 0.

    • September 30, 2010
    • Like
    • 0

    I have a procedure that can be triggered by an update to or deletion of any one of several inter-related objects based around Opportunities. The trigger retrieves the related Opportunity and all the relevant sub-records in all the relevant objects by way of a single query in the form of

     

     

    Opportunity[] opps = Database.query('SELECT [...fields and children...] FROM Opportunity WHERE Id IN (SELECT Opportunity__c FROM '+childObjectName+' WHERE Id IN :triggeredIds)');

     

    The trouble, of course, is that when this is coming from a delete trigger, it finds no Opportunities related to the deleted record. I tried putting in the keyword 'ALL ROWS' but when this was placed outside the WHERE clause subselect it returned no records and when it was placed within the WHERE clause subselect (shown below), I received the error "Expecting ')'. Found ALL"

     

    FROM Opportunity WHERE Id IN (SELECT Opportunity__c FROM '+childObjectName+' WHERE Id IN :triggeredIds ALL ROWS)');

     

     Does anyone know If there is a proper syntax for retrieving non-deleted parents of deleted child records using subselects?

    • September 24, 2010
    • Like
    • 0

    I'm getting a null pointer exception when I try to use evaluate a checkbox field from my BusinessChannels__c custom setting and the checkbox is unchecked. It seems like kind of a joke to have to set up an if statement like

     

    if(null!=bc.get('somefield__c')&&(Boolean) bc.get('somefield__c'))...

     instead of simply

    if((Boolean) bc.get('somefield__c'))...

     or simpler

    if(bc.get('somefield__c'))...

     

     

    am i missing something obvious? thanks!

     

    • August 26, 2010
    • Like
    • 0

    I have a dynamically generated soql statement. At the end of the statement I add 'AND Contract_Member__c ... 'and I get this error... System.QueryException: unexpected token: '{'  

     

    String corpMemberQuery = 'SELECT ID, Corporate_Contract__r.Name, Contract_Member__c FROM Corp_Contract_Member__c WHERE Is_Active__c = true';

     

    Database.query(corpMemberQuery+
                        ' AND Contract_Member__c IN ('+memMap.keySet()+')' ))

     

    Any ideas on

    1. If i can use keyset() in an 'IN' clause, keySet() returns a set??

    2. Can I cast a Set to a List ??

    Hi,

     

    Help need on how to populate the fields from the owner record when we click on "New" button in a standard objects.I heard that we can do by over riding the "New" button if that is the only way then  how to do that. Can any one help me out.

    • August 24, 2010
    • Like
    • 0

    How do you get access in APEX to the same global variables that are available in formulas and VisualForce. I'm looking for a non-SOQL based way to access this org-wide and environment-based settings. Particularly, is there a corresponding settings variable to $RecordType?

    • August 24, 2010
    • Like
    • 0

    Hi,

     

    I want to create a page that has the following: 1 enhanced list, 1 panel below that displays a list of detail fields for the records selected from the enhanced list.

     

    How do I get the Ids from the enhanced list without leaving the page? 

    Hi All,

     

    I would like to set the value for the account name field in visual force page when it is opening. I just want to pre-populate the value. I dont find the way to do it. Can anyone help me out ?

     

    Thanks in Advance.

     

    Manoj 

    Hello,

     

    I'm trying to build a custom search functionality that displays the list of cases using a custom hierarchy we have set in our org. I was able to display the list of cases according to our requirements. I'm trying now to set up the search criteria and I'm having problems setting this up.

     

    I'm using a custom controller to display the results so i simply added a section in my Visualforce page to slect some of the case fields the user would be able to set to filter the cases. In order to preserve the same look and field as for an actual case, I'm using a case variable to to display and capture the values for the filter criteria. When I first set up the fields using an actual case record (for testing purposes), this works fine and dsiplays the correct values. However, when I change the values and hit the view button to redisplay the data, the values for the filter fields do not change.

     

    I have tried using a custom controller and a Visualforce page for this. I'm not to familiar with writing getter and setters but I sort of undertood from checking the documentationa and the blogs that I wouldn't have to write one in this case as I'm biding the variable in Visualforce to a Case object in the custom controller.

     

    Any pointer would be greatly apprciate it.

     

    Thanks,

     

    Pedro

    With the Summer 10 eclipse plugin update, there is a change which is slowing down development considerably.

     

    When you save a file, it is sent to the server for compilation and deployment. This happens in the background so you can get on with your next change while waiting for the compilation results.

     

    However with the introduction of the Summer 10 plugin, switching to another Apex class file in Eclipse is dependent on the save action completing, so you are stuck with a modal dialog preventing you from doing any further work in the IDE. As a project grows in size, it is not uncommon to have to wait 20-30 secs for this to complete - as this happens frequently, it's really wasting developer time.

     

    Please can the plugin developers consider removing this blockage? It did not used to happen until recently.

     

    Used to have some simple code that went like this:

     

     

    				g.showRule.Value_To_Show__c = '';	
    					
    				for(String s : g.showVals)
    					g.showRule.Value_To_Show__c += s + ',';
    

     Crazy thing was, the value to show would save like this:

     

     

    nullvalue1,value2,value3

     

     

    So for some reason a double single quote was being converted into a four character string 'null.' Oddly, this has not happened in other instances where I successfully concatenate strings.

     

    My workaround:

     

    				if(g.showVals.size() > 0)
    				{
    					g.showRule.Value_To_Show__c = g.showVals.get(0) + ',';
    										 
    					for(Integer i = 1; i < g.showVals.size(); i++)
    						g.showRule.Value_To_Show__c += g.showVals.get(i) + ',';
    }

     

     

     

     

     

    At Dreamforce, I thought I saw an example in which a SOQL dataset was instantiated directly from within the value="..." element of an apex: container such as apex:dataTable, ie

    Code:
    <apex:pageBlockList var="myItem" value="!{[Select ID, Name From...]}">

    but now that I'm searching for it I can't find anything like this. Is it possible? Is there some functionality like it that I may be confusing it with?

    Thanks,
    Lindsay