• Paul.Fox
  • NEWBIE
  • 390 Points
  • Member since 2005

  • Chatter
    Feed
  • 12
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 96
    Replies

I need help figuring out why this isn't working on my VF page.  I have a section on my page set up like this:

<apex:commandButton style="width 50px;" value="Search" action="{!batchDetail}" status="status"/>
          </apex:pageBlockSection>
          </apex:pageBlock>
              <br/>
              <br/>
              <apex:outputPanel rendered="{!listResult == FOUND}">
              <apex:pageBlock >
              <apex:pageBlockSection title="Batch Information" id="resultsBlock" columns="1">
              <apex:pageBlockTable value="{!batchDetails}" var="item" rendered="{!NOT(ISNULL(batchDetails))}">
              <apex:column style="text-align:center;" value="{!item.Name}" headerValue="Batch #" width="95"/>
              <apex:column style="text-align:center;" value="{!item.Total_Contracts__c}" headerValue="Contract Holders" width="105"/>
              <apex:column style="text-align:center;" value="{!item.Product_Group__c}" headerValue="Policy Type" width="85"/>
              <apex:column style="text-align:center;" value="{!item.Form_Number__c}" headerValue="Form" width="95"/>
              <apex:column style="text-align:center;" value="{!item.Cancellable__c}" headerValue="Cancellable" width="95"/>
              <apex:column style="text-align:center;" value="{!item.Cancellation_Fee__c}" headerValue="Cancel Fee" width="95"/>
              <apex:column style="text-align:center;" value="{!item.Received_Date__c}" headerValue="Received Date" width="95"/>
             </apex:pageBlockTable>
            </apex:pageBlockSection>
           </apex:pageBlock>
          </apex:outputPanel>

 and it's governed by my controller here:

public PageReference batchDetail(){
          String qry = 'SELECT Name, Dealer__r.name, Received_Date__c, Product_Group__r.name, Total_Contracts__c FROM MG_Batch__c WHERE Name =:batchSearch AND Agent__c =:account LIMIT 1';
          batchDetails = Database.query(qry);
          if((batchDetails != null)){
          listResult = FOUND;
          return null;
              }
          else{
              listResult = NONE;
              ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'No Batches found which match that information, please try again.'));
              return null;
              }
              } 

 However, regardless of the outcome of the search an empty table is rendering with no error message or found records based on which statements are evaluating to be true and I would appreciate any help on pointing out where the error lies because I'm failing to see at the moment why this is not working when I have other similar sections which are.

Hey there,

 

I am not even sure this is possible, but I need some advice. Basically, I have a tabbed VF page for my account and all of its related lists and child objects have their own tab. These tabs are lists of all the records associated with that account and should the user click on one of the links, the bottom half of that tab will re-render with the information. Essentially, it is all the information on one page.

 

This all works perfectly, except what i need to do is to make it so that should the user wish to create a new record, upon saving they will be re-directed to the tab of the object they had jsut created the record in. I have searched and searched and searched for a solution, many people have theories on how to do this...maybe some people have even done this (by searching for a reference for each tab or naming each tab in the code), however it is a bit beyond my coding skill.

 

My question is...Would it be possible to have a link which will re-render the bottom half of the tab..into a create new record VF page...which upon saving will once again re-render to the record... What are your thoughts people?

 

Mikie 

How would I sort AllOpenTasks and AllCompletedTasks ascending by ActivityDate?

 

AccountExt Class:

public class AccountExt {

    public AccountExt(ApexPages.StandardController controller) {
    acc = (Account) controller.getRecord();
    }
    private final Account acc;
    Set<id> AccountIds = new set<ID>();
    
    public void AccountIds(){
    	AccountIds.add(acc.Id);
        for(integer i=0;i<5;i++){
            for(Account a: [select Id from Account where ParentId in :AccountIds limit 45000])
            AccountIds.add(a.Id);
        }
    }
    
    public list<Contact> getAllContacts(){ 
        if(AccountIds.size()==0) AccountIds();
        return [select Name, Title, Account.Name, Phone, Email from Contact where AccountId in :AccountIds];
        }
	public list<Task> getAllOpenTasks(){ 
        if(AccountIds.size()==0) AccountIds();
        list<Task> tasks = [select Id, Subject, Type, Call_Notes__c, Account.Name, WhoID, ActivityDate, OwnerId from Task where AccountId in :AccountIds and IsClosed = False];
        return tasks;
        }
    public list<Task> getAllCompletedTasks(){ 
        if(AccountIds.size()==0) AccountIds();
        list<Task> tasks = [select Subject, Type, Call_Notes__c, Account.Name, WhoId, ActivityDate, OwnerId, Id from Task where AccountId in :AccountIds and Isclosed = true];
        return tasks;
        }
}

 

