• Ash
  • NEWBIE
  • 0 Points
  • Member since 2004

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

Hi,

 

I am usng dynamic soql, where I prepare my sqol query at runtime and would like to access the field values using dynamic field names used in my query. I am able to do it using sObject method  get(stringName) but this works only for non-relationship fields and not relationsip fields. Please let me know if I am missing anything and how to access relationship field using get() method.

 

Below is the simple code snippet

 

String qryString = "SELECT Id, AccountId,   Account.AccountNumber from Order limit 2"       (note the field names will be computed at runtime, I am just hard coding here)

 

Order[] ords=Database.query(qryString);

 

 

for(Order ord : ords){

System.debug('Account ID...'+ord.get('AccountId'));//This works and prints the accountID

System.debug('Account number..'+ord.get( 'Account.AccountNumber'); //get an error "Account.AccountNumber does not belong to SObject type Order

}

 

Thanks.

  • January 09, 2010
  • Like
  • 0

Hi,

 

I have a page where there are 2 checkbox columns (primary and secondary). Only one primary can be selected. I am disabling the secondary checkbox coulmn if that corresponding primary row is selected so that the same primary and secondary cannot be selected. However multiple secondary can be selected.

 

I also have a default value for primary when rendering my VF page, so the corresponding secondary is disabled intially. All this works fine expect that my initially disabled secondary row never retrun a selected value=true  when passed to the colroller although I selected it my UI.

 

In the code below I am defaulting my primary to "Sam" (assuming I have a contact by that name in my app) the corresponing secondary row is disabled. But when I change the primary and choose 3 seconday and one of them is "Sam", then value retured to my controller is only 2 records instead on 3. Initial disabled secondary is always returned as checked=FALSE (eventhough I selected it). If I remove the highlighted (in red) code, then it works fine but that is not the behaviour I need.

 

Not sure why the VF page is not returing the prior disabled value even if it is checked.

 

Posted my working code below. Any sugesstion or soultion would be of great help.

 

Page:

 

<apex:page controller="sampleCon">
<apex:form >
<apex:pageBlock >

<apex:pageBlockButtons >
<apex:commandButton value="Process Selected" action="{!processSelected}" rerender="table"/>
</apex:pageBlockButtons>

<apex:pageBlockTable value="{!contacts}" var="c" id="tab">
<apex:column >

<apex:inputCheckbox Id="primarySel" title="Primary" value="{!c.selected}" onclick="deSelectOthers(this,'{!$Component.secSel}')"/>
<script>
if ("{!c.selected}" == "true") {
selectedChkbox = document.getElementById('{!$Component.primarySel}');
}
tableIdCount++;
</script>
</apex:column>
<apex:column >
<apex:inputCheckbox Id="secSel" title="Primary" value="{!c.selectedMany}" onclick="selMany('{!c.selectedMany}')" disabled="{!c.selected}" />
<script>
if ("{!c.selected}" == "true") {
disChkbox= document.getElementById('{!$Component.secSel}');
}
tableIdCount1++;
</script>
</apex:column>

<apex:column value="{!c.con.Name}" />
<apex:column value="{!c.con.Email}" />
<apex:column value="{!c.con.Phone}" />

</apex:pageBlockTable>

</apex:pageBlock>
</apex:form>

<script>
var selectedChkbox;
var disChkbox;

function deSelectOthers(chkBox, sec) {
var tableIdCount = 0;
var tableIdCount1 = 0;
var chkBox2=(document.getElementById(sec));
//alert(chk+'...'+chkBox2.checked);
//alert(document.getElementById(sec).disabled);
chkBox2.disabled=true;
chkBox2.checked=false;
if (chkBox.checked) {
if ((chkBox != selectedChkbox) && (selectedChkbox != null)) {
selectedChkbox.checked = false;
}
if ((chkBox2!= disChkbox) && (disChkbox!= null)) {
//disChkbox.checked=false;
disChkbox.disabled= false;
}
selectedChkbox = chkBox;
disChkbox= chkBox2;


}
}

function selMany(selMany){
//alert(selMany);
}

function dselCk(ck){
var inputElem = document.getElementsByTagName("input");
for(var i=0; i<inputElem.length; i++)
{
if(ck.checked)
inputElem[i].checked = ck.checked;
}
}

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

</apex:page>

 

 Controller

 

 

public class sampleCon {

public class PublishQuoteException extends Exception {
}

public List<cContact> contactList {get; set;}
List<Contact> selectedContacts = new List<Contact>();
List<Contact> selectedManyContacts = new List<Contact>();

public List<cContact> getContacts(){
if(contactList == null){
contactList = new List<cContact>();

for(Contact c : [select Id, Name, Email, Phone from Contact limit 10]){

if(c.Name == 'Sam Rowe')
contactList.add(new cContact(c, true));
else
contactList.add(new cContact(c, false));
}
}
return contactList;
}

public PageReference processSelected(){

for(cContact cCon : getContacts()){
System.debug('Sec cont...'+cCon.selectedMany);
if(cCon.selected == true){
selectedContacts.add(cCon.con);
}
if(cCon.selectedMany == true){
selectedManyContacts.add(cCon.con);
}
}
if(selectedContacts.size() <= 0)
throw new PublishQuoteException('You must select a primary field');

System.debug('These are the selected Contacts...'+selectedContacts.size());
for(Contact con : selectedContacts){
system.debug(con);
}

System.debug('These are the selected MANY Contacts*** '+selectedManyContacts.size());
for(Contact con : selectedManyContacts){
system.debug(con);
}
return null;
}


public class cContact{
public Contact con {get; set;}
public Boolean selected {get; set;}
public Boolean selectedMany {get; set;}
public Boolean secDis{get; set;}

public cContact(Contact c, Boolean sel){
con = c;
selected = sel;
selectedMany = false;

}
}

}

 

 

 

  • October 15, 2009
  • Like
  • 0

Hi,

 

Is it possible to force group sections when a VF page is rendered as a PDF doc. So a a form do not get split between pages (example: Never have the signature block span 2 pages). 

 

I know it's possible to add page breaks in pdf but I don't want to explictly add page breaks and want to only add page breaks if the sections is going to be split bewteen 2 pages.

 

Please let me know if this is possible in VF or if I take advantage of any pdf functionality.

 

Thanks in advance.

 

Message Edited by Ash on 02-18-2009 10:35 AM
  • February 18, 2009
  • Like
  • 0
Hi,

We are using the email to case feature for my company and I am customizing the application to suit our company need. I would like to know how thw handleEmailMessage method call works and what it exactly does. I could not find any documentstion related to in the sforce API documentation.

Can you please point me to the place where I can find the docs? or send me if you have a copy?.

Thanks in advance,

-AR
  • December 06, 2005
  • Like
  • 0

Hi,

 

Is it possible to force group sections when a VF page is rendered as a PDF doc. So a a form do not get split between pages (example: Never have the signature block span 2 pages). 

 

I know it's possible to add page breaks in pdf but I don't want to explictly add page breaks and want to only add page breaks if the sections is going to be split bewteen 2 pages.

 

Please let me know if this is possible in VF or if I take advantage of any pdf functionality.

 

Thanks in advance.

 

Message Edited by Ash on 02-18-2009 10:35 AM
  • February 18, 2009
  • Like
  • 0
Hi,

We are using the email to case feature for my company and I am customizing the application to suit our company need. I would like to know how thw handleEmailMessage method call works and what it exactly does. I could not find any documentstion related to in the sforce API documentation.

Can you please point me to the place where I can find the docs? or send me if you have a copy?.

Thanks in advance,

-AR
  • December 06, 2005
  • Like
  • 0