• dwwright
  • NEWBIE
  • 100 Points
  • Member since 2010

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

I have a requirement to show a section only on button click. here is the code I have tried, but no luck. can someone tell me what is the error in the below code

 

VF code :

 

<apex:page controller="testRenderCtrl">
<apex:form>
    <apex:commandButton value="Submit" action="{!submit}" reRender="panelId"/>
    <apex:outputPanel  rendered = "{!flag}"  id = "panelId">
    <apex:pageblock >
        <apex:pageblockSection title = "Contact Information">
            <apex:inputField value="{!con.firstname}"/>
            <apex:inputField value="{!con.lastname}"/>                                              
        </apex:pageblockSection>
    </apex:pageblock>
    </apex:outputPanel>
    </apex:form>
</apex:page>

 

 

Controller code

 

public class testRenderCtrl {
    public Contact con {get;set;}    
    public boolean flag = false;    
    public boolean getFlag(){
        return flag;
    }
    public void setFlag(boolean flg){
        flag = flg;
    }    
    public void submit(){
     System.debug('****');
     flag = true;   
    }
}

 

Thanks,

YP

 

Hi,

I have a query retrieving the userinfo from user in a trigger.

 

Here i am retrieving a custom field from  user object.

Below is the query: 

 

String userid= userinfo.getUserId();


User[] userType = [select u.custom__c from User u where u.Id=:userid limit 1];

 

the exception is:

Apex script unhandled trigger exception by user/organization: 00540000001RUm8/00D300000001EBY caused by: System.Exception: Too many SOQL queries: 21

 

can anyone whats wrong eith the query to avoid gov limits.

Hi community,

 

Wondering if anyone can shed me some lights. I'm this close to bang my head against the wall.

 

On our Force.com Sites, we have a "Case Study" page which lists some PDF/Excel/Words files. These files are stored in Documents in Salesforce. We want people visit our site to download them.

 

I wrote a simple VF page to output a download link, and a controller to query the Document object. But when I click on the Download link, I get the "Authorization Required" error message. I guess this is to do with Security setting between the Documents Object and the Guest User License. I did grant the Read permission on this object but no luck.

 

Is there any way to make this work? I don't really want to use Static Resource to hold these PDF files.

 

Here is my code:

 

DocumentDownload.page

 

<apex:page controller="DocumentCon" action="{!getFile}">
<apex:outputLink value="/servlet/servlet.FileDownload?file={!doc.Id}&oid={!$Organization.Id}">
Download Now!
</apex:outputLink>
</apex:page>

 

 

DocumentCon.cls

 

public class DocumentCon {	
public Document doc {get;set;}

public PageReference getFile() {
String fileId = System.currentPageReference().getParameters().get('id');

if(fileId != null) {
doc = [SELECT Id, Name, Description, ContentType, Type, Url, BodyLength, Body
FROM Document WHERE Id = :fileId];
}
return null;
}
}

 

 

 

I'm trying to build an inventory catalog from some data stored in a custom object in Salesforce. One of the fields on the custom object stores the Id of a document that is an externally available image.

 

I'm trying to build this catalog in a Sites page and make this image appear. I'm currently doing this:

 

 

<apex:image url="/servlet/servlet.FileDownload?file={!Inventory__c.Image_URL__c}" />

 This works fine when I'm logged into Salesforce and viewing the Visualforce page directly.

 

Once I navigate to the sites page and try to view it, nothing comes up. I'm confirmed that the image is externally available, and I've set the Sites profile to "Read" for Document objects.

 

Does anyone know how you actually take advantage of externally available images and make them VISIBLE externally?

 

Hello Everyone,

 

I have created a relationship in between Case and my Custom Object ( CR_Reply). So CR_Reply have relational field rCase__r.

 

Now what I'm trying to do :

 

I have created a Visualforce page, on which I have added Custom Object ( CR_Reply ) fields. On this page I have passed CaseID as querystring Parameter.

 

I just want to display read-only details of Case i.e. Case # and Subject on top of this Custom Object page.

 

Please let me know if anybody have done similar work before.

 

Thanks

Sakshi

I am new to visualforce development and I have a question regarding lookup fields.

 

I have a visualforce page in which I am displaying data using jqgrid. The controller returns json data, which is consumed by the jqgrid. This works fine.

When I select and edit a row,  jqgrid generates a form dyanmically with HTML input field based on the column definition given  and prepopulates the data for that row  under each field.

Now my problem is , one of the field in the form is a look up field  and I want to show the lookupfield icon next to the field. in otherwords, I want to mimic the behaviour of lookup field on a html input field.

 

Does any one have suggestions on how this can be done?

 

Help much appreciated.

jackson

Hey everyone,

 

This trigger query is killing me.

 

I am writing a trigger to sum up custom field Scores in Contact.

 

I want to display the sum in Account.

 

I want to query the database for all the Scores for each Contact in an Account.

 

I guess my fundamental understanding of apex code sucks, nothing i'm doing seems to even compile.

Here's my code:

 

 