AllOpenTasks Visualforce Page:

<apex:page standardController="Account" extensions="AccountExt" sidebar="false" showHeader="false">
    <script>
      function doRedirect()
      {
       window.parent.location.href = '{!URLFOR($Action.Task.NewTask)}';
     }
    </script>
    <apex:form >
    <apex:pageBlock title="Open Tasks">
        <apex:pageBlockButtons location="top">
            <apex:commandbutton onClick="doRedirect()" value="New Task"/>
        </apex:pageBlockButtons>
        <apex:pageBlockTable value="{!AllOpenTasks}" var="item">
            <apex:column headervalue="Subject">
                <apex:outputLink value="/{!item.Id}" target="_parent"><apex:outputField value="{!item.Subject}" /></apex:outputLink>
            </apex:column>
            <apex:column value="{!item.Type}" />
            <apex:column value="{!item.Call_Notes__c}" />
            <apex:column value="{!item.Account.Name}" />            
            <apex:column value="{!item.WhoId}" />
            <apex:column value="{!item.ActivityDate}" />
            <apex:column value="{!item.OwnerId}" />
        </apex:pageBlockTable>
    </apex:pageBlock>  
    </apex:form>
</apex:page>

 

AllCompletedTasks VisualForce Page:

<apex:page standardController="Account" extensions="AccountExt" sidebar="false" showHeader="false">
    <script>
      function doRedirect()
      {
       window.parent.location.href = '{!URLFOR($Action.Task.NewTask)}';
     }
    </script>
    <apex:form >
    <apex:pageBlock title="Open Tasks">
        <apex:pageBlockButtons location="top">
            <apex:commandbutton onClick="doRedirect()" value="New Task"/>
        </apex:pageBlockButtons>
        <apex:pageBlockTable value="{!AllOpenTasks}" var="item">
            <apex:column headervalue="Subject">
                <apex:outputLink value="/{!item.Id}" target="_parent"><apex:outputField value="{!item.Subject}" /></apex:outputLink>
            </apex:column>
            <apex:column value="{!item.Type}" />
            <apex:column value="{!item.Call_Notes__c}" />
            <apex:column value="{!item.Account.Name}" />            
            <apex:column value="{!item.WhoId}" />
            <apex:column value="{!item.ActivityDate}" />
            <apex:column value="{!item.OwnerId}" />
        </apex:pageBlockTable>
    </apex:pageBlock>  
    </apex:form>
</apex:page>

 

How can I generate a report of all contacts without open activities?  I've tried multiple of the standard reports and can't seem to make this happen.  Any ideas would be much appreciated!  

I would like to add a field to our Accounts that equals the account name up until there is a dash '-'.  We do not want anything after the dash to be in this new field.  How can I do that?  I've created a new custom field, but am not sure how to write the formula to accomplish this.  Thanks for the help!

I would like to import leads with two phone numbers, direct phone and other phone.  Direct phone will be the standard phone field and I created a custom field for other phone.  After that when I tried to map the custom other phone to contacts other phone I was not able to because Other Phone on the Contact is a standard field.  What is the best way to update the Other Phone number on the Contact when converting the lead?

Hi All,

 

I just setup Products and Quotes to work with opportunities and now I'd like to start using Contracts.  Can anyone point me at some good documentation and/or video tutorials?  It seems like there is less documentation about contracts than quotes and products.  Ultimately, when I close an opportunity I'd like that to generate a contract that we could send as an Invoice.  Thanks for the help.

I am trying to create a visualforce page that I will use to replace the standard contact related list on the Account page layout.  I want this new visualforce page to show all contacts associated with the current account, as well as from all the child accounts.  What is the best way to modify this code to display all the contacts?

 

<apex:page standardController="Account" sidebar="false" showHeader="false">
<apex:pageBlock title="All Related Account Contacts">
<apex:pageBlockTable value="{! account.contacts}" var="item">
<apex:column value="{! item.name}"/>
<apex:column value="{! item.account.name}"/>
<apex:column value="{! item.phone}"/>
<apex:column value="{! item.email}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

Is there any way to restrict the record type of new record options based on account role?  i.e., Sales Team would only have the ability to create new prospect record type accounts.

