-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
13Questions
-
8Replies
VLOOKUP to validate checkbox field type
I have a custom object SP__c having a checkbox field named 'Apply_To_All__c' and a text field P1__c. The standard object 'Account' has a lookup field to this custom object (Account.SP__c). Only SPs that have 'Apply_To_All' checked can be set as a lookup SP for an Account.
Account
Name SP__c
Sonixx Standard
Beltronix Custom (This is invalid as 'Apply_To_All__c' is false for Custom SP)
Airtel Standard
SP__c
Name Apply_To_All__c P1__c
Standard True Critical
Custom False Normal
To achieve this, I wrote the following validation rule in Account:
VLOOKUP($ObjectType.ENT_2__SP__c.Fields.ENT_2__Apply_To_All__c, $ObjectType.ENT_2__SP__c.Fields.Name, 'True')=True
However, this validation is allowing me to save no matter the lookup SP has 'Apply_To_All__c' checked or unchecked.
I even could not validate for attaching only SPs that have P1__c='Critical' with the following rule:
VLOOKUP($ObjectType.ENT_2__SP__c.Fields.ENT_2__P1__c, $ObjectType.ENT_2__SP__c.Fields.Name, 'Critical')='Critical'
Thanks,
-Roshan
-
- Roshan Tamrakar
- June 30, 2008
- Like
- 0
- Continue reading or reply
URL structure for Console Tab VS Detail Tab
I have a vf page inside Account under a section. A button in that page opens new case window. In order to achieve this I create a new url with the help of pagereference and returns to the page. This opens the case window. When I cancel, I am returned to the account and if I save I am returned to saved case.
It works fine. However if I do the same from the console window, the whole page is refreshed and the new case window is displayed (it should open within the Account detail frame). When I cancel/save, I am not returned to the console instead I returned to the Account (on cancel) or Case (on save).
Below is the code in s-control which I am converting to vf page with apex class.
var desktop = new DesktopApi(); if (desktop.desktopPageWindow) { parent.frames.location.replace('/'+result[0].id+'/e—retURL=%2F'+result[0].id+'%3Fisdtp%3Dmn%26retURL%3D%2Fui%2Fdesktop%2FDesktopMainDefaultPage%3Fisdtp%3Dmn&def_contact_id='+caseObj.ContactId+'&def_account_id='+caseObj.AccountId+'&isdtp=mn&saveURL=%2Fservlet%2Fservlet.Integration%3Flid%3D01N600000004hPk'); } else{ parent.navigateToUrl('/'+result[0].id+'/e–retURL=%2F'+result[0].id+'&saveURL=%2Fservlet%2Fservlet.Integration%3Flid%3D01N600000004hPk'); }
I am not sure how I can do above in apex class.
My first issue..How could I know that I am in desktopPageWindow from apex class?
Second, If I got it...how my parameters will change?
Below is my method which I am currently using:
public PageReference CreateNewCase(Id retUrlId, Id contId, Id acId, String prmFunc, Id prmEntId, Id prmspId, String prmEntName){ CaseOrigin = '&cas11='+EntUtil.GetDefaultPicklistValueFromCase('origin'); Status = '&cas7='+EntUtil.GetDefaultPicklistValueFromCase('status'); String sPriority = EntUtil.GetDefaultPicklistValueFromCase('priority'); Priority = '&cas8='+sPriority; PageReference page = new PageReference('/500/e—retURL=/'+retUrlId+CaseOrigin+Status+Priority); page.setRedirect(true); return page; }
Please help.
Thanks,
-Roshan
-
- Roshan Tamrakar
- June 26, 2008
- Like
- 0
- Continue reading or reply
VF Page in Section
Below is my page and controller class.
<apex:page standardController="Account" extensions="AccountExtension" sidebar="false" showheader="false"> <apex:form > <apex:pageBlock id="out" rendered="False"> </apex:pageBlock> <apex:pageBlock > {!Account.Name} <apex:pageBlockSection > <apex:pageblockTable value="{!Account.Contacts}" var="cnt"> <apex:column value="{!cnt.Name}"/> <apex:column > <apex:commandButton value="{!cnt.Name}" action="{!dosomething}" rerender="out"> <apex:param name="prmFunc" value="{!cnt.Name}"/> </apex:commandButton> </apex:column> </apex:pageblockTable> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page> public class AccountExtension{ private final Account ac; Id acId; //Constructor public AccountExtension(ApexPages.StandardController stdController){ this.ac = (Account)stdController.getRecord(); //Store Account's id acId = System.CurrentPageReference().getParameters().get('id'); } public PageReference dosomething(){ String prmFunc = System.currentPageReference().getParameters().get('prmFunc'); PageReference page = new PageReference('/500/e—retURL=/'+acId+'&cas15='+prmFunc); page.setRedirect(true); return page; } }
Everything works find and I even receive the parameter from my controller class. The problem is:
The above page I have placed inside a section in the Account detail page.

When I click on the button, new Case window is opened within the section.

I want the case to open in the whole page not within the section.
If I remove my rerender attribute from the commandButton, it works but then I don't get the parameter value. It's very frustrating.
If I change above commandButton to commandLink, then it works without any rerender attribute.
But my requirement is to use commandButton.
Code submitted above is not dependent on any custom object, so it can be just copied and pasted for the test.
Please help.
-
- Roshan Tamrakar
- June 26, 2008
- Like
- 0
- Continue reading or reply
Random name for relationship name
I wanted to have a many-to-many relationship between Asset and a custom object SP__c. For that I created a custom object Program_Asset__c. I added two lookup fields in it, one related to Asset and other related to SP__c. When I checked it in Apex Explorer, the child relationship name in Asset is some odd number and not in readable form (should have been Program_Assets__r). The highlighted item is the one.

Because of this my deployment fails in other org because it is used in my soql query and new package installation creates another random name for the relationship.
Select Id, (Select SP__c, SP__r.Name From a.R00N30000002NWqzEAG) From Asset a Where a.Id ='02i30000001DcJa'
Also, How do I know from apex class that I am currently in 'Desktop' page (console tab): https://na1.salesforce.com/ui/desktop/DesktopPage
Please help me.
Thanks,
-Roshan
-
- Roshan Tamrakar
- June 25, 2008
- Like
- 0
- Continue reading or reply
White space below VF Page when placed inside a section
I have created a VF Page and added that inside Account Detail page under a separete section.
The properties of the section are:
Name: Contact List
Column: 1
Tab Order: Top-Down
Show Section Heading On Detail Page: checked
Show Section Heading On Edit Page: checked
The properties of VF Page placed inside the section are:
Width: 100%
Height: 200px
Show Scrollbars: checked
Show label: unchecked
The output is as below:

The VF Page source code:
<apex:page standardController="Account"> <apex:pageBlock > {!Account.Name} <apex:pageBlockSection > <apex:pageBlockTable value="{!Account.Contacts}" var="cnt"> <apex:column value="{!cnt.Name}"/> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> </apex:page>
My problem is:
I don't want the white space below the page that is being displayed in above picture. If the list is too short the white space will be more. I want the page to cover the whole section.
What tag, attributes or settings help me to avoid the white section and cover the whole section.
Please help.
Thanks,
-Roshan
-
- Roshan Tamrakar
- June 20, 2008
- Like
- 0
- Continue reading or reply
Open VF Page in 'Add' mode
I want to be able to create new record with some fields pre-populated with default value and display to user ready for save. The new record window I want to invoke from a class. For my similar post earlier, Ron Hess has suggested me to use visualforce page with custom controller and extension to read parameter and assign them to new case. Below is what I tried.
Test_Object__c
Name
Log_Date__c
Score__c
TestObjectPage.page
<apex:page standardController=" Test_Object__c" extensions="TestObjectExtension"> <apex:pageBlock> Test Object Name = {! Test_Object__c.Name} PrmName = {!prmName} </apex:pageBlock> <apex:detail/> </apex:page>
This displays my object’s detail page in detail window.
TestObjectExtension.cls
public class TestObjectExtension{ private final Test_Object__c t; String name; public TestObjectExtension(ApexPages.StandardController stdController){ this.t = (Test_Object__c)stdController.getRecord(); String prmName = System.CurrentPageReference().getParameters().get('name'); this.name = prmName; t.Name = prmName; System.debug('abcd'); System.debug(prmName); } public String getPrmName(){ return this.name; } }
To use this page in ‘View’ mode, I overrode ‘View’ button with my VF page. When I click any record in this object, my VF page is displayed correctly. It also executes my class.
But as per my requirement, I overrode ‘New’ button with my VF page so that when a new record is being created, my VF page is displayed so that I could pre-populate some of the fields.
When I click on the ‘New’ button, it returns error as ‘Unable to Access Page’.
Do I need to override the button at all? How could I call my VF page to open in ‘add’ mode and populate some of the fields?
Please help
-
- Roshan Tamrakar
- June 02, 2008
- Like
- 0
- Continue reading or reply
Date Subtraction
Hi Experts,
I have a field (first_response__c) of type datetime and I want to find the difference between the value in this field and current date time (system.now()).
System.debug(first_response__c - system.now()); // first_response__c is greater than system.now() here.
It throws me error like:
"Date/time arithmetic expressions must use Integer and Double arguments"
I also tried to use DATEVALUE() function as found a remedy in other posts, but it does not recognize this method. It returns error like:
"Method does not exist or incorrect signature: DATEVALUE(Datetime)"
I am working in DE org from Eclipse IDE.
What am I doing wrong? Is there any function that differenciates two datetime value and returns me a value in hours?
Thank you,
-Roshan
-
- Roshan Tamrakar
- May 16, 2008
- Like
- 0
- Continue reading or reply
Open 'Add New' window and populate Custom and Standard Fields via Apex Class
Hello experts,
I am creating a VF Page in Contact detail page. The page lists some values from an object which is child of the Contact object. This is not important though. One of the columns in the list has a commandLink.
What I want to achieve is that when the link is clicked, I want open Case detail page in ‘add mode’ (ready to save, as if user has clicked on ‘New’ button in ‘Cases’ Home page). I also want to populate some of the fields with default values when the Case detail page is opened.
I succeeded on most parts, like I could open Case detail page in ‘add-mode’ and populated some of the fields.
Part of my VF Page code is:
<apex:column> <apex:commandLink value="{!ent.ButtonCaption}" action="{!CreateNewCase}"> <apex:param name="prmFunc" value="{!ent.NewCaseFuncName}"/> <apex:param name="prmEntId" value="{!ent.ent.Id}"/> <apex:param name="prmSPId" value="{!ent.ent.Support_Program__c}"/> <apex:param name="prmEntName" value="{!ent.ent.Name}"/> </apex:commandLink> </apex:column>
And the function in my Apex Class is:
public PageReference CreateNewCase(){ String prmFunc = System.currentPageReference().getParameters().get('prmFunc'); ID prmEntId = System.currentPageReference().getParameters().get('prmEntId'); ID prmSpId = System.currentPageReference().getParameters().get('prmSPId'); String prmEntName = System.currentPageReference().getParameters().get('prmEntName'); String ContactId, AccountName, CaseOrigin, Status, Priority, EntId; ContactId = (String)contId; ContactId = '&cas3_lkid='+ContactId.substring(0,ContactId.length()-3); AccountName = [Select Name from Account where Id=:acId].Name; AccountName = '&cas4='+AccountName; EntId = (String)prmEntId; EntId = '&00N60000001NTnz='+EntId.substring(0,EntId.length()-3); //EntId = '&00N60000001NTnz=a0760000001kq3lAAA'; //EntId = '&00N60000001NTnz=a0760000001MYD9'; CaseOrigin = '&cas11=Phone'; Status = '&cas7=New'; Priority = '&cas8=High'; return new PageReference('/500/e—retURL=/'+acId+ContactId+AccountName+CaseOrigin+Status+Priority+EntId); }
The parameter is being sent correctly and there is no problem in it.
According to the suggestion given in the links below, I was able to populate some of the fields by assigning values in their ‘Field ID’ in the link.
http://salesforce.phollaio.com/2007/04/02/how_to_obtain_a_field_id/
http://salesforce.phollaio.com/2007/01/31/play_with_custom_links_part_2/
So, to open a New Case window with data populated for Contact, Account, Case Origin, Status, Priority and Ent (one of the custom fields in Case object) I build up new URL in the following way:
- ‘/500/e’ - to open Case in add mode
- ‘&cas4 =’ +AccountName – to populate Account Name field
- ‘&cas3_lkid=’+ContactId – to populate Contact Name field
- '&cas11=Phone' – to populate Case Origin field
- '&cas7=New' – to populate Status field
- '&cas8=High' – to populate Priority field
- '&00N60000001NTnz=a0760000001MYD9' – to populate Ent field
Ent is the lookup field in Case object that references to a custom object ‘Ent’
The value ‘00N60000001NTnz’ is the ‘Field ID’ of Ent field in Case object, which I got in the following way:
- Setup --> App Setup --> Customize --> Cases --> Fields
- Click on Custom field ‘Ent’ under ‘Case Custom Fields & Relationships’ section
- From the url ‘https://na4.salesforce.com/00N60000001NTnz’, get the last value
All other other fields are populated except the ‘Ent’ field. I even tried hard-coding the ‘Ent’ id.
My question is:
- Am I specifying the Ent ‘Field ID’ incorrectly?
- Is it an appropriate way of opening ‘New Record’ window?
- Getting ‘Field ID’ this way is correct?
- The Ent field is custom field in Case. If I create the same field (Ent) in the same object (Case) in another org, will the ‘Field ID’ (00N60000001NTnz) remain the same?
Please suggest me if there is another reliable way of opening ‘New Record’ window and populating default values in Custom and Standard fields.
Thanks
-Roshan
-
- Roshan Tamrakar
- May 12, 2008
- Like
- 0
- Continue reading or reply
Getting Picklist Values in Controller
Thanks,
Roshan
-
- Roshan Tamrakar
- May 10, 2008
- Like
- 0
- Continue reading or reply
Getting commandbutton Parameter in controller
<apex:page showHeader="false" controller="VehicleListControllerClass_2"> <apex:form> <apex:pageBlock title="Vehicle List for {!personname}"> <apex:pageBlockList value="{!vehicleList}" var="v"> <apex:column value="{!v.VehicleName}"/> <apex:column value="{!v.PersonVehicle.Vehicle__r.Name}"/> <apex:column headerValue="Vehicle"> <apex:outputLink value="/{!v.PersonVehicle.Vehicle__c}" target="_top">{!v.PersonVehicle.Vehicle__r.Name}</apex:outputLink> </apex:column> <apex:column> <apex:commandLink value="Click This Link" action="{!dosomething}" > <apex:param name="myparm" value="Link abcd"/> </apex:commandLink> </apex:column> <apex:column> <apex:commandButton value="Click This Button" action="{!dosomething}" styleClass="btn"> <apex:param assignTo="{!MP}" name="myparm1" value="abcd"/> <apex:param name="myparm2" value="Button abcd"/> </apex:commandButton> </apex:column> </apex:pageBlockList> </apex:pageBlock> </apex:form> </apex:page> public class VehicleListControllerClass_2{ public String getPersonName(){ ID pId = System.currentPageReference().getParameters().get('id'); String name = [Select Name from Person__c where id=:pId].Name; return name; } public class Vehicles{ Person_Vehicle__c pv; //Constructor public Vehicles(Person_Vehicle__c pvin) {pv = pvin;} public Person_Vehicle__c getPersonVehicle() {return pv;} public String getVehicleName(){ if(pv.Vehicle__r.Name == 'Maruti 800') return 'It is Maruti 800 yar'; else return pv.Vehicle__r.Name; } Integer curYear = system.now().year(); return (curYear - (Integer)pv.Purchase_Year__c); } } List<Vehicles> pvlist = new List<Vehicles>(); public List<Vehicles> getVehicleList(){ ID pId = System.currentPageReference().getParameters().get('id'); pvlist.clear(); for(Person_Vehicle__c pvv : [Select p.Person__r.Name, p.Vehicle__c, p.Vehicle__r.Name, p.Purchase_Year__c from Person_Vehicle__c p where p.Person__c=:pId]){ pvlist.add(new Vehicles(pvv)); } return pvlist; } String p; public String getMP(){ return p; } public void setMP(String s){ p=s; } public PageReference dosomething(){ String s = System.CurrentPageReference().getParameters().get('myparm'); String s1 = System.CurrentPageReference().getParameters().get('myparm1'); String s2 = System.CurrentPageReference().getParameters().get('myparm2'); System.debug(s); System.debug(s1); System.debug(s2); return null; } }
When I click on the link 'Click This Link', String 's' returns 'Link abcd' which is correct.
-
- Roshan Tamrakar
- May 10, 2008
- Like
- 0
- Continue reading or reply
System.Now() and Time Zone
If I issue the following command in an apex class ...
DateTime d = System.now(); return d;
...the datetime it returns belongs to which time zone?
It returned me "Thu May 01 07:40:07 GMT 2008" when I tested on Thursday 05/01/2008 at 1:25PM. Which is correct according to my timezone location.
(my time zone location is "(GMT+05:45) Kathmandu")
Does it always return GMT time? Or it depends on some settings? If so, what is the place of the setting? How do I access that via code?
Also, is there any method like one in javascript "getTimezoneOffset()"?
According to JavaScript guide:
The getTimezoneOffset() method returns the number of minutes that the current time zone is ahead or behind UTC. For instance, getTimezoneOffset() returns 300 for U.S. Eastern Daylight Saving Time, which is 5 hours (or 300 minutes) behind UTC.
Thanks,
-Roshan
-
- Roshan Tamrakar
- May 01, 2008
- Like
- 0
- Continue reading or reply
Page Redirect Issue
Hi Experts,
I have 3 custom objects:
Person__c
Vehicle__c
Person_Vehicle__c
The Person_Vehicle__c is child of Person and it has lookup relationship with Vehicle.
I created a VisualForce page and placed it in person tab. The VisualForce page lists all child records for the person whose data is being displayed. The display in person page is something like:
Person Name Vehicle
Tirtha Maruti 800
Tirtha Zen
The ‘Vehicle’ items are commandLink so that if I click ‘Maruti 800’, the page redirects to ‘Maruti 800’ detail page.
The following is my page and controller code:
public class VehicleListControllerClass{ public String getPersonName(){ ID pId = System.currentPageReference().getParameters().get('id'); String name = [Select Name from Person__c where id=:pId].Name; return name; } public List<Person_Vehicle__c> getVehicleList(){ ID pId = System.currentPageReference().getParameters().get('id'); List<Person_Vehicle__c> data = new List<Person_Vehicle__c>( [Select p.Person__r.Name, p.Vehicle__c, p.Vehicle__r.Name from Person_Vehicle__c p where p.Person__c=:pId]); return data; } public PageReference OpenVehicle(){ PageReference page = System.CurrentPageReference(); ID vId = page.getParameters().get('vehicleId'); return new PageReference('/'+vId); } } <apex:page controller="VehicleListControllerClass"> <apex:form> <apex:pageBlock title="Vehicle List for {!personname}"> <apex:pageBlockList value="{!vehicleList}" var="v"> <apex:column value="{!v.Person__r.Name}"/> <apex:column> <apex:commandLink value="{!v.Vehicle__r.Name}" action="{!OpenVehicle}"> <apex:param name="vehicleId" value="{!v.Vehicle__c}"/> </apex:commandLink> </apex:column> </apex:pageBlockList> </apex:pageBlock> </apex:form> </apex:page>
The first issue:
When I click on any vehicle item, it works nicely and respective vehicle detail is displayed on the page. The url becomes:
https://na2.salesforce.com/a0340000004dX5AAAU?inline=1
But, if I try to do the same with ‘right-click-->Open link in new tab’, it doesn’t work and instead displays error ‘URL No Longer Exists’. The url, in this case, becomes:
https://na2.salesforce.com/servlet/servlet.Integration?lid=0664000000000JY&ic=1#
The second issue:
The second problem is that I do not see the column header for ‘vehicle’ (second column). I also tried to use facet, but it also didn’t work:
<apex:column> <apex:facet name="header">Vehicle</apex:facet> <apex:commandLink value="{!v.Vehicle__r.Name}" action="{!OpenVehiclePage}"> <apex:param name="vehicleId" value="{!v.Vehicle__c}"/> </apex:commandLink> </apex:column>
Please suggest.
Thanks,
-Roshan
-
- Roshan Tamrakar
- April 29, 2008
- Like
- 0
- Continue reading or reply
If Condition in VisualForce Page
Name, Active(Checkbox), Birthday, Age(Numberic)
'Minor' if Age<16, otherwise 'Adult'
I want to be able to do this in any of the following 3 ways:
2. By passing 'Age' as a parameter to my extended controller
3. And using case (or similar) in SOQL
<apex:page standardController="Person__c" extensions="PersonExtension"> <apex:form> <apex:pageblock title="My Persons Infos"> <apex:pageblockList value="{!PersonList}" var="p"> <apex:column value="{!p.Name}"/> <apex:column value="{!p.Active__c}"/> <apex:column value="{!p.Birthday__c}"/> <apex:column value="{!p.Age__c}"/> <apex:column value="{!anystring}"/> <apex:column value="{!IF((p.Age__c>16),'Adult','Minor')}"/> </apex:pageblockList> </apex:pageblock> </apex:form> </apex:page> public class PersonExtension{ private final Person__c person; public PersonExtension(ApexPages.StandardController stdController){ this.person= (Person__c)stdController.getRecord(); } public Person__c[] getPersonList(){ return [Select p.Id, p.Name, p.Age__c, Birthday__c, p.Active__c from Person__c p]; } public String getAnyString(){ return 'Anything'; } }
The error I get is: Error: Syntax error. Missing ')'
<apex:column value="{!IF(CONTAINS({!anystring}, 'Anything'),True, False)}"/>
2. Can I pass a parameter (Age in above case) to my controller and return a string based on parameter supplied to it? If so, how?
3. Can I use case...when clause (or similar like in sql) in my SOQL? If so, how can I do so?
-
- Roshan Tamrakar
- April 28, 2008
- Like
- 0
- Continue reading or reply
VLOOKUP to validate checkbox field type
I have a custom object SP__c having a checkbox field named 'Apply_To_All__c' and a text field P1__c. The standard object 'Account' has a lookup field to this custom object (Account.SP__c). Only SPs that have 'Apply_To_All' checked can be set as a lookup SP for an Account.
Account
Name SP__c
Sonixx Standard
Beltronix Custom (This is invalid as 'Apply_To_All__c' is false for Custom SP)
Airtel Standard
SP__c
Name Apply_To_All__c P1__c
Standard True Critical
Custom False Normal
To achieve this, I wrote the following validation rule in Account:
VLOOKUP($ObjectType.ENT_2__SP__c.Fields.ENT_2__Apply_To_All__c, $ObjectType.ENT_2__SP__c.Fields.Name, 'True')=True
However, this validation is allowing me to save no matter the lookup SP has 'Apply_To_All__c' checked or unchecked.
I even could not validate for attaching only SPs that have P1__c='Critical' with the following rule:
VLOOKUP($ObjectType.ENT_2__SP__c.Fields.ENT_2__P1__c, $ObjectType.ENT_2__SP__c.Fields.Name, 'Critical')='Critical'
Thanks,
-Roshan
- Roshan Tamrakar
- June 30, 2008
- Like
- 0
- Continue reading or reply
Random name for relationship name
I wanted to have a many-to-many relationship between Asset and a custom object SP__c. For that I created a custom object Program_Asset__c. I added two lookup fields in it, one related to Asset and other related to SP__c. When I checked it in Apex Explorer, the child relationship name in Asset is some odd number and not in readable form (should have been Program_Assets__r). The highlighted item is the one.

Because of this my deployment fails in other org because it is used in my soql query and new package installation creates another random name for the relationship.
Select Id, (Select SP__c, SP__r.Name From a.R00N30000002NWqzEAG) From Asset a Where a.Id ='02i30000001DcJa'
Also, How do I know from apex class that I am currently in 'Desktop' page (console tab): https://na1.salesforce.com/ui/desktop/DesktopPage
Please help me.
Thanks,
-Roshan
- Roshan Tamrakar
- June 25, 2008
- Like
- 0
- Continue reading or reply
White space below VF Page when placed inside a section
I have created a VF Page and added that inside Account Detail page under a separete section.
The properties of the section are:
Name: Contact List
Column: 1
Tab Order: Top-Down
Show Section Heading On Detail Page: checked
Show Section Heading On Edit Page: checked
The properties of VF Page placed inside the section are:
Width: 100%
Height: 200px
Show Scrollbars: checked
Show label: unchecked
The output is as below:

The VF Page source code:
<apex:page standardController="Account"> <apex:pageBlock > {!Account.Name} <apex:pageBlockSection > <apex:pageBlockTable value="{!Account.Contacts}" var="cnt"> <apex:column value="{!cnt.Name}"/> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> </apex:page>
My problem is:
I don't want the white space below the page that is being displayed in above picture. If the list is too short the white space will be more. I want the page to cover the whole section.
What tag, attributes or settings help me to avoid the white section and cover the whole section.
Please help.
Thanks,
-Roshan
- Roshan Tamrakar
- June 20, 2008
- Like
- 0
- Continue reading or reply
Date Subtraction
Hi Experts,
I have a field (first_response__c) of type datetime and I want to find the difference between the value in this field and current date time (system.now()).
System.debug(first_response__c - system.now()); // first_response__c is greater than system.now() here.
It throws me error like:
"Date/time arithmetic expressions must use Integer and Double arguments"
I also tried to use DATEVALUE() function as found a remedy in other posts, but it does not recognize this method. It returns error like:
"Method does not exist or incorrect signature: DATEVALUE(Datetime)"
I am working in DE org from Eclipse IDE.
What am I doing wrong? Is there any function that differenciates two datetime value and returns me a value in hours?
Thank you,
-Roshan
- Roshan Tamrakar
- May 16, 2008
- Like
- 0
- Continue reading or reply
Getting commandbutton Parameter in controller
<apex:page showHeader="false" controller="VehicleListControllerClass_2"> <apex:form> <apex:pageBlock title="Vehicle List for {!personname}"> <apex:pageBlockList value="{!vehicleList}" var="v"> <apex:column value="{!v.VehicleName}"/> <apex:column value="{!v.PersonVehicle.Vehicle__r.Name}"/> <apex:column headerValue="Vehicle"> <apex:outputLink value="/{!v.PersonVehicle.Vehicle__c}" target="_top">{!v.PersonVehicle.Vehicle__r.Name}</apex:outputLink> </apex:column> <apex:column> <apex:commandLink value="Click This Link" action="{!dosomething}" > <apex:param name="myparm" value="Link abcd"/> </apex:commandLink> </apex:column> <apex:column> <apex:commandButton value="Click This Button" action="{!dosomething}" styleClass="btn"> <apex:param assignTo="{!MP}" name="myparm1" value="abcd"/> <apex:param name="myparm2" value="Button abcd"/> </apex:commandButton> </apex:column> </apex:pageBlockList> </apex:pageBlock> </apex:form> </apex:page> public class VehicleListControllerClass_2{ public String getPersonName(){ ID pId = System.currentPageReference().getParameters().get('id'); String name = [Select Name from Person__c where id=:pId].Name; return name; } public class Vehicles{ Person_Vehicle__c pv; //Constructor public Vehicles(Person_Vehicle__c pvin) {pv = pvin;} public Person_Vehicle__c getPersonVehicle() {return pv;} public String getVehicleName(){ if(pv.Vehicle__r.Name == 'Maruti 800') return 'It is Maruti 800 yar'; else return pv.Vehicle__r.Name; } Integer curYear = system.now().year(); return (curYear - (Integer)pv.Purchase_Year__c); } } List<Vehicles> pvlist = new List<Vehicles>(); public List<Vehicles> getVehicleList(){ ID pId = System.currentPageReference().getParameters().get('id'); pvlist.clear(); for(Person_Vehicle__c pvv : [Select p.Person__r.Name, p.Vehicle__c, p.Vehicle__r.Name, p.Purchase_Year__c from Person_Vehicle__c p where p.Person__c=:pId]){ pvlist.add(new Vehicles(pvv)); } return pvlist; } String p; public String getMP(){ return p; } public void setMP(String s){ p=s; } public PageReference dosomething(){ String s = System.CurrentPageReference().getParameters().get('myparm'); String s1 = System.CurrentPageReference().getParameters().get('myparm1'); String s2 = System.CurrentPageReference().getParameters().get('myparm2'); System.debug(s); System.debug(s1); System.debug(s2); return null; } }
When I click on the link 'Click This Link', String 's' returns 'Link abcd' which is correct.
- Roshan Tamrakar
- May 10, 2008
- Like
- 0
- Continue reading or reply
Page Redirect Issue
Hi Experts,
I have 3 custom objects:
Person__c
Vehicle__c
Person_Vehicle__c
The Person_Vehicle__c is child of Person and it has lookup relationship with Vehicle.
I created a VisualForce page and placed it in person tab. The VisualForce page lists all child records for the person whose data is being displayed. The display in person page is something like:
Person Name Vehicle
Tirtha Maruti 800
Tirtha Zen
The ‘Vehicle’ items are commandLink so that if I click ‘Maruti 800’, the page redirects to ‘Maruti 800’ detail page.
The following is my page and controller code:
public class VehicleListControllerClass{ public String getPersonName(){ ID pId = System.currentPageReference().getParameters().get('id'); String name = [Select Name from Person__c where id=:pId].Name; return name; } public List<Person_Vehicle__c> getVehicleList(){ ID pId = System.currentPageReference().getParameters().get('id'); List<Person_Vehicle__c> data = new List<Person_Vehicle__c>( [Select p.Person__r.Name, p.Vehicle__c, p.Vehicle__r.Name from Person_Vehicle__c p where p.Person__c=:pId]); return data; } public PageReference OpenVehicle(){ PageReference page = System.CurrentPageReference(); ID vId = page.getParameters().get('vehicleId'); return new PageReference('/'+vId); } } <apex:page controller="VehicleListControllerClass"> <apex:form> <apex:pageBlock title="Vehicle List for {!personname}"> <apex:pageBlockList value="{!vehicleList}" var="v"> <apex:column value="{!v.Person__r.Name}"/> <apex:column> <apex:commandLink value="{!v.Vehicle__r.Name}" action="{!OpenVehicle}"> <apex:param name="vehicleId" value="{!v.Vehicle__c}"/> </apex:commandLink> </apex:column> </apex:pageBlockList> </apex:pageBlock> </apex:form> </apex:page>
The first issue:
When I click on any vehicle item, it works nicely and respective vehicle detail is displayed on the page. The url becomes:
https://na2.salesforce.com/a0340000004dX5AAAU?inline=1
But, if I try to do the same with ‘right-click-->Open link in new tab’, it doesn’t work and instead displays error ‘URL No Longer Exists’. The url, in this case, becomes:
https://na2.salesforce.com/servlet/servlet.Integration?lid=0664000000000JY&ic=1#
The second issue:
The second problem is that I do not see the column header for ‘vehicle’ (second column). I also tried to use facet, but it also didn’t work:
<apex:column> <apex:facet name="header">Vehicle</apex:facet> <apex:commandLink value="{!v.Vehicle__r.Name}" action="{!OpenVehiclePage}"> <apex:param name="vehicleId" value="{!v.Vehicle__c}"/> </apex:commandLink> </apex:column>
Please suggest.
Thanks,
-Roshan
- Roshan Tamrakar
- April 29, 2008
- Like
- 0
- Continue reading or reply
If Condition in VisualForce Page
Name, Active(Checkbox), Birthday, Age(Numberic)
'Minor' if Age<16, otherwise 'Adult'
I want to be able to do this in any of the following 3 ways:
2. By passing 'Age' as a parameter to my extended controller
3. And using case (or similar) in SOQL
<apex:page standardController="Person__c" extensions="PersonExtension"> <apex:form> <apex:pageblock title="My Persons Infos"> <apex:pageblockList value="{!PersonList}" var="p"> <apex:column value="{!p.Name}"/> <apex:column value="{!p.Active__c}"/> <apex:column value="{!p.Birthday__c}"/> <apex:column value="{!p.Age__c}"/> <apex:column value="{!anystring}"/> <apex:column value="{!IF((p.Age__c>16),'Adult','Minor')}"/> </apex:pageblockList> </apex:pageblock> </apex:form> </apex:page> public class PersonExtension{ private final Person__c person; public PersonExtension(ApexPages.StandardController stdController){ this.person= (Person__c)stdController.getRecord(); } public Person__c[] getPersonList(){ return [Select p.Id, p.Name, p.Age__c, Birthday__c, p.Active__c from Person__c p]; } public String getAnyString(){ return 'Anything'; } }
The error I get is: Error: Syntax error. Missing ')'
<apex:column value="{!IF(CONTAINS({!anystring}, 'Anything'),True, False)}"/>
2. Can I pass a parameter (Age in above case) to my controller and return a string based on parameter supplied to it? If so, how?
3. Can I use case...when clause (or similar like in sql) in my SOQL? If so, how can I do so?
- Roshan Tamrakar
- April 28, 2008
- Like
- 0
- Continue reading or reply