trigger sumContactScore on Account (after insert, after update) {
	
	Set<Id> accIDs = new Set<Id>();
	for(Account a: Trigger.new){
		accIDs.add(a.Id);
	}
	
	for(Account a : Trigger.new){
		
		Double sum = 0;

		List<Contact> scoreList = new List<Contact>();

		scoreList = [SELECT LS_Implicit_Contact_Score__c FROM Contact WHERE Email != null and Contact.AccountId in :accIDs];
		
		for(Contact i : scoreList){
			sum += i.LS_Implicit_Contact_Score__c;
		}
		
		a.Sum_of_Implicit_Behavior_Scores__c = sum;	
	}

}

 

 

 

Help.

I am utilizing Sites and my Visualforce pages use a custom object as the standard controller with an extension for additional functionality. 

 

How do I reference fields directly on a Visualforce page? For example, I have two fields that only have id's and no input value.

 

Example:

<apex:pageBlockSectionItem >
  <apex:outputLabel value="US001_VEReq" for="test_us001vereq" />
  <apex:inputTextarea id="test_us001vereq"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
  <apex:outputLabel value="US001_VERes" for="test_us001veres" />
  <apex:inputTextarea id="test_us001veres" />
</apex:pageBlockSectionItem>

 

I want to combine the input from these two Text Area Fields into one field which does have a value, meaning upon save the concatenated (combined) value will be entered (saved) into the database. 

 

Example:

<apex:pageBlockSectionItem >
  <apex:outputLabel value="US001" for="test_us001" />
  <apex:inputTextArea value="{!SK__c.US001__c}" id="test_us001" />
</apex:pageBlockSectionItem>

 

What options do I have to accomplish this task. I have spent 4 days looking at the forums, code examples, etc. and can not figure out how to make this work. Any suggestions, ideas, code examples, and/or links are much appreciated. Please let me know if this is unclear and I will provide more detail.

 

Also, for anyone familiar with MS Access Databases, this would be similar to bound/unbound fields and how to reference those fields within a form via VBA etc.

Hi,

 

I have visualforce page showing report data in a page block table. I want to show this page as dashboard component. Is there any way to achieve this easily? I have heard that dashboard component wont get created if you use a Standard Controller, but if you use Controller class or call/refer a page having StandardSetController Class from the concerned vf page, you may have the component available.

 

Could you please advise on this.

 

 

Thanks,

 

Vimal

hi ,

 

i have a  requirement with my client for creating 

 

1. I need to create Some Dashboard Reports in VF Sites

2. Will Dashboard menu appear in VF Sites

 

So i taught of working on building dashboards on Visualforce pages and then i didnt find any example for that,Is it possible to do that

 

can anybody help me in this issue,

We have an intermediary new lead page that takes basic fields (name, phone, email, company) and searchs showing possible duplicates. When one is not found then the user can choose to create his new lead. The lead is created with all the data the rep has already filled out, inserted and then shown to the user via a a pagereference. 

 

Is there a way to not "insert" the lead before showing it? I would like for agent's to have a chance to change some other field data before the initial insert trigger is fired. I just want to open the lead to its edit page 

I'm trying to give "apex managed sharing" a test run. I've created a custom object (in my sandbox) and I'm trying to run through how to handle creating share objects.

 

Right now, I'm getting a compile error that appears to be a syntactical error, but I can't figure it out.

 

In the documentation Here, the description of how to handle doing this is pretty clear: MyCustomObject__Share. In the example, referencing their Job__c object is done as "Job__Share".

 

My object is called RFQ. The api name is RFQ__c, so I would expect the share name to be RFQ__Share. I'm getting the error: "Invalid Type: RFQ__Share" when trying to compile my code. Here's a snippet:

 

 