Is there documentation on how to extend Action Plans to other Objects?

 

Thanks,


Sonny

Hi All,

 

I have a requirement to show # of open Task on Lead Detailpage. Below is the logic that we are planning to implement. I would like tocheck with you if any one has implemented similar functionality handling BULK insert/update.If so could you please share the code?

 

Trigger on Task <after insert after update>

 

{

    for (Task thistask : Trigger.new)

      {

    // Get all leads assosited to Tasks

    if (WhoId.startsWith('00Q'))               

      leadIdToUpdateList.add(taskWhoId.WhoId);

     }

 

FOR each Lead

           SelectCount() from Task where whoId=LeadId and Status=Completed

           Updatecustom field “ Open Task” on  Lead object

End Loop   

 

}

 

Thank You . 

Hi,

I need to log users into Salesforce and immediately return the following URL as the first page:
https://ssl.salesforce.com/500/e?isdtp=mn

How can I construct a URL that passes both the username, password and immediately logs the agent into the above URL without any additional clicks?

I'm wondering if anyone else has had this experience or knows why it won't work.

 

I know Map.values() returns a list of objects in an arbitrary order. However, what I didn't know was that Visualforce can't understand this order.

 

I had a visualforce page that was showing a list of Accounts and some objects inside of them. For many reasons I was storing the Accounts in a Map grouped by their IDs and stored in a wrapper class.

 

Map<Id,AccountWrapper> AccountMap;

 

So in my getAccounts() Method I was just using this at the end:

return AccountMap.values();

 

But I was getting some very strange behavior when users made changes to the Account Wrapper and saved it.

 

Turns out sometimes it would save Account 1 data into the Account 2 wrapper object. 

 

I switched the end of the getAccounts method to the following:

 

AccountWrapper[] AccountList = AccountMap.values();
return AccountList;

 Now the AccountList always has the right values.

 

Does anyone know why maps cannot be sent directly to the page? Why can't Salesforce update map values?

 

I have a list of events that I want to insert. The invitations should just go to the Owner (who is a User). 

When I create an Event through the user interface I can click Save & Send Invitation. Is there a way to replicate that functionality in Apex?

I have a list called EventsToInvite.

 

This is what I've tried:

Database.DMLOptions options = new database.DMLoptions();
options.EmailHeader.TriggerUserEmail = true;
options.EmailHeader.TriggerOtherEmail = true;
Database.insert(EventsToInvite,options);

Temporarily I have it working through a workflow rule and email notification, but I'd like to just use the Salesforce functionality if possible so I don't have to style email templates.

How do I rerender a component on the page after someone inline edits a detail section?

 

According to the docs I thought I could just specify an id in the rerender attribute of apex:detail

 

So in this page:

<apex:page standardcontroller="Account" extensions="AccountDetailController" tabStyle="Account" id="AccountPage">
	<apex:detail id="detail" relatedListHover="false" inlineedit="true" rerender="relatedlists"/>
    <c:PageBlockTableEnhancer targetPbTableIds="contracts" paginate="true" defaultPageSize="10" pageSizeOptions="10,20,50"/>
        
    <!-- Outputpanel for rerender (for inline editing) -->
    <apex:outputpanel id="relatedlists">
    {!Account.Name}
    </apex:outputpanel>
</apex:page>

I thought the Account.Name would update if someone inline edited it in the detail section above. But it doesn't seem to work that way. Can't really tell what the rerender attribute does.

 

Anybody know another way to refresh the outputpanel after inline editing is finished?

I'm trying to setup a custom related list on the Account page that has sorting and pagination, but without losing too much of the standard functionality for the page.

 

So my questions are:

1. Is there a way to reorder the related lists so that the custom list is not at the bottom of all the others? I've tried moving it with javascript but when someone does inline editing then the related lists are rerendered without the custom list. I've also tried using <apex:relatedlist> tags for the other related lists, but then they do not hide/appear for the right page layouts/record types.

2. What's the easiest way to add sorting and pagination? The users would like to be able to click on a column and have it resort.

 

Visualforce Page

<apex:page standardcontroller="Account" extensions="AccountDetailController" tabStyle="Account" id="AccountPage">

<apex:detail id="detail" relatedListHover="false" inlineedit="true" />

