-
ChatterFeed
-
2Best Answers
-
0Likes Received
-
0Likes Given
-
8Questions
-
19Replies
Help with Querying all Fields on an Object
I want to be able to query for all creatable fields on an object without having to hardcode each field into the SOQL query. I have a method that builds the SOQL query and it works great except for when the WHEN statement includes id in: a collection of records.
Here is the method:
/** *Returns a dynamic SOQL statement for the whole object, includes only creatable fields since we will be inserting a cloned result of this query */ public static string getCreatableFieldsSOQL(String objectName, String whereClause){ String selects = ''; if(whereClause == null || whereClause == ''){ return null; } //get a map of field names and field tokens Map<String, Schema.SObjectField> fMap = Schema.getGlobalDescribe().get(objectName.toLowerCase()).getDescribe().Fields.getMap(); List<String> selectFields = new List<String>(); if(fMap!=null){ for(Schema.SObjectField ft : fMap.values()){ //loop through all field tokens (ft) Schema.DescribeFieldResult fd = ft.getDescribe(); //describe each field (fd) if (fd.isCreateable()){ //field is creatable selectFields.add(fd.getName()); } } }
Here is where I invoke the method:
String oppSOQL = CSUtils.getCreatableFieldsSOQL('Opportunity', 'id in' + clonedFromOppIDs); system.debug('[MF] oppSOQL: ' + oppSOQL); for(Opportunity opp : (List<Opportunity>)Database.query(oppSOQL)){ ClonedOppIDtoClonedOpp.put(opp.id, opp); }
"clonedFromOppIDs" is a set of Opportunity IDs. However, when I try to execute this code I get the error message: System.QueryException: unexpected token: '{' . This is the debug log (I removed most of the fields to make it easier to read):
16:56:07.493 (493363000)|USER_DEBUG|[28]|DEBUG|[MF] oppSOQL: SELECT ApprovedTerms__c,Rate_Type__c,WhatChanged__c FROM Opportunity WHERE id in{006Q000000BmT4XIAV} 16:56:07.493 (493388000)|SYSTEM_METHOD_EXIT|[28]|System.debug(ANY) 16:56:07.493 (493412000)|SYSTEM_METHOD_ENTRY|[30]|Database.query(String) 16:56:07.494 (494079000)|EXCEPTION_THROWN|[30]|System.QueryException: unexpected token: '{'
I've tried making the WHERE clause 'id in: ' + clonedFromOppIDs but I get the same error message. Does anyone know if there is anyway I can get around this? Or have other suggestions for how to systematically query all fields without typing each one it? Any help would be much appreciated, thank you!!
- mgodsey
- September 10, 2013
- Like
- 0
- Continue reading or reply
Need help with Visualforce currency formatting. Will give kudos to anyone that contributes.
Kudos goes to everyone who contributes.
I'm having a problem formatting this to $ USD currency. I have the commas and the commas but:
$10,000.50 = $10,000.5 - Where I need $10,000.50
OR
$10,000.00 = $10,000 - Where I need $10,000.00
Here is the code below I'm hoping someone can help. (Please note that the column in second table called "Invoice Amount" is where I am having formatting issues.
Thank you,
Steve Laycock
<apex:page standardController="Contract" showHeader="false" renderas="pdf"> <table border="0" cellspacing="0" cellpadding="0" width="100%" id="table1"> <tr> <td> <img src='{!URLFOR($Resource.APSLogoContract)}' title="logo" /> </td> <td align="center" style="font-size:20px;"><font face="Arial"> <b>INVOICE</b></font> <table border="1" cellspacing="0" cellpadding="1" width="100%" id="table77"> <tr> <td bgcolor="#d7dee9"> <font face="Arial" style="font-size:13px;">Date: </font> </td> <td> <font face="Arial" style="font-size:13px;"> <apex:outputText value="{0,date,MM'/'dd'/'yyyy}"> <apex:param value="{!contract.WF_Invoice_Date__c}" /> </apex:outputText> </font> </td> </tr> <tr> <td bgcolor="#d7dee9"> <font face="Arial" style="font-size:13px;">Due: </font> </td> <td> <font face="Arial" style="font-size:13px;">Net 30</font> </td> </tr> </table> </td> </tr> </table> <br/> <table border="0" cellspacing="0" cellpadding="1" width="100%" id="table2"> <tr> <td colspan="2" style="font-size:13px;"> <font face="Arial">BarbaraG@aps.us <br/><br/></font> </td> </tr> <tr> <td style="font-size:13px;"> <font face="Arial">Bill To:<br/><br/> {!Contract.Account.Name}<br/> {!Contract.Account.BillingStreet}<br/> {!Contract.Account.BillingCity} {!Contract.Account.BillingState} {!Contract.Account.BillingPostalCode} </font> </td> <td width="20%"></td> <td style="font-size:13px;"> <font face="Arial">Ship To:<br/><br/> {!Contract.Account.Name}<br/> {!Contract.Account.ShippingStreet}<br/> {!Contract.Account.ShippingCity} {!Contract.Account.BillingState} {!Contract.Account.ShippingPostalCode} </font> </td> </tr> </table> <br/><br/><br/> <table border="1" cellspacing="0" cellpadding="1" width="85%" id="table15"> <tr> <td bgcolor="#d7dee9" align="center"><font face="Arial">Contract Number</font></td> <td bgcolor="#d7dee9" align="center"><font face="Arial">Product</font></td> <td bgcolor="#d7dee9" align="center"><font face="Arial">Term</font></td> <td bgcolor="#d7dee9" align="center"><font face="Arial">Invoice Amount</font></td> </tr> <tr> <td align="center"><font face="Arial"> {!Contract.ContractNumber} </font> </td> <td align="center"><font face="Arial"> Maintenance </font> </td> <td align="center"><font face="Arial"> <apex:outputText value="{0,date,MM'/'dd'/'yyyy}"> <apex:param value="{!contract.startdate}" /> </apex:outputText>-<apex:outputText value="{0,date,MM'/'dd'/'yyyy}"> <apex:param value="{!Contract.Contract_End_Date__c}" /> </apex:outputText> </font> </td> <td align="center"><font face="Arial"> <apex:outputText value="{0,number,$#,###,###.##}"> <apex:param value="{!Contract.Total_Maintenance_Price__c}" /> </apex:outputText> </font> </td> </tr> </table> <br/><br/> <table border="1" style="border-color: #3B5E91" cellspacing="0" cellpadding="1" width="100%" id="table4"> <tr> <td bgcolor="#d7dee9" align="left"><font face="Arial">Product(s) Covered</font></td> <td bgcolor="#d7dee9" align="center"><font face="Arial">Quantity</font></td> </tr> <tr> <apex:repeat value="{!Contract.Service_Contract_Line_Items__r}" var="line"> <tr> <td align="left">{!line.Product_LU__r.name}</td> <td align="right">{!(ROUND(line.Quantity__c,0))}</td> </tr> </apex:repeat> </tr> </table> <br/><br/> <table border="1" cellspacing="0" cellpadding="1" width="65%" id="table3"> <tr> <td bgcolor="#d7dee9" align="left"><font face="Arial">Please Note Our Remit To Address</font></td> </tr> <tr> <td><font face="Arial"> Advanced Public Safety, Inc.<br/> PO Box 535208<br/> Atlanta, GA 30353-5208<br/><br/> Wire Instructions: Wells Fargo Bank<br/> ABA#: 121000248 Account #: 412-1360267 </font> </td> </tr> </table> <br/> </apex:page>
- RelaxItsJustCode
- September 10, 2013
- Like
- 0
- Continue reading or reply
Salesforce Community issue when template is switched to VF + Tab (that /s)
How can I get rid of this /s ?
Thanks!
- pinoytechie
- April 04, 2017
- Like
- 0
- Continue reading or reply
common.apex.runtime.bytecode.BytecodeApexObjectType cannot be cast to common.apex.runtime.impl.ApexType on Salesforce Idea
We are getting this message when using contoller exention for Idea object:
common.apex.runtime.bytecode.BytecodeApexObjectType cannot be cast to common.apex.runtime.impl.ApexType
Steps to reproduce
For IdeaStandardController:
1) Create the extension controller class:
public class IdeaDetail_XT { public HROIdeaDetail_XT (ApexPages.IdeaStandardController controller) {} }2) Create the visualforce page. vf page. Let's call it IdeaDetail_VF:
<apex:page standardController="Idea"> <!-- nothing here --> </apex:page>3) Steps #1 and #2 are both fine. Both are saved without problems.
4) Now, edit the IdeaDetail_VF, add the extentions attribute to the page... i.e.:
<apex:page standardController="Idea" extensions="IdeaDetail_XT"> <!-- nothing here --> </apex:page>5) Try to save the IdeaDetail_VF and this error appears:
common.apex.runtime.bytecode.BytecodeApexObjectType cannot be cast to common.apex.runtime.impl.ApexType
For IdeaStandardSetController:
1) Create the extension controller class:
public class IdeaList_XT { public IdeaList_XT(ApexPages.IdeaStandardSetController controller) { //nothing here } }2) Create the visualforce page. vf page. Let's call it IdeaList_VF:
<apex:page standardController="Idea"> <!-- nothing here --> </apex:page>3) Steps #1 and #2 are both fine. Both are saved without problems.
4) Now, edit the IdeaList_VF, add the extentions attribute to the page... i.e.:
<apex:page standardController="Idea" extensions="IdeaList_XT"> <!-- nothing here --> </apex:page>5) Try to save the IdeaList_VF and this error appears:
common.apex.runtime.bytecode.BytecodeApexObjectType cannot be cast to common.apex.runtime.impl.ApexType
NOTE: Tried in 3 different sandboxes, same result.
Thanks,
Aldrin
- pinoytechie
- February 13, 2016
- Like
- 0
- Continue reading or reply
Lightning App Security/Visibility
First of all, please forgive my ignorance as I am new to Salesforce's Lightning app/component.
I just would like to ask, how do you restrict a Lightning app based on profile or permission set? For example you have a Lightning app called "SalesForecaster.app" and you want it to be accessible to users with "Account Executive" profile/permission set, where do you set that up?
Because right now, the app is accessible via "<your_salesforce_instance/c/SalesFocecaster.app" to any user.
Heck it is even accessible via community like "<community_domain>.force.com/<communit_site>/c/SalesFocecaster.app" by community users.
Hope you can help me.
THANK YOU!!!
- pinoytechie
- January 24, 2016
- Like
- 0
- Continue reading or reply
Spring 16: Fullsite switches to Salesforce1 in Mobile Safari
Tested devices:
- iPAD iOS 9.1 on Mobile Safari
- iPhone iOS 9.2 on Mobile Safari
Any workaround for this? Why it forces me to use Salesforce1?
NOTE: works ok in Chrome mobile.
- pinoytechie
- January 14, 2016
- Like
- 0
- Continue reading or reply
WebServiceCallout (wsdl2apex)
We have a system that consumes webservice in SAP. Due to the complexity of webservice structure that SF is invoking in SAP, we use the tool wsdl2apex to generate stub classes. Basically, the connectivity is like this:
SF ==> APIgee ==> Siteminder ==> SAP
The system needs a few enhancements particularly in logging. To goal is to have comprehensive log, to easily pinpoint the culprit when failure happens. The main reason why this enhancement conceived is that there were some webservice/network/middleware-related issues and we really had a hard time tracing that.
When we had those issues, the log only says:
Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':HTML'The error message above is same error when we had authentication error, gateway timeout, SAP unavailability, or any siteminder error, which is being relayed to APIgee, the point where SF connects. The errors actually would have different HTTP headers and messages in the body, but I don't know how to get the content/body and headers using wsdl2apex (or WebServiceCallout) approach.
QUESTIONS:
- How do I extract/generate the XML SOAP envelope being sent to webservice from the stub classes generated by wsdl2apex?
- How do I extract/generate the raw data returned by the webservice from the stub classes generated by wsdl2apex?
- How do I get the HTTP headers returned by the webservice from the stub classes generated by wsdl2apex?
NOTE: when the call was a success, outputHttpHeaders_x contains HTTP headers. However, when there's an error, i.e. 400, 401, 404, 40x, outputHttpHeaders_x is not getting populated. Though a SOAPUI simulation clearly shows there were headers returned.
Please don't tell me to use HTTPRequest instead. I am not in the position to revamp the current code, and I don't have the time and budget to do that. Also, we have a very complex webservice and wsdl2apex tools is really handy to generate all the stubs for such complex webservice.
THANK YOU!
- pinoytechie
- November 03, 2015
- Like
- 0
- Continue reading or reply
why does autonumber starts with zero?
i have may be a hundred objects with autonumber that will be deployed to production.
now as i've tested it in our assembly, autonumber will start with zero unless you go those fields one by one and explicitly specify to start it with '1'.
considering the number of objects i have, and the awkward way to reset it (change to text, save, change back to autonumber, set starting number), this would be very tedious... and might cause delay to get productive.
is there anyway to swiftly done this? why would you have an autonumber in the first place that by default starts with zero?
- pinoytechie
- September 26, 2013
- Like
- 0
- Continue reading or reply
Winter 14: VF Page <apex:detail> issue with Approval History related list
Good day.
One of our sandbox is now in Winter 14.
In pages using <apex:detail>, I noticed tha the Approval History related list is missing the step name, including the corresponding "Overall Status" as shown below:
Screenshot #1) Summer 13: <apex:detail>, Standard Page Layout | Winter 14: Standard Page Layout
Screenshot #2) Winter 14: <apex:detail>
Steps to reproduce:
The Object
- Create a simple custom object (let's call the object "Test Request", with API name being Test_Request__c )
- In the page layout of Test Request, include/add the "Approval History" related list
- Create a simple approval process for "Test Object"
- Create a new Test Request and save it
- Submit the newly created Test Request for approval
- Open the newly submitted Test Request
- Noticed that the "Approval History" section looks normal. This is fine.
The <apex:detail> Problem
- Create a new VF page called "Test_Request_View_Page", with the following code:
<apex:page standardController="Test_Request__c"> <apex:detail /> </apex:page>
- Override the view button of Test_Request__c with the newly created page
- Open the Test Request we created in step#4 above
- In Summer 13, you would notice that the Approval History section is ok (see screenshot #1). But in Winter 14, it doesn't show the steps name and corresponding overall status (screenshot #2)
Is there any workaround to this ?
Please note that I have a much more complex code than the provided code, so reverting back to using just a standard page is not a workaround.
Thanks
- pinoytechie
- September 09, 2013
- Like
- 0
- Continue reading or reply
Problem with dependent lookup fields in "Search Filter Fields"
In "Search Filter Fields", when using lookup field where value selection is dependent on the value of another field, the pop-window for dependent field doesn't show up when the lookup icon/button is clicked.
For example:
- I have an object called Trademark__c (with fields: Name, Code__c)
- Then I have another object called Flavor__c (with fields: Name, Code__c, TM__c). TM__c in this case is a lookup to Trademark__c object.
- Now I have another object called Request__c. This object has two fields called Trademark__c and Flavor__c. Trademark__c is a lookup field (to Trademark__c object), and Flavor__c is also a lookup field (to Flavor__c object). Now there's a filter in the definition of Flavor__c field that the records it will return/show are those only related to selected (value) of Trademark__c.
1, 2, and 3 are fine.
Now in the "Search Filter Fields" of Request__c object, I would define Trademark__c and Flavor__c as filter fields. When I do global search, in the results for Request__c, there's an area where I could further filter the results. I can click the Trademark__c lookup icon just fine. But the Flavor__c lookup icon doesn't work when I click on it.
When I click in the non-working lookup icon, I can see the following message goes out of Chrome's JS console:
Uncaught TypeError: Cannot read property 'lookupControllerIds' of undefined main.js:696 DetailPage.getReferredDomIds main.js:696 (anonymous function)
In IE8:
Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; MS-RTC LM 8; .NET4.0E; .NET4.0C) Timestamp: Tue, 3 Sep 2013 15:27:34 UTC Message: 'this.getFieldById(...).lookupControllerIds' is null or not an object Line: 696 Char: 191 Code: 0 URI: https://ap1.salesforce.com/jslibrary/1375816926000/sfdc/main.js
In Firefox, I get:
Timestamp: 9/3/2013 11:30:20 PM Error: TypeError: this.getFieldById(...) is undefined Source File: https://ap1.salesforce.com/jslibrary/1375816926000/sfdc/main.js Line: 696
Tried in different orgs, and got the same result.
How to solve this?
- pinoytechie
- September 03, 2013
- Like
- 0
- Continue reading or reply
Salesforce Community issue when template is switched to VF + Tab (that /s)
How can I get rid of this /s ?
Thanks!
- pinoytechie
- April 04, 2017
- Like
- 0
- Continue reading or reply
common.apex.runtime.bytecode.BytecodeApexObjectType cannot be cast to common.apex.runtime.impl.ApexType on Salesforce Idea
We are getting this message when using contoller exention for Idea object:
common.apex.runtime.bytecode.BytecodeApexObjectType cannot be cast to common.apex.runtime.impl.ApexType
Steps to reproduce
For IdeaStandardController:
1) Create the extension controller class:
public class IdeaDetail_XT { public HROIdeaDetail_XT (ApexPages.IdeaStandardController controller) {} }2) Create the visualforce page. vf page. Let's call it IdeaDetail_VF:
<apex:page standardController="Idea"> <!-- nothing here --> </apex:page>3) Steps #1 and #2 are both fine. Both are saved without problems.
4) Now, edit the IdeaDetail_VF, add the extentions attribute to the page... i.e.:
<apex:page standardController="Idea" extensions="IdeaDetail_XT"> <!-- nothing here --> </apex:page>5) Try to save the IdeaDetail_VF and this error appears:
common.apex.runtime.bytecode.BytecodeApexObjectType cannot be cast to common.apex.runtime.impl.ApexType
For IdeaStandardSetController:
1) Create the extension controller class:
public class IdeaList_XT { public IdeaList_XT(ApexPages.IdeaStandardSetController controller) { //nothing here } }2) Create the visualforce page. vf page. Let's call it IdeaList_VF:
<apex:page standardController="Idea"> <!-- nothing here --> </apex:page>3) Steps #1 and #2 are both fine. Both are saved without problems.
4) Now, edit the IdeaList_VF, add the extentions attribute to the page... i.e.:
<apex:page standardController="Idea" extensions="IdeaList_XT"> <!-- nothing here --> </apex:page>5) Try to save the IdeaList_VF and this error appears:
common.apex.runtime.bytecode.BytecodeApexObjectType cannot be cast to common.apex.runtime.impl.ApexType
NOTE: Tried in 3 different sandboxes, same result.
Thanks,
Aldrin
- pinoytechie
- February 13, 2016
- Like
- 0
- Continue reading or reply
common.apex.runtime.bytecode.BytecodeApexObjectType cannot be cast to common.apex.runtime.impl.ApexType
The page can be edited directly through Develop->Pages.
Here's a very simplified version of the page which produces the error
<apex:page standardController="User" extensions="SalesRepGoalController2"> <b>Hello World!</b> </apex:page>and controller
public with sharing class SalesRepGoalController2{ private String userID = '' ; public SalesRepGoalController2(ApexPages.StandardController c) { userID = c.getId(); } }
Java 1.7 was installed, but has been uninstalled.
Windows 8 Enterprise, 64bit
IE 10
JRE none
- dhunt
- July 20, 2015
- Like
- 1
- Continue reading or reply
Overriding lookup with a Visualforce page
Hi All,
I've gone through a couple of sites including
- http://blog.jeffdouglas.com/2011/08/12/roll-your-own-salesforce-lookup-popup-window/
- http://bobbuzzard.blogspot.com/2010/09/visualforce-lookup.html
- http://boards.developerforce.com/t5/Visualforce-Development/Overriding-lookup-icon/m-p/196802#M26504 (no solution found)
The jist of what I'm trying to do is override all of our lookup on the account detail for the "Go Forward PM System" object. The reason why is that sometimes the name of the GFPM is different than the vendor that sells it. I can add additional filters to the standard lookup page, but this only filters off of the 'recently' viewed, which is not helpful since we have quite a few GFPM records.
However, I do not want to completely override our standard account page since we have several record types and layouts with over 100 fields on each. I am able to override the lookup, but I am having trouble passing the Id of the selection back to the account page. In both of the examples by Jeff and Bob, they are able to pass it back by having the field element specified as apex:inputfield. With apex:detail, is there a way to get the field Id to pass it back? If so how can I pass it back? I also humored the idea of using a hiddenInput, but ideally, I would like the user to be able to see that they modified the page (standard feel).
I have very limited javascript expereince, so that's where the additional struggle is coming from. Any education you gurus can provide would be greatly helpful.
Here's what I have so far:
Detail Page:
<apex:page standardController="Account"> <script type="text/javascript"> function openLookup(baseURL, width, modified, searchParam) { var lookupType = baseURL.substr(baseURL.length-3,3); //This is the value for lktp //var lookupFieldId = baseURL.substr(baseURL.length-38,17); //This is the value for lknm, renamed as txtId //var lookupFormId = escapeUTF("{!$Component.detail}"); //This is the value for the other half of lknm, identifying the form, renamed as frm if(lookupType == "a1i") { var urlArr = baseURL.split("&"); var txtId = ''; if(urlArr.length > 2) { urlArr = urlArr[1].split('='); txtId = urlArr[1]; } baseURL = "/apex/GFPMCustomLookupSearch?txt=" + txtId + "&frm=" + escapeUTF("{!$Component.detail}"); } openPopup(baseURL, "lookup", 350, 480, "width="+width+",height=480,toolbar=no,status=no,directories=no,menubar=no,resizable=yes,scrollable=no", true); } </script> <apex:form > <apex:inputField value="{!account.Go_Forward_PM_System__c}"/> </apex:form> <apex:detail id="detail" inlineEdit="true"/> </apex:page>
Lookup page:
<apex:page controller="GFPMDynamicSearch" title="Search" showHeader="false" sideBar="false" tabStyle="Go_Forward_PM_System__c" id="pg"> <apex:form id="form"> <apex:actionFunction name="doSearchAF" action="{!searchGFPM}"/> <apex:outputPanel id="page" layout="block" style="margin:5px;padding:10px;padding-top:2px;"> <apex:actionRegion > <apex:outputPanel id="top" layout="block" style="margin:5px;padding:10px;padding-top:2px;"> <apex:outputLabel value="Search" style="font-weight:Bold;padding-right:10px;" for="txtSearch" /> <apex:inputText id="txtSearch" value="{!searchText}" onkeypress="return noenter(event);" /> <span style="padding-left:5px"> <apex:commandButton id="btnSearch" value="Search" action="{!searchGFPM}" rerender="searchResults"/> <apex:actionStatus id="status" startText="requesting..."/> </span> </apex:outputPanel> <apex:outputPanel id="pnlSearchResults" style="margin:10px;height:350px;overflow-Y:auto;" layout="block"> <apex:pageBlock id="searchResults"> <apex:pageBlockTable value="{!results}" var="result" id="tblResults"> <apex:column headerValue="Go Forward PM System"> <apex:outputLink value="javascript:top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!result.Id}','{!result.Name}', false)" rendered="{!NOT(ISNULL(result.Id))}">{!result.Name}</apex:outputLink> </apex:column> <apex:column headerValue="Vendor Account" value="{!result.Vendor_Account__r.Name}"/> <apex:column headerValue="Status" value="{!result.Status__c}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:outputPanel> </apex:actionRegion> </apex:outputPanel> </apex:form> <script type='text/javascript'> //This function allows the user to press enter to search function noenter(ev) { if (window.event && window.event.keyCode == 13 || ev.which == 13) { doSearchAF(); return false; } else { return true; } } </script> </apex:page>
- Kelly K
- September 30, 2013
- Like
- 0
- Continue reading or reply
why does autonumber starts with zero?
i have may be a hundred objects with autonumber that will be deployed to production.
now as i've tested it in our assembly, autonumber will start with zero unless you go those fields one by one and explicitly specify to start it with '1'.
considering the number of objects i have, and the awkward way to reset it (change to text, save, change back to autonumber, set starting number), this would be very tedious... and might cause delay to get productive.
is there anyway to swiftly done this? why would you have an autonumber in the first place that by default starts with zero?
- pinoytechie
- September 26, 2013
- Like
- 0
- Continue reading or reply
Winter 14 pageBlockSectionItem format bug
It would appear there is a bug with the Winter 14 release and visualforce pageBlockSectionItem. Below is the markup to reproduce:
<apex:page"> <apex:pageBlock> <apex:pageBlockSection > <apex:pageBlockSectionItem> <apex:outputPanel > Choose whether to define the fields for this Map Object or whether to refer to another object already configured. (e.g. for Opportunities, you may want to refer to the Account object). Referring to another object means this object need not be geocoded and will use the referring object's information. </apex:outputPanel> <apex:outputPanel > hi </apex:outputPanel> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> </apex:page>
In Summer 13 it looked like this, correct:
In Winter 14 it looks like this:
- TehNrd
- September 12, 2013
- Like
- 0
- Continue reading or reply
Initial term of field expression must be a concrete SObject
I have written an After Insert trigger on Case that re-assigns AccountId and Contact Id associated wiith the case based on if the case is created by a customer portal user or not.
The trigger will not compile because of an error that I don't quite understand here: Initial term of field expression must be a concrete SObject: LIST<Case>
It fails where I'm extracting the new Id from a map of Accounts keyed by a custom field: SSNumber__c and try to assign that Id to the Case.AccountId field (see ==> below). What am I doing wrong?
trigger AfterInsertCase on Case (after insert) { List<Id> lstCases = new List<Id>(); List<String>lstSSNumbers=new List<String>();
// Find cases created by Customer Portals for (Case caseObj:Trigger.new) { if(caseObj.Account.IsCustomerPortal==true){ lstCases.add(caseObj.Id); lstSSNumbers.add(caseObj.SSNumber__c); } } // Create a map with the AccountID's keyed by SSNumber__c Map<String,Account>MapAccBySSNumber=new Map<String,Account>(); List<Account>lstAcc=new List<Account>([Select Id, SSNumber__c from Account where SSNumber__c IN:lstSSNumbers]); for(Account ac:lstAcc){ MapAccBySSNumber.put(ac.SSNumber__c,ac); } // Update the Case object with new references to Contact and Account List<Case>lstCaseInfo=new List<Case>([Select Id, AccountId, ContactId, SSNumber__c from Case where Id IN :lstCases]); list<Case>lstCasesToUpdate=new List<Case>(); for(Case cse: lstCaseInfo){ ==> cse.AccountId = MapAccBySSNumber.get(lstCaseInfo.SSNumber__c).Id; ==> cse.ContactId=MapAccBySSNumber.get(lstCaseInfo.SSNumber__c).Id; lstCasesToUpdate.add(cse); } update lstCasesToUpdate; }
- Souls
- September 11, 2013
- Like
- 0
- Continue reading or reply
Help with Querying all Fields on an Object
I want to be able to query for all creatable fields on an object without having to hardcode each field into the SOQL query. I have a method that builds the SOQL query and it works great except for when the WHEN statement includes id in: a collection of records.
Here is the method:
/** *Returns a dynamic SOQL statement for the whole object, includes only creatable fields since we will be inserting a cloned result of this query */ public static string getCreatableFieldsSOQL(String objectName, String whereClause){ String selects = ''; if(whereClause == null || whereClause == ''){ return null; } //get a map of field names and field tokens Map<String, Schema.SObjectField> fMap = Schema.getGlobalDescribe().get(objectName.toLowerCase()).getDescribe().Fields.getMap(); List<String> selectFields = new List<String>(); if(fMap!=null){ for(Schema.SObjectField ft : fMap.values()){ //loop through all field tokens (ft) Schema.DescribeFieldResult fd = ft.getDescribe(); //describe each field (fd) if (fd.isCreateable()){ //field is creatable selectFields.add(fd.getName()); } } }
Here is where I invoke the method:
String oppSOQL = CSUtils.getCreatableFieldsSOQL('Opportunity', 'id in' + clonedFromOppIDs); system.debug('[MF] oppSOQL: ' + oppSOQL); for(Opportunity opp : (List<Opportunity>)Database.query(oppSOQL)){ ClonedOppIDtoClonedOpp.put(opp.id, opp); }
"clonedFromOppIDs" is a set of Opportunity IDs. However, when I try to execute this code I get the error message: System.QueryException: unexpected token: '{' . This is the debug log (I removed most of the fields to make it easier to read):
16:56:07.493 (493363000)|USER_DEBUG|[28]|DEBUG|[MF] oppSOQL: SELECT ApprovedTerms__c,Rate_Type__c,WhatChanged__c FROM Opportunity WHERE id in{006Q000000BmT4XIAV} 16:56:07.493 (493388000)|SYSTEM_METHOD_EXIT|[28]|System.debug(ANY) 16:56:07.493 (493412000)|SYSTEM_METHOD_ENTRY|[30]|Database.query(String) 16:56:07.494 (494079000)|EXCEPTION_THROWN|[30]|System.QueryException: unexpected token: '{'
I've tried making the WHERE clause 'id in: ' + clonedFromOppIDs but I get the same error message. Does anyone know if there is anyway I can get around this? Or have other suggestions for how to systematically query all fields without typing each one it? Any help would be much appreciated, thank you!!
- mgodsey
- September 10, 2013
- Like
- 0
- Continue reading or reply
Need help with Visualforce currency formatting. Will give kudos to anyone that contributes.
Kudos goes to everyone who contributes.
I'm having a problem formatting this to $ USD currency. I have the commas and the commas but:
$10,000.50 = $10,000.5 - Where I need $10,000.50
OR
$10,000.00 = $10,000 - Where I need $10,000.00
Here is the code below I'm hoping someone can help. (Please note that the column in second table called "Invoice Amount" is where I am having formatting issues.
Thank you,
Steve Laycock
<apex:page standardController="Contract" showHeader="false" renderas="pdf"> <table border="0" cellspacing="0" cellpadding="0" width="100%" id="table1"> <tr> <td> <img src='{!URLFOR($Resource.APSLogoContract)}' title="logo" /> </td> <td align="center" style="font-size:20px;"><font face="Arial"> <b>INVOICE</b></font> <table border="1" cellspacing="0" cellpadding="1" width="100%" id="table77"> <tr> <td bgcolor="#d7dee9"> <font face="Arial" style="font-size:13px;">Date: </font> </td> <td> <font face="Arial" style="font-size:13px;"> <apex:outputText value="{0,date,MM'/'dd'/'yyyy}"> <apex:param value="{!contract.WF_Invoice_Date__c}" /> </apex:outputText> </font> </td> </tr> <tr> <td bgcolor="#d7dee9"> <font face="Arial" style="font-size:13px;">Due: </font> </td> <td> <font face="Arial" style="font-size:13px;">Net 30</font> </td> </tr> </table> </td> </tr> </table> <br/> <table border="0" cellspacing="0" cellpadding="1" width="100%" id="table2"> <tr> <td colspan="2" style="font-size:13px;"> <font face="Arial">BarbaraG@aps.us <br/><br/></font> </td> </tr> <tr> <td style="font-size:13px;"> <font face="Arial">Bill To:<br/><br/> {!Contract.Account.Name}<br/> {!Contract.Account.BillingStreet}<br/> {!Contract.Account.BillingCity} {!Contract.Account.BillingState} {!Contract.Account.BillingPostalCode} </font> </td> <td width="20%"></td> <td style="font-size:13px;"> <font face="Arial">Ship To:<br/><br/> {!Contract.Account.Name}<br/> {!Contract.Account.ShippingStreet}<br/> {!Contract.Account.ShippingCity} {!Contract.Account.BillingState} {!Contract.Account.ShippingPostalCode} </font> </td> </tr> </table> <br/><br/><br/> <table border="1" cellspacing="0" cellpadding="1" width="85%" id="table15"> <tr> <td bgcolor="#d7dee9" align="center"><font face="Arial">Contract Number</font></td> <td bgcolor="#d7dee9" align="center"><font face="Arial">Product</font></td> <td bgcolor="#d7dee9" align="center"><font face="Arial">Term</font></td> <td bgcolor="#d7dee9" align="center"><font face="Arial">Invoice Amount</font></td> </tr> <tr> <td align="center"><font face="Arial"> {!Contract.ContractNumber} </font> </td> <td align="center"><font face="Arial"> Maintenance </font> </td> <td align="center"><font face="Arial"> <apex:outputText value="{0,date,MM'/'dd'/'yyyy}"> <apex:param value="{!contract.startdate}" /> </apex:outputText>-<apex:outputText value="{0,date,MM'/'dd'/'yyyy}"> <apex:param value="{!Contract.Contract_End_Date__c}" /> </apex:outputText> </font> </td> <td align="center"><font face="Arial"> <apex:outputText value="{0,number,$#,###,###.##}"> <apex:param value="{!Contract.Total_Maintenance_Price__c}" /> </apex:outputText> </font> </td> </tr> </table> <br/><br/> <table border="1" style="border-color: #3B5E91" cellspacing="0" cellpadding="1" width="100%" id="table4"> <tr> <td bgcolor="#d7dee9" align="left"><font face="Arial">Product(s) Covered</font></td> <td bgcolor="#d7dee9" align="center"><font face="Arial">Quantity</font></td> </tr> <tr> <apex:repeat value="{!Contract.Service_Contract_Line_Items__r}" var="line"> <tr> <td align="left">{!line.Product_LU__r.name}</td> <td align="right">{!(ROUND(line.Quantity__c,0))}</td> </tr> </apex:repeat> </tr> </table> <br/><br/> <table border="1" cellspacing="0" cellpadding="1" width="65%" id="table3"> <tr> <td bgcolor="#d7dee9" align="left"><font face="Arial">Please Note Our Remit To Address</font></td> </tr> <tr> <td><font face="Arial"> Advanced Public Safety, Inc.<br/> PO Box 535208<br/> Atlanta, GA 30353-5208<br/><br/> Wire Instructions: Wells Fargo Bank<br/> ABA#: 121000248 Account #: 412-1360267 </font> </td> </tr> </table> <br/> </apex:page>
- RelaxItsJustCode
- September 10, 2013
- Like
- 0
- Continue reading or reply
Unable to load data from custom object into "apex:inputText" field
Hi,
I need help with an issue I am having with my VisualForce page. When I display the Title as an inputText I am unable to get the data to refresh from the apex code. The outputText works and changes when the data on the server side changes but for some reason the data in the inputText will not change. Any and all help in this matter is appreciated.
Here is the VisualForce code:
<apex:outputText value="{!SELEMP.firstName}" />
<apex:outputText value="{!SELEMP.lastName}" />
<apex:inputText id="titleId" value="{!SELEMP.title}" />
Here is the apex code:
myEmployee = [SELECT e.id, e.Last_Name__c, e.First_Name__c,
e.Title__c, e.UP_Contact_Number__c,
e.Responsibility_Center__c FROM Employee__c e where Id =:theEmp Limit 1];
selemp = new objEmployee(
myEmployee.id, '', myEmployee.First_Name__c, myEmployee.Last_Name__c, myEmployee.Title__c,
myEmployee.UP_Contact_Number__c, myEmployee.Responsibility_Center__c,'','',
'', false);
Thanks,
Vibrate
- Vibrate
- September 10, 2013
- Like
- 0
- Continue reading or reply
onselect attribute is not working in apex:selectList
i write a visualforce page
<apex:page controller="sampleCon">
<apex:form>
<apex:selectList value="{!countries}" size="1" onselect="searchFeeds();">
<apex:selectOptions value="{!items}"/>
</apex:selectList>
<script type="text/javascript">
function searchFeeds(){
alert('Hello world');
}
</script>
<p/>
</apex:form>
<chatter:newsfeed />
</apex:page>
and controller code is
public class sampleCon {
String countries ;
public PageReference test() {
return null;
}
public List<SelectOption> getItems() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('US','US'));
options.add(new SelectOption('CANADA','Canada'));
options.add(new SelectOption('MEXICO','Mexico'));
return options;
}
public String getCountries() {
return countries;
}
public void setCountries(String countries) {
this.countries = countries;
}
}
when i select any different country from select list no alert is shown by the browser. can any one please point me why ??
- RIteshM
- September 10, 2013
- Like
- 0
- Continue reading or reply
How to automatically re-render a pageblock every time a variable is updated?
Hello,
Let's say a have a certain pageblock inside a visualforce page that I want to be refreshed every time a certain variable (in my controller class) is updated. Do you have any idea of how this can be done??
Thank you!
- Gtemporao
- September 09, 2013
- Like
- 0
- Continue reading or reply
Winter 14: VF Page <apex:detail> issue with Approval History related list
Good day.
One of our sandbox is now in Winter 14.
In pages using <apex:detail>, I noticed tha the Approval History related list is missing the step name, including the corresponding "Overall Status" as shown below:
Screenshot #1) Summer 13: <apex:detail>, Standard Page Layout | Winter 14: Standard Page Layout
Screenshot #2) Winter 14: <apex:detail>
Steps to reproduce:
The Object
- Create a simple custom object (let's call the object "Test Request", with API name being Test_Request__c )
- In the page layout of Test Request, include/add the "Approval History" related list
- Create a simple approval process for "Test Object"
- Create a new Test Request and save it
- Submit the newly created Test Request for approval
- Open the newly submitted Test Request
- Noticed that the "Approval History" section looks normal. This is fine.
The <apex:detail> Problem
- Create a new VF page called "Test_Request_View_Page", with the following code:
<apex:page standardController="Test_Request__c"> <apex:detail /> </apex:page>
- Override the view button of Test_Request__c with the newly created page
- Open the Test Request we created in step#4 above
- In Summer 13, you would notice that the Approval History section is ok (see screenshot #1). But in Winter 14, it doesn't show the steps name and corresponding overall status (screenshot #2)
Is there any workaround to this ?
Please note that I have a much more complex code than the provided code, so reverting back to using just a standard page is not a workaround.
Thanks
- pinoytechie
- September 09, 2013
- Like
- 0
- Continue reading or reply
VF calling javascript on load
Right now, I have a selectoptions on my vf page that has several checkboxes. If Checkbox Value 1 is selected, another input text field is displyed and if unchecked it is hidden again which is wrapped around a div called showfield. The script below works great but if the value is pre-checked on page load(since it is passed from another page), the textbox should display or not display depending on if it is checked. How can I ensure in visualforce, that my script below runs immediatley after the DOM is loaded? when I did an alert the getchkboxvalue is undefined.....i tried domcontentloaded and that didn't work either, when i tried windows.load the alert boxes said undefined when i tried to output getchkboxvalue value
<apex:outputPanel >
<apex:selectCheckBoxes onchange="Showdiv(this)" value="{!checkboxes}" required="true" id="checkboxes" >
<apex:selectOptions value="{!checkboxes}"/>
</apex:selectCheckBoxes>
</apex:outputPanel>
<div id = "showfield" style="display:none;">
<apex:panelGrid columns="2" columnClasses="labelCol,input" styleClass="inputGrid">
<apex:outputLabel id="myfieldId" for="myField" ><span class="required">* </span> myField:</apex:outputLabel>
<apex:inputField id="myField" value="{!Lead.myField}" required="false"/>
</apex:panelGrid>
</div>
</script>
function Showdiv(var1){
var getchkboxvalue=var1.value;
if(getchkboxvalue=='Checkbox Value 1' && var1.checked==true){
document.getElementById('showfield').style.display='block';
}
if(getchkboxvalue=='Checkbox Value 1' && var1.checked==false){
document.getElementById('showfield').style.display='none';
}
}
</script>
</body>
- learningsfdcdev
- September 07, 2013
- Like
- 0
- Continue reading or reply
Javascript within apex:pageBlockTable Related List ?
Hello,
I have an apex:pageBlockTable that displays a picture for eacg record in the list of record. I want to get the size of each picture using Javascrip width. How do I do that? I am stuck with the following problem in the code below: the id="AIHURLPicture1" is convey accross all records in the table, so it can not work. How do I get each picture to have a different Id? Thanks in advance for your support. Have a good weekend, Jerome
<apex:pageBlockTable value="{!vehicleList}" var="vehicle" id="vehicletable">
<apex:column>
<img src="{!vehicle.URLPicture1__c}" id="URLPicture1" />
<script>
var URLPict1JS = document.getElementById("URLPicture1");
var pict1 = new Image();
pict1.src=URLPict1JS.src;
var width = pict1.width;
</script>
....
- FastSnail
- September 06, 2013
- Like
- 0
- Continue reading or reply