/*
* Trigger to test Apex Managed Sharing
*/
trigger AssignSharing on RFQ__c (after insert) {
List<RFQ__Share> shares = new List<RFQ__Share>(); List<String> srNums = new List<String>(); Map<String, Id> userIds = new Map<String, Id>(); RFQ__Share shr = new RFQ__Share(); for(RFQ__c rfq : trigger.new) { //for each comma separated SR Num in the SR Num field, add it to //the list of relevant SR nums for(String num : rfq.Sales_Responsible_Numbers__c.split(',',0)) { srNums.add(num); } } //SR Nums now holds all the Sales Responsible numbers that apply to the //rfq's being inserted, so we can query them from the database; //next step is to iterate through all the users who will be assigned a
//sharing rule (query result)
//create a map of SR#s to Ids for quick reference later for(User u : [SELECT Id, Sales_Responsible_Number__c from User where Sales_Responsible_Number__c in :srNums]) { userIds.put(u.Sales_Responsible_Number__c, u.Id); } //userIds now maps each SR# to a user Id //for each new RFQ, assign the users that need to be given share priviledges
 for(RFQ__c rfq : trigger.new) { //for each sales responsible number for(String s :srNums) { //if this RFQ has that sales responsible number if(rfq.Sales_Responsible_Numbers__c.contains(s)) { //create a sharing rule that allows the corresponding user to be added shr.ParentId = rfq.Id; shr.AccessLevel = 'edit'; shr.UserOrGroupId = userIds.get(s); shr.RowCause = Schema.rfq__Share.RowCause.SalesResponsible__c; shr.add(shares); } }//end for loops over srNums for this rfq }//end for (trigger.new) insert shares; }//end trigger

 

(Don't make fun of my code... it's for testing, not even compiled once yet, and not made to be efficient, I just want to get it to compile)

 

 

Any insight?

Hi All-

      I'm sure this is simple but I can't find a simple answer.  I have a couple of different page layouts for leads that multiple users need to see.  Since a page layout is assigned per user, the only way around this was to create a visualforce page for the second page layout, time consuming but not a problem.   So now I need a way for the user to choose which page layout they see when creating a new lead.  I want to have them choose the LEADS tab, then from the LEADS HOME page launch new "custom" lead as well as the "standard" page layout that is assigned to them.

 

Is there a way to customize and add buttons to the TAB HOME page for a standard object like LEADS or do I have to create a VForce page to mimick this?  Thanks in advance for your help!!

I'm pretty new to this and I see other people have struggled with custom date pickers...

 

I have a custom VF task page.  I am trying to mimic the reminder section of the standard task screen.

 

I am usting an outputPanel so I can have a checkbox, input field (for date) and select field (for time).

 

The fields display fine and the datepicker lets me pick a date, but when I save, I am not able to get the selected date value back into my controller class.  The !ReminderDate comes back empty.

The !ReminderTime comes back fine.  

Neither field is bound to an SObject.

 

Is there another way?

 

Thanks,  Kevin.

 

 

             <apex:pageBlockSection title="Reminder" collapsible="false" rendered="true">                
                <apex:pageBlockSectionItem >
                    <apex:outputLabel id="taskAddReminderLabel" for="taskAddReminder" value="Add Reminder" />                    
                    <apex:outputPanel id="taskAddReminderOutputPanel" >
                    <apex:inputCheckbox id="taskAddReminder" value="{!AddReminder}">
                        <!-- <apex:actionSupport event="onchange" rerender="taskInformation" action="{!Refresh}"/> -->
                    </apex:inputCheckbox>                                        
                    <span id="dateSpan" class="dateInput dateOnlyInput"><input id="taskReminderDate2" name="taskReminderDate2" value="{!ReminderDate}" onfocus="DatePicker.pickDate(true, 'taskReminderDate2', false);" size="12" type="text" /><span class="dateFormat"></span></span>                    
                    <apex:selectList id="taskAddReminderSelectList" value="{!ReminderTime}" multiselect="false" size="1">
                        <apex:selectOptions value="{!TaskReminderList}"/>
                    </apex:selectList>                 
                    </apex:outputPanel>                                    
                </apex:pageBlockSectionItem>            
            </apex:pageBlockSection>   

 

 

I'm trying to create a page that allows my users to fill in fields, attach as many files as they want, and then submit the information, creating a new lead with all the attachments.

 

What I want to do is let the user attach files BEFORE submitting, meaning BEFORE the Lead is actually inserted into the database. To try to accomplish this, I'm creating a list of attachments in the controller and then holding the attachments there. When the user clicks "submit" I then insert the Lead and assign all of the attachments in the list to that Lead.

 

The goal here is to be able to submit the Lead and its Attachments at the same time.

 

I'm hitting the viewstate size limit (I'm growing to dislike that error very much.) Is there a way to efficiently gather attachments before inserting them into the DB? Below are my relevant code snippets:

 

 

public class newLeadExtension {

public Lead theLead;
public String theName {get; set;}
public Attachment att {get; private set;} //Holds value from inputFile
public List<Attachment> attachments {get; set;} //Holds attachments
public List<String> attachmentNames {get; set;} //Holds atachment names

//Get the lead from the standardcontroller
public newLeadExtension(ApexPages.StandardController cont) {
theLead = (Lead)cont.getRecord();
att = new Attachment();
attachmentNames = new List<String>();
attachments = new List<Attachment>();
}

public PageReference attach() {
attachments.add(att);
attachmentNames.add(att.Name);
return null;
}
}

 

Attach A File:<br/>
<apex:inputFile value="{!att.Body}" filename="{!att.Name}" />
<apex:commandButton value="Attach" action="{!attach}"/>

Attached Files:<br/>
<apex:repeat var="att" value="{!attachmentNames}" >
&nbsp;&nbsp;{!att}<br/>
</apex:repeat>

 

 

(The "submit" method isn't shown here, but it just inserts the lead, then iterates through the attachment list assigning each parent ID as the lead and inserting it)

 

Thanks for any help you can provide!

I want to send an email thanking the Primary Contact on an Opportunity when we mark the corresponding Opportunity Closed Won. But I don't see that object (Opportunity Contact Role) as an option when setting up the email alert.

Any suggestions?

Jane