<!-- Active Licenses --> <apex:pageblock title="Active Licenses" id="licenses" > <apex:facet name="header"> <table border="0" cellpadding="0" cellspacing="0" style="padding:0;border-bottom:none;"><tbody><tr> <td class="pbTitle"><img src="/img/icon/cd24.png" alt="License" class="relatedListIcon" style="width:24px; display:block; margin:-4px 4px -5px -8px;" title="License"/><h3 >Active Licenses</h3></td> <td class="pbButton"><input value="New License" title="New License" class="btn" onclick="window.location.href='{!URLFOR($Action.License__c.New, $ObjectType.License__c,['CF00Na000000A8Imu'=Account.Name,'CF00Na000000A8Imu_lkid'=Account.Id,'retURL'='/'+Account.Id])}';return false;" type="button" style="padding:2px 3px;"/></td> <td class="pbHelp">&nbsp;</td> </tr></tbody></table> </apex:facet> <apex:pageblocktable title="Active Licenses" id="activelicenses" value="{!Licenses}" var="license" rendered="{!Licenses.size!=0}" > <apex:column headerValue="Name"> <apex:outputlink value="/{!License.Id}" target="_parent" ><apex:outputfield value="{!license.Name}"/></apex:outputlink> </apex:column> <apex:repeat value="{!$ObjectType.License__c.FieldSets.Account_Related_List}" var="f"> <apex:column value="{!license[f]}" /> </apex:repeat> </apex:pageblocktable> <apex:outputText rendered="{!Licenses.size = 0}" value="No records to display" style="padding:5px;border:1px solid #E0E3E5;display:block;" /> </apex:pageblock>

</apex:page>

 

I have a custom object with a list of related objects and I'm using a controller extension to create the object and apply a list of related objects to it. Everything is working correctly for the normal save functionality.

 

However, when I try and create a Save and New button, it is not creating a new object, it is merely opening the same object again. How do I create a new object so it won't save over the existing one?

 

The page has the oppid as a parameter, and calls the saveAndNew action.

 

Here are the relevant sections from the class (I think):

