-
ChatterFeed
-
3Best Answers
-
0Likes Received
-
0Likes Given
-
11Questions
-
23Replies
twistSection not working
Hi everyone.
I am trying to implement SFDCFox's twistSection code that I have found in multiple places.
Every variation that I can find on Force.com is not working, so I suspect that I have done something terribly wrong. Could someone please help me out ?
I have a pageBlock with multiple pageBlockSections. I want to be able to toggle the sections open or closed onClick of the triangle img from salesforce.
Here is a small piece of my page:
<apex:page showHeader="false" sidebar="false" standardController="Opportunity" tabStyle="Opportunity" extensions="getAllRecords"> <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" />
...
<apex:pageBlock id="block1" mode="detail" rendered="true">
<apex:tabPanel selectedTab="FIRST TAB" id="theTabPanel" tabClass="activeTab" inactiveTabClass="inactiveTab" width="100%">
<apex:tab label="FIRST TAB" name="firstOne" labelWidth="250px" id="one">
<apex:pageBlockSection id="underFive" title="Within 5 Days or Past Due.." columns="1" collapsible="true">
<apex:PageBlockTable value="{!DuePastDue}" var="records" rowClasses="brightRed1,brightRed2" >
<!--I have multiple columns here-->
<apex:column value="{!records.Account_Name__c}" headerValue="Account Name" width="19%" /> </apex:pageBlockTable>
<script>
twistSection(document.getElementById('{!$Component.block1.theTabPanel.one.underFive}').getElementsByTagName('img')[0])
</script>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:tab>
</apex:tabPanel>
</apex:pageBlock>
I cut almost all the extra bits for brevity.
I have also tried:
twistSection(document.getElementById('{!$Component.block1.underFive}').getElementsByTagName('img')[0])
twistSection(document.getElementById('{!$Component.underFive}').getElementsByTagName('img')[0])
twistSection(document.getElementById('{!$Component.j_id0.block1.theTabPanel.underFive}').getElementsByTagName('img')[0])
twistSection(document.getElementById('{!$Component.j_id0.block1.underFive}').getElementsByTagName('img')[0])
For all of them, when i run it, the twistSection does not work. It does append the alt's "Hide Details" name, so I know it is recognizing the image at least.
And, finally, when I use the Firefox debugger tool, here is the id I get for my global component reference:
div id="j_id0:block1:underFive"
What am I doing wrong?
Any suggestions would be helpful, thanks!
***** 12/27/2012 UPDATE: when i remove the tabPanel and tab tags from the VF page, the twistSection works fine.
So how do I keep the <apex:tab> and <apex:tabPanel> portions of the page AND use the twistSection?
-
- Grrrrrrrrrrrrr
- December 27, 2012
- Like
- 0
- Continue reading or reply
Trigger help
Hello!
I am writing a trigger (or trying to ...) that will create X amount of child records on a parent.
Parent - Custom Object: Finance__c
Child - Custom Object: Finance_Payment__c
On the parent is a field called Number_of_payments__c
I want the trigger to (after parent insert) create the same number of children records as indicated in the field Number_of_payments__c.
The only field on the child record that needs to be populated on the initial insert is the payment_number__c (which starts at 1 and ends at :Number_of_payments).
Can someone help me fill in the blanks (and correct mistakes).
I am very new to triggers. Thanks!
trigger Payments on Finance_Payment__c (after insert){ // collect parent id ?
id[] finIds = new Id[0];
// collect number of payments data
Finance__c[] parent;
parent = [SELECT Number_of_payments__c FROM Finance__c WHERE Finance__C IN (ParentID?)];
// iterate through to create child records.
for (Finance_Payment__c f : tigger.new){
// create records using number of payments
insert ?;
}
}
-
- Grrrrrrrrrrrrr
- December 15, 2012
- Like
- 0
- Continue reading or reply
Reviews on AppExchange for Partner Portal Customers?
Hello Everyone,
My question is more App-Administrative than anything else.
All of our clients use our Partner Portal, so they are not salesforce users. They cannot log in to leave a review for us in the AppExchange Marketplace.
Does anyone have any idea how we can allow our clients to share their thoughts on our App without signing up for a SF account??
Thanks in advance!
-
- Grrrrrrrrrrrrr
- December 06, 2012
- Like
- 0
- Continue reading or reply
54% coverage on test method ... almost there ... need a little help
Jeff Douglas wrote a wonderful chunk of code ( http://blog.jeffdouglas.com/2010/07/13/building-a-dynamic-search-page-in-visualforce/ )
And I am working on applying it to my org. I have it in my sandbox and it works awesome! But I am having trouble getting anything over 50% code coverage.
Can someone help me to figure out the last little bit? Thanks in advance!
Here is my test so far:
@isTest(SeeAllData=true) private with sharing class TestOpportunitySearchController { static testMethod void myTest() { Test.startTest(); date testdate = System.today().addDays(+1); Account testaccount = new Account(Name = 'test', Trident_Contract_Manager__c = 'test'); insert testaccount; Opportunity testrenewal = new Opportunity(accountId = testaccount.Id, Amount = 100.00, Closedate = testdate, Description = 'test', Name = 'test', Stagename = 'Baseline', Probability = 100, OwnerId = UserInfo.getUserId(), Coverage_Start_Date__c = System.today().addDays(-15), Coverage_End_Date__c = System.today().addDays(100)); insert testrenewal; ApexPages.StandardController sc1 = new ApexPages.StandardController(testrenewal); OpportunitySearchController controller1 = new OpportunitySearchController(sc1); controller1.runQuery(); controller1.runSearch(); controller1.toggleSort(); Test.stopTest(); } }
Here is my missing coverage (red indicates not covered): I cant figure out how to call the 'stages' and 'managers' methods.
line source 1 public with sharing class OpportunitySearchController { 2 public OpportunitySearchController(ApexPages.StandardController controller) { soql = 'select name, account.name, Trident_Contract_Manager2__c, stagename from opportunity where name != null'; runQuery(); } 3 private String soql {get;set;} 4 public List<Opportunity> renewals {get;set;} 5 public String sortDir { get { if (sortDir == null) { sortDir = 'asc'; } return sortDir; } set; } 6 public String sortField { get { if (sortField == null) {sortField = 'name'; } return sortField; } set; } 7 public String debugSoql { get { return soql + ' order by ' + sortField + ' ' + sortDir + ' limit 40'; } set; } 8 9 public void toggleSort() { sortDir = sortDir.equals('asc') ? 'desc' : 'asc'; runQuery(); } 10 public void runQuery() { 11 try { renewals = Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 40'); } catch (Exception e) { ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!')); } } 12 public PageReference runSearch() { 13 String name = Apexpages.currentPage().getParameters().get('name'); 14 String account = Apexpages.currentPage().getParameters().get('account'); 15 String manager = Apexpages.currentPage().getParameters().get('manager'); 16 String stage = Apexpages.currentPage().getParameters().get('stage'); 17 soql = 'select name, account.name, Trident_Contract_Manager2__c, stagename from opportunity where name != null'; 18 if (!name.equals('')) soql += ' and name LIKE \''+String.escapeSingleQuotes(Name)+'%\''; 19 if (!account.equals('')) soql += ' and account.name LIKE \''+String.escapeSingleQuotes(account)+'%\''; 20 if (!manager.equals('')) soql += ' and Trident_Contract_Manager2__c LIKE \''+manager+'\''; 21 if (!stage.equals('')) soql += ' and stagename LIKE \''+stage+'\''; 22 runQuery(); 23 return null; 24 } 25 26 27 public List<String> stages { 28 get { if (stages == null) { stages = new List<String>(); 29 Schema.DescribeFieldResult field = Opportunity.stagename.getDescribe(); 30 for (Schema.PicklistEntry f : field.getPicklistValues()) stages.add(f.getLabel()); } 31 return stages; 32 } 33 set; 34 } 35 public List<String> managers { 36 get { if (managers == null) { managers = new List<String>(); 37 Schema.DescribeFieldResult field = Account.Trident_Contract_Manager__c.getDescribe(); 38 for (Schema.PicklistEntry f : field.getPicklistValues()) managers .add(f.getLabel()); 39 } 40 return managers; 41 } 42 set; 43 } 44 }
Thank you!
-
- Grrrrrrrrrrrrr
- December 04, 2012
- Like
- 0
- Continue reading or reply
There is no error when I check syntax, but still not working
In my quest to find a way to report on rolling months in custom object, I decided to brainiack this approach.
I set a field to todays date. Then I add a month. So, this formula works somewhat (returns wrong month right now):
IF(MONTH(TODAY()) + 1 >= 12, "1", TEXT(MONTH(TODAY()) + 1)) & "/1/" & IF(MONTH(TODAY()) + 1 >= 12, TEXT(YEAR(TODAY()) +1), TEXT(YEAR(TODAY())))
But if I want to calculate the following months based on today (for example):
IF(MONTH(TODAY()) + 2 >= 12, "1", TEXT(MONTH(TODAY()) + 2)) & "/1/" & IF(MONTH(TODAY()) + 2 >= 12, TEXT(YEAR(TODAY()) +1), TEXT(YEAR(TODAY()))) IF(MONTH(TODAY()) + 3 >= 12, "1", TEXT(MONTH(TODAY()) + 3)) & "/1/" & IF(MONTH(TODAY()) + 3 >= 12, TEXT(YEAR(TODAY()) +1), TEXT(YEAR(TODAY()))) IF(MONTH(TODAY()) + 4 >= 12, "1", TEXT(MONTH(TODAY()) + 4)) & "/1/" & IF(MONTH(TODAY()) + 4 >= 12, TEXT(YEAR(TODAY()) +1), TEXT(YEAR(TODAY()))) IF(MONTH(TODAY()) + 5 >= 12, "1", TEXT(MONTH(TODAY()) + 5)) & "/1/" & IF(MONTH(TODAY()) + 5 >= 12, TEXT(YEAR(TODAY()) +1), TEXT(YEAR(TODAY()))) IF(MONTH(TODAY()) + 6 >= 12, "1", TEXT(MONTH(TODAY()) + 6)) & "/1/" & IF(MONTH(TODAY()) + 6 >= 12, TEXT(YEAR(TODAY()) +1), TEXT(YEAR(TODAY()))) IF(MONTH(TODAY()) + 7 >= 12, "1", TEXT(MONTH(TODAY()) + 7)) & "/1/" & IF(MONTH(TODAY()) + 7 >= 12, TEXT(YEAR(TODAY()) +1), TEXT(YEAR(TODAY())))
these all return the same date (1/1/2013).
AND if I try to use the first rolling date calculated like this:
IF(MONTH(DATEVALUE(Rolling_Months_1__c)) + 2 >= 12, "1", TEXT(MONTH(TODAY()) + 2)) & "/1/" & IF(MONTH(DATEVALUE(Rolling_Months_1__c)) + 2 >= 12, TEXT(YEAR(TODAY()) +1), TEXT(YEAR(TODAY())))
I do not get any syntax errors, BUT my field displays this --> #error <-- instead of a date.
I should point out that ALL my formula fields are set to return values as text.
Anyone have any ideas on this?
Thanks!
Temple
-
- Grrrrrrrrrrrrr
- November 29, 2012
- Like
- 0
- Continue reading or reply
Help with get; set; methods
Hi everyone. I am trying to understand how to use the get; set; methods. Here is my block of code:
public class LogoImage { public LogoImage(ApexPages.StandardController controller) { get{ return image; } set{ image = value; } } // get a company logo: based on user log in, strip spaces, return image name public String getImageName(){ String file = [SELECT Name FROM Account WHERE Id IN (SELECT AccountId FROM user WHERE username=:UserInfo.getUsername() ) LIMIT 1 ].Name; file = file.replace(' ', ''); String foldername = 'Logos/'; String extension = '.jpg'; String fullImageName = foldername + file + extension; return fullImageName; } }
I am trying to understand what the Apex Developer's Guide means and I obviously don't (so say my error messages :) ) ... Could someone please show me (in code, not links to more reading material) an example of how I would want to use the get set method?
I should also point out that without the get/set this works on my visualforce pages. My partner portal users get a logo image on their page of their company when they log in. But I want to understand gets and sets so I can write pages and classes that are ... well, not crappy.
Thanks!
-
- Grrrrrrrrrrrrr
- November 29, 2012
- Like
- 0
- Continue reading or reply
Page Block / Command Button style
I am going crazy.
Here is my VF snippet:
<!-- --------------------------------------- --> <!-- ---------------- UPLOAD --------------- --> <!-- --------------------------------------- --> <div> <apex:form enctype="multipart/form-data"> <apex:pageMessages /> <p>UPLOAD AN ATTACHMENT</p> <apex:pageBlock id="buttons"> <apex:pageBlockButtons > <apex:commandButton styleclass="button1" action="{!upload}" value="Upload Document"/> </apex:pageBlockButtons> </apex:pageBlock> <apex:outputLabel value="File Name" for="fileName"/><apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" id="file"/> <apex:inputText value="{!attachment.name}" id="fileName"/><apex:outputLabel value="File Name" for="file"/> </apex:form> </div> <!-- --------------------------------------- --> <!-- ------------ END UPLOAD --------------- --> <!-- --------------------------------------- -->
Here is my VF view:
It looks so painfully ugly. I know. I have tried everything I can think of in my styles.
Here are some that have yielded poor results:
.pbHeader {clear:both!important; text-align: left!important; background-color: #FFFFFF!important;} .pbTitle {width: 50%!important} .bPageBlock {background-color:#FFFFFF!important; clear:both!important; text-align:left!important; padding: 0px!important; margin: 0px!important; } .button1 {background-color:#FFFFFF; clear:both!important; text-align:left!important; padding: 0px!important; margin: 0px!important; }
What I am looking to do is to justify left my page buttons block of code. But I can't seem to get down to the heart of css code.
Any thoughts?
-
- Grrrrrrrrrrrrr
- November 19, 2012
- Like
- 0
- Continue reading or reply
Passing data to Visualforce page
I have a class that stores data from a custom object into a List. The class sorts the list and does all the things it needs to do, but now I want to pass the data back to my visualforce page.
But! I dont want to use pageblock or tabledata to render the values. Everytime I reference my class, it errors out on me. Here is some code:
First method in my class that is getting the data:
public class getOnboarding { public getOnboarding(ApexPages.StandardController Controller){ } public SFDC_Acct_Plan__c[] getPlanInfo(){ List<SFDC_Acct_Plan__c> fields = new List<SFDC_Acct_Plan__c>(); fields = [SELECT Planning_Year__c, Sales_Agreement_in_Place__c, Plan_Status__c, Last_Plan_Revision__c, Days_Between__c, Non_Disclosure_Agreement_in_Place__c, Number_of_assets_tracked__c, On_Boarding_Packet_to_Customer__c, Kickoff_Meeting_Completed__c, Kickoff_Meeting_Completed_on__c FROM SFDC_Acct_Plan__c WHERE Account__c IN (SELECT AccountId FROM AccountShare WHERE UserOrGroupId=:Userinfo.getUserId()) AND (Plan_Status__c = 'Draft') ]; return fields; }
and I want to pass it to my VF page:
<apex:page showHeader="false" sidebar="false" standardController="SFDC_Acct_Plan__c" extensions="getOnboarding"> <!-- --------------------------------------- --> <!-- ------------START OF STYLES------------ --> <!-- --------------------------------------- --> <style> #onboardingStages {text-align: center; width:95%} .pbheader {background-color:#000000!important; color:#FF4D4D!important;} .pbsubheader {background-color:#FFFF85!important; color:#5a5a5a!important;} </style> <!-- --------------------------------------- --> <!-- ------------ END OF STYLES ------------ --> <!-- --------------------------------------- --> <h1>Welcome Back {!$User.FirstName}</h1><br/> <h2>Date: {!MONTH(TODAY())}/{!DAY(TODAY())}/{!YEAR(TODAY())}</h2> <div id="onboardingStages"> <apex:variable var="stage" value="{!StageImage}"/> <apex:image url="{!URLFOR($Resource.Stages, stage)}" /> </div>
But I want to put the data into my own table.
If I reference my method {!PlanInfo.Plan_Status__c} it will not allow me to use the data (unless its in a pageBlock). I have also tried using variables for this.
I basically want to pass it to an HTML table cell that I define later.
Anyone come across this before? I know its something easy and silly ... but I cant get it.
Thank you,
TS
-
- Grrrrrrrrrrrrr
- November 16, 2012
- Like
- 0
- Continue reading or reply
Reference List
I have been working on creating some new visualforce pages and I thought I was doing ok. But now I stumbled across some of this code:
.pbSection
.pbSubHeader
etc, when it comes to using styles! I have searched the internet, but cannot find any reference material that will give me a list of all these available classes for use in CSS on my visualforce pages. I had no idea they even existed!! But try as I might, I cannot get mine to work quite right. Does anyone have a great reference page they can point out for me? I appreciate any and all tips.
Also, if anyone has some suggestions on how to best use !important that would be great too.
-
- Grrrrrrrrrrrrr
- November 15, 2012
- Like
- 0
- Continue reading or reply
Trigger for Child Records
Hello everyone.
I am pretty sure that what I need to do is write a trigger to accomplish my goal, but I have not written one before and need some help with the code. I will try to outline this as best I can, and any help is appreciated.
I have a parent Custom Object called Job__c
I have a child Custom Object called Bid__c
On Bid__c I have a field called Status__c that is a picklist with the values "Awarded" and "Lost"
One Job__c can have 1 to many Bid__c
When one Bid__c Status__c is changed to "Awarded" I need for all remaining Bid__c Status__c to change from "Pending" to "Lost"
I have absolutely no idea how to accomplish this. I have read through some of the posts about triggers in here, but I have never done anything with one before, and I am pretty lost.
Here is what I have so far, which is nothing, and I am already not sure if its right. (I can't wait to get beat up on a Test Class)
trigger updateBids on Bid__c(after update){
for(Bid__c c : trigger.old) {
}
}
Can someone please help me to fill in the missing blanks?
Thank you!
-
- Grrrrrrrrrrrrr
- November 09, 2012
- Like
- 0
- Continue reading or reply
Master-Detail in Edit Mode
Hello Everyone,
I have two custom objects tied by Master-Detail. But in my child object, in edit mode, I cannot see the Master-Detail field (not even as a read only). I do not want to edit the Master Detail field, I just want to be able to show the Parent field.
Example:
Parent Object
Name field
Date field
Currency FIeld, etc.
Child Object
Name (Master Detail from Parent) field
Date field
Location field, etc.
When I am editing my child object, I just want to see which Parent it belongs to. There are too many occassions where the wrong record is being updated since the user is losing track of what Parent / Child records they are really working in!! This is very frustrating.
I am not opposed to VF, Apex, or Trigger workarounds, although shame on Salesforce for making that necessary. I have tried using various formulas and field updates, but each time I am not able to access the Parent's Master-Detail field.
Any thoughts?
Thanks!
-
- Grrrrrrrrrrrrr
- November 07, 2012
- Like
- 0
- Continue reading or reply
twistSection not working
Hi everyone.
I am trying to implement SFDCFox's twistSection code that I have found in multiple places.
Every variation that I can find on Force.com is not working, so I suspect that I have done something terribly wrong. Could someone please help me out ?
I have a pageBlock with multiple pageBlockSections. I want to be able to toggle the sections open or closed onClick of the triangle img from salesforce.
Here is a small piece of my page:
<apex:page showHeader="false" sidebar="false" standardController="Opportunity" tabStyle="Opportunity" extensions="getAllRecords"> <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" />
...
<apex:pageBlock id="block1" mode="detail" rendered="true">
<apex:tabPanel selectedTab="FIRST TAB" id="theTabPanel" tabClass="activeTab" inactiveTabClass="inactiveTab" width="100%">
<apex:tab label="FIRST TAB" name="firstOne" labelWidth="250px" id="one">
<apex:pageBlockSection id="underFive" title="Within 5 Days or Past Due.." columns="1" collapsible="true">
<apex:PageBlockTable value="{!DuePastDue}" var="records" rowClasses="brightRed1,brightRed2" >
<!--I have multiple columns here-->
<apex:column value="{!records.Account_Name__c}" headerValue="Account Name" width="19%" /> </apex:pageBlockTable>
<script>
twistSection(document.getElementById('{!$Component.block1.theTabPanel.one.underFive}').getElementsByTagName('img')[0])
</script>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:tab>
</apex:tabPanel>
</apex:pageBlock>
I cut almost all the extra bits for brevity.
I have also tried:
twistSection(document.getElementById('{!$Component.block1.underFive}').getElementsByTagName('img')[0])
twistSection(document.getElementById('{!$Component.underFive}').getElementsByTagName('img')[0])
twistSection(document.getElementById('{!$Component.j_id0.block1.theTabPanel.underFive}').getElementsByTagName('img')[0])
twistSection(document.getElementById('{!$Component.j_id0.block1.underFive}').getElementsByTagName('img')[0])
For all of them, when i run it, the twistSection does not work. It does append the alt's "Hide Details" name, so I know it is recognizing the image at least.
And, finally, when I use the Firefox debugger tool, here is the id I get for my global component reference:
div id="j_id0:block1:underFive"
What am I doing wrong?
Any suggestions would be helpful, thanks!
***** 12/27/2012 UPDATE: when i remove the tabPanel and tab tags from the VF page, the twistSection works fine.
So how do I keep the <apex:tab> and <apex:tabPanel> portions of the page AND use the twistSection?
- Grrrrrrrrrrrrr
- December 27, 2012
- Like
- 0
- Continue reading or reply
Trigger help
Hello!
I am writing a trigger (or trying to ...) that will create X amount of child records on a parent.
Parent - Custom Object: Finance__c
Child - Custom Object: Finance_Payment__c
On the parent is a field called Number_of_payments__c
I want the trigger to (after parent insert) create the same number of children records as indicated in the field Number_of_payments__c.
The only field on the child record that needs to be populated on the initial insert is the payment_number__c (which starts at 1 and ends at :Number_of_payments).
Can someone help me fill in the blanks (and correct mistakes).
I am very new to triggers. Thanks!
trigger Payments on Finance_Payment__c (after insert){ // collect parent id ?
id[] finIds = new Id[0];
// collect number of payments data
Finance__c[] parent;
parent = [SELECT Number_of_payments__c FROM Finance__c WHERE Finance__C IN (ParentID?)];
// iterate through to create child records.
for (Finance_Payment__c f : tigger.new){
// create records using number of payments
insert ?;
}
}
- Grrrrrrrrrrrrr
- December 15, 2012
- Like
- 0
- Continue reading or reply
54% coverage on test method ... almost there ... need a little help
Jeff Douglas wrote a wonderful chunk of code ( http://blog.jeffdouglas.com/2010/07/13/building-a-dynamic-search-page-in-visualforce/ )
And I am working on applying it to my org. I have it in my sandbox and it works awesome! But I am having trouble getting anything over 50% code coverage.
Can someone help me to figure out the last little bit? Thanks in advance!
Here is my test so far:
@isTest(SeeAllData=true) private with sharing class TestOpportunitySearchController { static testMethod void myTest() { Test.startTest(); date testdate = System.today().addDays(+1); Account testaccount = new Account(Name = 'test', Trident_Contract_Manager__c = 'test'); insert testaccount; Opportunity testrenewal = new Opportunity(accountId = testaccount.Id, Amount = 100.00, Closedate = testdate, Description = 'test', Name = 'test', Stagename = 'Baseline', Probability = 100, OwnerId = UserInfo.getUserId(), Coverage_Start_Date__c = System.today().addDays(-15), Coverage_End_Date__c = System.today().addDays(100)); insert testrenewal; ApexPages.StandardController sc1 = new ApexPages.StandardController(testrenewal); OpportunitySearchController controller1 = new OpportunitySearchController(sc1); controller1.runQuery(); controller1.runSearch(); controller1.toggleSort(); Test.stopTest(); } }
Here is my missing coverage (red indicates not covered): I cant figure out how to call the 'stages' and 'managers' methods.
line source 1 public with sharing class OpportunitySearchController { 2 public OpportunitySearchController(ApexPages.StandardController controller) { soql = 'select name, account.name, Trident_Contract_Manager2__c, stagename from opportunity where name != null'; runQuery(); } 3 private String soql {get;set;} 4 public List<Opportunity> renewals {get;set;} 5 public String sortDir { get { if (sortDir == null) { sortDir = 'asc'; } return sortDir; } set; } 6 public String sortField { get { if (sortField == null) {sortField = 'name'; } return sortField; } set; } 7 public String debugSoql { get { return soql + ' order by ' + sortField + ' ' + sortDir + ' limit 40'; } set; } 8 9 public void toggleSort() { sortDir = sortDir.equals('asc') ? 'desc' : 'asc'; runQuery(); } 10 public void runQuery() { 11 try { renewals = Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 40'); } catch (Exception e) { ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!')); } } 12 public PageReference runSearch() { 13 String name = Apexpages.currentPage().getParameters().get('name'); 14 String account = Apexpages.currentPage().getParameters().get('account'); 15 String manager = Apexpages.currentPage().getParameters().get('manager'); 16 String stage = Apexpages.currentPage().getParameters().get('stage'); 17 soql = 'select name, account.name, Trident_Contract_Manager2__c, stagename from opportunity where name != null'; 18 if (!name.equals('')) soql += ' and name LIKE \''+String.escapeSingleQuotes(Name)+'%\''; 19 if (!account.equals('')) soql += ' and account.name LIKE \''+String.escapeSingleQuotes(account)+'%\''; 20 if (!manager.equals('')) soql += ' and Trident_Contract_Manager2__c LIKE \''+manager+'\''; 21 if (!stage.equals('')) soql += ' and stagename LIKE \''+stage+'\''; 22 runQuery(); 23 return null; 24 } 25 26 27 public List<String> stages { 28 get { if (stages == null) { stages = new List<String>(); 29 Schema.DescribeFieldResult field = Opportunity.stagename.getDescribe(); 30 for (Schema.PicklistEntry f : field.getPicklistValues()) stages.add(f.getLabel()); } 31 return stages; 32 } 33 set; 34 } 35 public List<String> managers { 36 get { if (managers == null) { managers = new List<String>(); 37 Schema.DescribeFieldResult field = Account.Trident_Contract_Manager__c.getDescribe(); 38 for (Schema.PicklistEntry f : field.getPicklistValues()) managers .add(f.getLabel()); 39 } 40 return managers; 41 } 42 set; 43 } 44 }
Thank you!
- Grrrrrrrrrrrrr
- December 04, 2012
- Like
- 0
- Continue reading or reply
There is no error when I check syntax, but still not working
In my quest to find a way to report on rolling months in custom object, I decided to brainiack this approach.
I set a field to todays date. Then I add a month. So, this formula works somewhat (returns wrong month right now):
IF(MONTH(TODAY()) + 1 >= 12, "1", TEXT(MONTH(TODAY()) + 1)) & "/1/" & IF(MONTH(TODAY()) + 1 >= 12, TEXT(YEAR(TODAY()) +1), TEXT(YEAR(TODAY())))
But if I want to calculate the following months based on today (for example):
IF(MONTH(TODAY()) + 2 >= 12, "1", TEXT(MONTH(TODAY()) + 2)) & "/1/" & IF(MONTH(TODAY()) + 2 >= 12, TEXT(YEAR(TODAY()) +1), TEXT(YEAR(TODAY()))) IF(MONTH(TODAY()) + 3 >= 12, "1", TEXT(MONTH(TODAY()) + 3)) & "/1/" & IF(MONTH(TODAY()) + 3 >= 12, TEXT(YEAR(TODAY()) +1), TEXT(YEAR(TODAY()))) IF(MONTH(TODAY()) + 4 >= 12, "1", TEXT(MONTH(TODAY()) + 4)) & "/1/" & IF(MONTH(TODAY()) + 4 >= 12, TEXT(YEAR(TODAY()) +1), TEXT(YEAR(TODAY()))) IF(MONTH(TODAY()) + 5 >= 12, "1", TEXT(MONTH(TODAY()) + 5)) & "/1/" & IF(MONTH(TODAY()) + 5 >= 12, TEXT(YEAR(TODAY()) +1), TEXT(YEAR(TODAY()))) IF(MONTH(TODAY()) + 6 >= 12, "1", TEXT(MONTH(TODAY()) + 6)) & "/1/" & IF(MONTH(TODAY()) + 6 >= 12, TEXT(YEAR(TODAY()) +1), TEXT(YEAR(TODAY()))) IF(MONTH(TODAY()) + 7 >= 12, "1", TEXT(MONTH(TODAY()) + 7)) & "/1/" & IF(MONTH(TODAY()) + 7 >= 12, TEXT(YEAR(TODAY()) +1), TEXT(YEAR(TODAY())))
these all return the same date (1/1/2013).
AND if I try to use the first rolling date calculated like this:
IF(MONTH(DATEVALUE(Rolling_Months_1__c)) + 2 >= 12, "1", TEXT(MONTH(TODAY()) + 2)) & "/1/" & IF(MONTH(DATEVALUE(Rolling_Months_1__c)) + 2 >= 12, TEXT(YEAR(TODAY()) +1), TEXT(YEAR(TODAY())))
I do not get any syntax errors, BUT my field displays this --> #error <-- instead of a date.
I should point out that ALL my formula fields are set to return values as text.
Anyone have any ideas on this?
Thanks!
Temple
- Grrrrrrrrrrrrr
- November 29, 2012
- Like
- 0
- Continue reading or reply
Help with get; set; methods
Hi everyone. I am trying to understand how to use the get; set; methods. Here is my block of code:
public class LogoImage { public LogoImage(ApexPages.StandardController controller) { get{ return image; } set{ image = value; } } // get a company logo: based on user log in, strip spaces, return image name public String getImageName(){ String file = [SELECT Name FROM Account WHERE Id IN (SELECT AccountId FROM user WHERE username=:UserInfo.getUsername() ) LIMIT 1 ].Name; file = file.replace(' ', ''); String foldername = 'Logos/'; String extension = '.jpg'; String fullImageName = foldername + file + extension; return fullImageName; } }
I am trying to understand what the Apex Developer's Guide means and I obviously don't (so say my error messages :) ) ... Could someone please show me (in code, not links to more reading material) an example of how I would want to use the get set method?
I should also point out that without the get/set this works on my visualforce pages. My partner portal users get a logo image on their page of their company when they log in. But I want to understand gets and sets so I can write pages and classes that are ... well, not crappy.
Thanks!
- Grrrrrrrrrrrrr
- November 29, 2012
- Like
- 0
- Continue reading or reply
Page Block / Command Button style
I am going crazy.
Here is my VF snippet:
<!-- --------------------------------------- --> <!-- ---------------- UPLOAD --------------- --> <!-- --------------------------------------- --> <div> <apex:form enctype="multipart/form-data"> <apex:pageMessages /> <p>UPLOAD AN ATTACHMENT</p> <apex:pageBlock id="buttons"> <apex:pageBlockButtons > <apex:commandButton styleclass="button1" action="{!upload}" value="Upload Document"/> </apex:pageBlockButtons> </apex:pageBlock> <apex:outputLabel value="File Name" for="fileName"/><apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" id="file"/> <apex:inputText value="{!attachment.name}" id="fileName"/><apex:outputLabel value="File Name" for="file"/> </apex:form> </div> <!-- --------------------------------------- --> <!-- ------------ END UPLOAD --------------- --> <!-- --------------------------------------- -->
Here is my VF view:
It looks so painfully ugly. I know. I have tried everything I can think of in my styles.
Here are some that have yielded poor results:
.pbHeader {clear:both!important; text-align: left!important; background-color: #FFFFFF!important;} .pbTitle {width: 50%!important} .bPageBlock {background-color:#FFFFFF!important; clear:both!important; text-align:left!important; padding: 0px!important; margin: 0px!important; } .button1 {background-color:#FFFFFF; clear:both!important; text-align:left!important; padding: 0px!important; margin: 0px!important; }
What I am looking to do is to justify left my page buttons block of code. But I can't seem to get down to the heart of css code.
Any thoughts?
- Grrrrrrrrrrrrr
- November 19, 2012
- Like
- 0
- Continue reading or reply
Passing data to Visualforce page
I have a class that stores data from a custom object into a List. The class sorts the list and does all the things it needs to do, but now I want to pass the data back to my visualforce page.
But! I dont want to use pageblock or tabledata to render the values. Everytime I reference my class, it errors out on me. Here is some code:
First method in my class that is getting the data:
public class getOnboarding { public getOnboarding(ApexPages.StandardController Controller){ } public SFDC_Acct_Plan__c[] getPlanInfo(){ List<SFDC_Acct_Plan__c> fields = new List<SFDC_Acct_Plan__c>(); fields = [SELECT Planning_Year__c, Sales_Agreement_in_Place__c, Plan_Status__c, Last_Plan_Revision__c, Days_Between__c, Non_Disclosure_Agreement_in_Place__c, Number_of_assets_tracked__c, On_Boarding_Packet_to_Customer__c, Kickoff_Meeting_Completed__c, Kickoff_Meeting_Completed_on__c FROM SFDC_Acct_Plan__c WHERE Account__c IN (SELECT AccountId FROM AccountShare WHERE UserOrGroupId=:Userinfo.getUserId()) AND (Plan_Status__c = 'Draft') ]; return fields; }
and I want to pass it to my VF page:
<apex:page showHeader="false" sidebar="false" standardController="SFDC_Acct_Plan__c" extensions="getOnboarding"> <!-- --------------------------------------- --> <!-- ------------START OF STYLES------------ --> <!-- --------------------------------------- --> <style> #onboardingStages {text-align: center; width:95%} .pbheader {background-color:#000000!important; color:#FF4D4D!important;} .pbsubheader {background-color:#FFFF85!important; color:#5a5a5a!important;} </style> <!-- --------------------------------------- --> <!-- ------------ END OF STYLES ------------ --> <!-- --------------------------------------- --> <h1>Welcome Back {!$User.FirstName}</h1><br/> <h2>Date: {!MONTH(TODAY())}/{!DAY(TODAY())}/{!YEAR(TODAY())}</h2> <div id="onboardingStages"> <apex:variable var="stage" value="{!StageImage}"/> <apex:image url="{!URLFOR($Resource.Stages, stage)}" /> </div>
But I want to put the data into my own table.
If I reference my method {!PlanInfo.Plan_Status__c} it will not allow me to use the data (unless its in a pageBlock). I have also tried using variables for this.
I basically want to pass it to an HTML table cell that I define later.
Anyone come across this before? I know its something easy and silly ... but I cant get it.
Thank you,
TS
- Grrrrrrrrrrrrr
- November 16, 2012
- Like
- 0
- Continue reading or reply
New to Formulas . Why does this not work?
Tyring to create a Time-Dependent Workflow Formula but what i created does not work.
(Organization_Type__c = business/company || photography/art) AND (OwnerId = 00530000007jMIb) AND (Lead: Lead StatusEQUALSWorking - Contacted) AND (Lead: Last Modified ByEQUALSToday()+14)
Anyone know how to get this to work? when i check Syntax is says extra AND and when i remove the AND its says extea "(" To be honest im not sure whats right or wrong....=(
- gyip31
- November 15, 2012
- Like
- 0
- Continue reading or reply
Reference List
I have been working on creating some new visualforce pages and I thought I was doing ok. But now I stumbled across some of this code:
.pbSection
.pbSubHeader
etc, when it comes to using styles! I have searched the internet, but cannot find any reference material that will give me a list of all these available classes for use in CSS on my visualforce pages. I had no idea they even existed!! But try as I might, I cannot get mine to work quite right. Does anyone have a great reference page they can point out for me? I appreciate any and all tips.
Also, if anyone has some suggestions on how to best use !important that would be great too.
- Grrrrrrrrrrrrr
- November 15, 2012
- Like
- 0
- Continue reading or reply
Trigger for Child Records
Hello everyone.
I am pretty sure that what I need to do is write a trigger to accomplish my goal, but I have not written one before and need some help with the code. I will try to outline this as best I can, and any help is appreciated.
I have a parent Custom Object called Job__c
I have a child Custom Object called Bid__c
On Bid__c I have a field called Status__c that is a picklist with the values "Awarded" and "Lost"
One Job__c can have 1 to many Bid__c
When one Bid__c Status__c is changed to "Awarded" I need for all remaining Bid__c Status__c to change from "Pending" to "Lost"
I have absolutely no idea how to accomplish this. I have read through some of the posts about triggers in here, but I have never done anything with one before, and I am pretty lost.
Here is what I have so far, which is nothing, and I am already not sure if its right. (I can't wait to get beat up on a Test Class)
trigger updateBids on Bid__c(after update){
for(Bid__c c : trigger.old) {
}
}
Can someone please help me to fill in the missing blanks?
Thank you!
- Grrrrrrrrrrrrr
- November 09, 2012
- Like
- 0
- Continue reading or reply
Master-Detail in Edit Mode
Hello Everyone,
I have two custom objects tied by Master-Detail. But in my child object, in edit mode, I cannot see the Master-Detail field (not even as a read only). I do not want to edit the Master Detail field, I just want to be able to show the Parent field.
Example:
Parent Object
Name field
Date field
Currency FIeld, etc.
Child Object
Name (Master Detail from Parent) field
Date field
Location field, etc.
When I am editing my child object, I just want to see which Parent it belongs to. There are too many occassions where the wrong record is being updated since the user is losing track of what Parent / Child records they are really working in!! This is very frustrating.
I am not opposed to VF, Apex, or Trigger workarounds, although shame on Salesforce for making that necessary. I have tried using various formulas and field updates, but each time I am not able to access the Parent's Master-Detail field.
Any thoughts?
Thanks!
- Grrrrrrrrrrrrr
- November 07, 2012
- Like
- 0
- Continue reading or reply