public with sharing class InvoiceExt {
	public STT_Invoice__c i {get;set;}
	Id OppId = ApexPages.currentPage().getParameters().get('oppid');

// Constructor to extend the class
	public InvoiceExt(ApexPages.StandardController c){
		controller = c;
		i = (STT_Invoice__c) c.getRecord();
		
		i.Opportunity__c = OppId;
		
		Opportunity opp = [Select Account.Finance_Contact__c, AccountId From Opportunity where Id = :i.Opportunity__c limit 1];
		i.Recipient__c = opp.Account.Finance_Contact__c;
		i.Account__c = opp.AccountId;
		i.Estimated_Send_Date__c = date.today();
		i.Payment_Terms__c = '15 Days';
	}

public PageReference saveAndNew(){
		
		PageReference p = Page.NewInvoice;
		p.getParameters().put('oppid',OppId);
		controller.save();
		
		// Get the new Invoice Id
		InvoiceId = controller.getId();
		

		i = new STT_Invoice__c();
		p.getParameters().put('id',null);
		return p;
	}
	
	/* The standard controller object which will be used later for navigation and to invoke
       it's save action method to create the new Quote. */
    private ApexPages.StandardController controller;

 

 

I'm trying to parse a csv file and having trouble getting the pattern to match correctly.

 

This section of code has been formatted to work in the system log, so any helpful people can try it out and make their changes.

 

This pattern works in the web-based regex tester I've used, but it doesn't work in Salesforce. Not sure what I'm doing wrong.

 

pattern myPattern = pattern.compile('(".*?")'); 
matcher myMatcher = myPattern.matcher('Joe,0%,0%," $48,623 "," $48,623 ",0,29468,39782,48623,1');
System.assert(myMatcher.matches());
for(integer i=0;i<myMatcher.groupCount();i++){ System.Debug('Match '+i+': '+myMatcher.group(i));}

If the pattern works correctly, the output should look like this:

Match 0: Joe,0%,0%," $48,623 "," $48,623 ",0,29468,39782,48623,1
Match 1: " $48,623 "
Match 2: " $48,623 "

 

I installed Action Plans and got it set up for one of my custom objects. However, when I marked off a task, it was creating two dependant tasks. I looked at the debug log and it turns out that I had a field update on the task object which was causing the task trigger to run again, creating a second dependant task.

 

Luckily, I just had this problem with some other apex code, so here's what I did:

 

In the ActionPlansTaskTriggerUtilities class I added:

 

public static boolean firstTrigger = true;

In the ActionPlanTaskTrigger I wrapped everything inside of an if statement:

 

if(    ActionPlansTaskTriggerUtilities.firstTrigger == true){
        ActionPlansTaskTriggerUtilities.firstTrigger = false;
      // Existing code went here
}

 

This appears to be working correctly. Let me know if this will mess anything else up.

 

 

I have two objects, A and B, which are linked via a lookup field. B is the sub-object in this example.

 

Now even though they're linked with a lookup, I want one key field to be synced between the two objects. I want users to be able to edit from either record.

 

However, here's my problem:

When someone changes the value on A, the trigger on A fires, and updates B. This causes a chain reaction which causes the trigger on B to fire, and update A again. I'm not actually sure how many times it goes through the loop before failing.

 

This actually works for records where there are only a few B records, but my test cases fail because of too many DML rows. I thought this was a problem with just the number of records, so I created some Asynchronous Apex to handle the actual updating. However, now I get the error that a future method cannot call a future method (since one future method is causing the second trigger to fire which also uses a future method).

 

I have tried and failed with the following:

Trigger.isExecuting - this always returns true since they are triggers, so I can't use this

Custom checkbox which says Updated from Sync - This works for the initial update, but I can never set this field back to false, because when I do (via trigger or workflow rule) it fires the other trigger again, and I get the same errors.

 

Any ideas on how to sync one field between two objects?

I'm trying to MD5 encode a key for an external request. However, I must be doing something wrong because my key doesn't match the one that the service is expecting. I think it has something to do with having to make the string into a blob before using the generateDigest function.

 

Here's my code:

 

string keystring = 'StJoApuytj2ih48p3062010';
Blob keyblob = Blob.valueof(keystring);
Blob key = Crypto.generateDigest('MD5',keyblob);
System.Debug('Key: '+key.toString());

When I run this keystring through another website, I get this key: fdb338dff10d6619a3516b627ebbfc2c

 

When I run this keystring through Salesforce I get this: �8�� f�Qkb~��

 

Anybody know how to get them to match?

I've created a visualforce email template that has an attachment on it. It works really well when I click Send an Email, choose the contact, then choose the Template. However, I've created a custom link on the object that says Email. I want it to open up the email and automatically fill in the contact and the template. That way the user can change the body before sending it. When I click on the button it fills in the body from the template but there's no attachment! If I then select the template again, the attachment shows up.

 

There are merge fields from the RelatedTo and the Recipient in the body of the template which are working, so I don't know what is wrong.

 

Here's the link which passes the Contact, Quote ID, and Template ID to the Send Email page:

 

/_ui/core/email/author/EmailAuthor?p3_lkid={!Quote__c.Id}&retURL=%2F{!Quote__c.Id}&p2_lkid={!Quote__c.ContactId__c}&template_id=00XA0000000QX8G

 And here's the template that it's using:

 

<messaging:emailTemplate subject="{!relatedTo.Type__c} {!relatedTo.Name} for {!recipient.Account.Name}" recipientType="Contact" relatedToType="Quote__c"> <messaging:plainTextEmailBody > Dear {!recipient.FirstName} {!recipient.LastName}, I have attached the {!relatedTo.Type__c}, as we discussed. Please call me if you have any questions. Sincerely, {!$User.FirstName} {!$User.LastName} {!$User.Phone} </messaging:plainTextEmailBody> <messaging:attachment renderAs="PDF" filename="{!relatedTo.Type__c} {!relatedTo.Name} for {!recipient.Account.Name}"> <c:quote quoteId="{!relatedTo.Id}"/> </messaging:attachment> </messaging:emailTemplate>

 

 

 

 

 

I have a custom object Time_Card__c. I'm trying to create a trigger that will fill in the pay rate based on some criteria.

 

I commented out everything in the trigger except for this and it still won't save:

 

 

trigger Trigger_TimeCard_FindPay on Time_Card__c (before insert, before update) { for(Time_Card__c tc : Trigger.new){ tc.Pay__c = 5; } }

 

 The Error Log says "Did not find ApexClass component for 'timecardcontroller'".

 

I have an Apex Class called timecardcontroller which is used for a Visualforce page which lets people update the Time Cards, but I have no idea what this has to do with this trigger.

 

If I comment out the line that says tc.Pay__c = 5; then it saves correctly.

 

Any ideas on how to fix this?

 

I'm trying to create a data table that has values from two different, unrelated objects. I couldn't find out a way to map the two objects together, so I created a custom class inside of my custom controller called ConvertItem. This is what the class looks like.

 

public class ConvertItem {
Boolean Convert;
String ProductName;
Double Quantity;
}

 

I have another method in the controller called getLineItems() that returns a List<ConvertItem>

 

public List<ConvertItem> getLineItems(){
// Grab the lineitems
List<OpportunityLineItem> LineItems = [Select Id, PricebookEntry.Name, Quantity, Description From OpportunityLineItem
where OpportunityId = :ApexPages.currentPage().getParameters().get('Id')];

// Create a list of ConvertItems to store the line item and asset info
List<ConvertItem> Items = new List<ConvertItem>();

// Put the line items in a generic sobject with asset information
for(OpportunityLineItem lineItem : LineItems){
ConvertItem newItem = new ConvertItem();
newItem.Convert=True;
newItem.ProductName=lineItem.PricebookEntry.Name;
newItem.Quantity=lineItem.Quantity;
newItem.AssetName=lineItem.PricebookEntry.Name;
Items.add(newItem);
}

System.Debug(Items);
return Items;
}

 

I have verified that it is returning a list in the debug logs, and that the list includes a ProductName for each item.

 

However, when I try to save the visualforce page that shows this list in a data table I get an error that ConvertItem.ProductName is an unknown property.

 

Here's the section of the visualforce page:

 

<apex:pageBlockTable value="{!LineItems}" var="item">
<apex:column value="{!item.ProductName}" />
</apex:pageBlockTable>

 Anyone know why the visualforce page can't recognize that the ProductName is there?

 

 

Message Edited by Paul.Fox on 10-08-2009 03:03 PM

I have built a few web forms using CMSForce. I was able to customize the code in several places despite feeling like I was playing with one of those russian dolls (there's a component inside of a component inside of a component inside of a page inside of a page). In the end it was still easier to maintain than a custom visualforce page. The drag and drop form creation was great.

 

Anyway, my problem is that when a person submits a form on the website with some invalid field, like asdf in an email field, they get only that error message, even if they've forgotten a required field. So they fix the email address and submit it again, only to get another message that says 'xyz is a required field'.

 

It would be nicer if the user got a list of errors 'Invalid Email, xyz is a required field'.

 

Any ideas?

 

For anyone that's looking into this, it appears that the form fields are handled by the Form Field object when they're saved. That means internal salesforce code probably validates the data types. Then the RenderFormComponentController handles the required field validation, so I don't see how we could do them both at the same time, but it'd be really nice.

I have an application that stores data related to a lead or contact. I need the data to stay with the Lead when it is converted. To do this I have created a field on the Contact called Converted Lead ID, which I want to populate with the ID of the lead that the contact was converted from.

 

Since I can't map standard lead fields to custom contact fields, I created a formula field called Lead ID, and set it equal to the Lead ID.

 

Now I mapped the formula field to the Converted Lead ID field and tested it, and it all worked great. 

 

Then I found out a problem. I added these two fields to our managed package, and installed it in another org. Since package installation does not support field mapping, I went in to the Settings page to map the Lead ID to the Converted Contact ID. However, it gave me an error when I tried to do it saying that the Lead ID formula field length of 3900 was too long to map to my 18 character Converted Lead ID field.

 

Salesforce support says that can't help me because it's "Custom Code". Any suggestions?

I have created a simple page in Apex that shows my tasks for the day and gives me a place to add a new task.
However, I can't seem to get the commandLink or the form to create a new task if I use the rerender parameter.
This means that when I add a new Task the whole page refreshes, which takes a lot longer than just refreshing the task list.

Here's the snippet from the Apex Page:
Code:
  <apex:form id="AddTask">
      <apex:inputText size="40" id="NewTask"/>
      <apex:commandLink value="Add Task" action="{!AddTask}" rerender="openTasks"/>
  </apex:form>
Somewhere below this I have a <ul id="openTasks">. If I take off that rerender

 Here's the AddTask method in the Controller:
Code:
    public PageReference AddTask() {
        Task newTask = new Task(Subject='xxx',Priority='Normal',Status='Not Started');
        string NewTaskSubject = 'Hello'; //Need to change this to get value from field.
        newTask.subject = NewTaskSubject;
        insert(newTask);
        return null;
    }

I also need to figure out how to grab the new task subject if anyone wants to help me with that. I can't use the standard edit method because I don't want the standard subject field with the little pop-up box.

Does anyone know how to remove a line break from a field?
I am trying to use MailingAddress in a hyperlink formula but it breaks every time there is a contact with a two line mailing address.

I have tried the following and they did not work:
substitute(MailingAddress,BR(),"")
substitute(MailingAddress,"\n","")
substitute(MailingAddress,\n,"")
trim(MailingAddress)

For reference my formula looks something like this:
hyperlink("http://linklocation.com?address="&MailingAddress,"Link Text", "_blank")
I am creating a visualforce page for leads.

I have the following in my controller:

Code:
Lead lead;

public Lead getLead(){
    if(lead == null) lead = [select id, name, Persona__c from Lead where id= :ApexPages.currentPage().getParameters().get('id')];
    return lead;
}

public List<Question__c> getQuestions(){
    return [select id, Question_Value__c from Question__c where Persona__c = :lead.Persona__c];
}

 Now on the Page it shows the Question ids if I just put {!Questions}.

But as soon as I try to put the questions into a pageblock I get the error: System.NullPointerException: Attempt to de-reference a null object. The error points to the return statement in the last method above.

Here is the section of the page:

Code:
<apex:pageBlockTable value="{!Questions}" var="q">
             <apex:column value="{!q.Question_Value__c}"/>
         </apex:pageBlockTable>

 
Any idea how to put the data into a table appropriately?



I'm wondering if anyone else has had this experience or knows why it won't work.

 

I know Map.values() returns a list of objects in an arbitrary order. However, what I didn't know was that Visualforce can't understand this order.

 

I had a visualforce page that was showing a list of Accounts and some objects inside of them. For many reasons I was storing the Accounts in a Map grouped by their IDs and stored in a wrapper class.

 

Map<Id,AccountWrapper> AccountMap;

 

So in my getAccounts() Method I was just using this at the end:

return AccountMap.values();

 

But I was getting some very strange behavior when users made changes to the Account Wrapper and saved it.

 

Turns out sometimes it would save Account 1 data into the Account 2 wrapper object. 

 

I switched the end of the getAccounts method to the following:

 

AccountWrapper[] AccountList = AccountMap.values();
return AccountList;

 Now the AccountList always has the right values.

 

Does anyone know why maps cannot be sent directly to the page? Why can't Salesforce update map values?

 

I have an application that stores data related to a lead or contact. I need the data to stay with the Lead when it is converted. To do this I have created a field on the Contact called Converted Lead ID, which I want to populate with the ID of the lead that the contact was converted from.

 

Since I can't map standard lead fields to custom contact fields, I created a formula field called Lead ID, and set it equal to the Lead ID.

 

Now I mapped the formula field to the Converted Lead ID field and tested it, and it all worked great. 

 

Then I found out a problem. I added these two fields to our managed package, and installed it in another org. Since package installation does not support field mapping, I went in to the Settings page to map the Lead ID to the Converted Contact ID. However, it gave me an error when I tried to do it saying that the Lead ID formula field length of 3900 was too long to map to my 18 character Converted Lead ID field.

 

Salesforce support says that can't help me because it's "Custom Code". Any suggestions?

Hi,

 

Our opportunity partners have commissions associated with opportunities. We have created a new object called Commissions which is tied to opportunities and accounts. To create commissions the sales person clicks “add new commission” from the opportunity page and fills out a simple form below.

 

Opportunity Name (Auto populates)                      

Partner Lookup (A lookup to choose partner "account" that will get commission)

Commissions (Yes/No)

Amount (Currency)                         

Product (Multi Select)

 

We’d like to have a visual force page that pulls in all associated opportunity partners with a separate commission section for each. Currently we’re asking sales to reselect the partner when adding commission which isn’t very elegant. Can you please offer any ideas or examples of how we might improve our process?

 

I would greatly appreciate any ideas or help.

 

Thank you!

Greg

All-

I have a LARGE VF page on Quote with multiple sections.  One of the sections (near the bottom 2/3rds of the page) renders approvals in an object.  Each approval record has a series of buttons (approve, reject, etc.).  When users click on one of these buttons, they are directed to another form to fill out the necessary information and, when complete, they return to the quote thorugh a PageReference in an Apex class.  The issue is, when returning to the quote, it automatically returns to the TOP of the quote page.  Is there a way to make them return to the approvals section of the Quote VF page when they are being directed to the QUOTE page from the Apex Class?  Any help on how to do it?

  • October 15, 2013
  • Like
  • 0

I need help figuring out why this isn't working on my VF page.  I have a section on my page set up like this:

<apex:commandButton style="width 50px;" value="Search" action="{!batchDetail}" status="status"/>
          </apex:pageBlockSection>
          </apex:pageBlock>
              <br/>
              <br/>
              <apex:outputPanel rendered="{!listResult == FOUND}">
              <apex:pageBlock >
              <apex:pageBlockSection title="Batch Information" id="resultsBlock" columns="1">
              <apex:pageBlockTable value="{!batchDetails}" var="item" rendered="{!NOT(ISNULL(batchDetails))}">
              <apex:column style="text-align:center;" value="{!item.Name}" headerValue="Batch #" width="95"/>
              <apex:column style="text-align:center;" value="{!item.Total_Contracts__c}" headerValue="Contract Holders" width="105"/>
              <apex:column style="text-align:center;" value="{!item.Product_Group__c}" headerValue="Policy Type" width="85"/>
              <apex:column style="text-align:center;" value="{!item.Form_Number__c}" headerValue="Form" width="95"/>
              <apex:column style="text-align:center;" value="{!item.Cancellable__c}" headerValue="Cancellable" width="95"/>
              <apex:column style="text-align:center;" value="{!item.Cancellation_Fee__c}" headerValue="Cancel Fee" width="95"/>
              <apex:column style="text-align:center;" value="{!item.Received_Date__c}" headerValue="Received Date" width="95"/>
             </apex:pageBlockTable>
            </apex:pageBlockSection>
           </apex:pageBlock>
          </apex:outputPanel>

 and it's governed by my controller here:

public PageReference batchDetail(){
          String qry = 'SELECT Name, Dealer__r.name, Received_Date__c, Product_Group__r.name, Total_Contracts__c FROM MG_Batch__c WHERE Name =:batchSearch AND Agent__c =:account LIMIT 1';
          batchDetails = Database.query(qry);
          if((batchDetails != null)){
          listResult = FOUND;
          return null;
              }
          else{
              listResult = NONE;
              ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'No Batches found which match that information, please try again.'));
              return null;
              }
              } 

 However, regardless of the outcome of the search an empty table is rendering with no error message or found records based on which statements are evaluating to be true and I would appreciate any help on pointing out where the error lies because I'm failing to see at the moment why this is not working when I have other similar sections which are.

 

i have custom object A.B AND C Object have Lookup relationship with A OBJECT.In A object Have custom field name: delevery template (its a rich text).it is work as a EMAILTEMPLATE....
My task is whenever create a new record under A Object -when select 'B'&'c' custom  field...custom field name: delevery template (its a rich text) section automatically send email to 'B' object emailfield.
here i am use delevery template (its a rich text) section like a plaintext for email..how to automatically send email whenever create a new record under A Object -when select 'B'&'c' custom  field Using apex trigger..
please give your knowledge.

  • October 15, 2013
  • Like
  • 0

Hey there,

 

I am not even sure this is possible, but I need some advice. Basically, I have a tabbed VF page for my account and all of its related lists and child objects have their own tab. These tabs are lists of all the records associated with that account and should the user click on one of the links, the bottom half of that tab will re-render with the information. Essentially, it is all the information on one page.

 

This all works perfectly, except what i need to do is to make it so that should the user wish to create a new record, upon saving they will be re-directed to the tab of the object they had jsut created the record in. I have searched and searched and searched for a solution, many people have theories on how to do this...maybe some people have even done this (by searching for a reference for each tab or naming each tab in the code), however it is a bit beyond my coding skill.

 

My question is...Would it be possible to have a link which will re-render the bottom half of the tab..into a create new record VF page...which upon saving will once again re-render to the record... What are your thoughts people?

 

Mikie 

How do I rerender a component on the page after someone inline edits a detail section?

 

According to the docs I thought I could just specify an id in the rerender attribute of apex:detail

 

So in this page:

<apex:page standardcontroller="Account" extensions="AccountDetailController" tabStyle="Account" id="AccountPage">
	<apex:detail id="detail" relatedListHover="false" inlineedit="true" rerender="relatedlists"/>
    <c:PageBlockTableEnhancer targetPbTableIds="contracts" paginate="true" defaultPageSize="10" pageSizeOptions="10,20,50"/>
        
    <!-- Outputpanel for rerender (for inline editing) -->
    <apex:outputpanel id="relatedlists">
    {!Account.Name}
    </apex:outputpanel>
</apex:page>

I thought the Account.Name would update if someone inline edited it in the detail section above. But it doesn't seem to work that way. Can't really tell what the rerender attribute does.

 

Anybody know another way to refresh the outputpanel after inline editing is finished?