• Matt_
  • NEWBIE
  • -1 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 7
    Replies

I know you can create a custom button and create a task on click using Javascript. can you apply the same thing to visualforce pages? The button code looks like this:

{!REQUIRESCRIPT("/soap/ajax/17.0/connection.js" )}
var t1= new sforce.SObject("Task" );
      t1.OwnerId = "##############3";
      t1.Subject = "This is my subject";
      t1.Status = "Not Started";
      t1.Priority = "Normal";
      t1.whatId = "#############";
      result = sforce.connection.create([t1]);

So would the VF page code look like this?

<apex:page >
<script language="Javasript">

var t1= new sforce.SObject("Task" );
      t1.OwnerId = "##############3";
      t1.Subject = "This is my subject";
      t1.Status = "Not Started";
      t1.Priority = "Normal";
      t1.whatId = "#############";
      result = sforce.connection.create([t1]);
</script>
</apex:page>

This doesn't work though. Any thoughts?

  • July 29, 2013
  • Like
  • 0

I've looked but have failed to find a remedy thus far. Any input is welcome. 

 

I have a page that creates multiple records at once, with buttons that can add or remove rows(new records) to a pageblocktable. This works. All the records save perfectly. 

 

In addition to these rows there are other inputfields that contain information that should be applied to every single new record. The data from these inputfields does not save. All the fields are found under the same object "End_of_Month_Report__c". Below is the VF page. HTML has been added to format the layout.  

 

<apex:page standardController="End_of_Month_Report__c" extensions="ReportEntry" Title="New End of the Month Report">
<h1><b><font size="5" face="Times New Roman">New End of the Month Report</font></b></h1>

    <apex:form title="New End of the Month Report">
     
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}" rerender="table" />
                <apex:commandButton value="Cancel" action="{!cancel}" rerender="table" />
            </apex:pageBlockButtons>
            <apex:pageblocksection title="Data for All Cities in the Region" id="PBS" collapsible="false">
           
            <apex:pageBlockTable value="{!Report}" var="a" id="table">
                <apex:column headerValue="Station [Domicile First] :">
                    <apex:inputField value="{!a.Station_1__c}"/>
                </apex:column> 
                               
                <apex:column headerValue="Fully Staffed?">
                    <apex:inputField value="{!a.Staffing_Station_1__c}"/>
                </apex:column>
                
                <apex:column headerValue="Staffing Comments :">
                    <apex:inputField value="{!a.Staffing_Comments_Station_1__c}"/>
                </apex:column>
                
                <apex:column headerValue="Date of Station Visit :">
                    <apex:inputField value="{!a.Visit_Date_Station_1__c}"/>
                </apex:column>
                
                <apex:column headerValue="Comments Regarding Visit :">
                    <apex:inputField value="{!a.Visit_Comments_Station_1__c}"/>
                </apex:column>
                
            </apex:pageBlockTable>
            </apex:pageblockSection>
            
<table width="54%">
    <tr><td>
    <apex:pageblocksection title="Domicile Specifics" collapsible="false" ID="DomicileSpecifics">
        <apex:panelGrid columns="2" width="50%" id="DomicileSpecificsGrid">
          <apex:outputText ><b>OT Goal</b></apex:outputText>
          <apex:outputText ><b>OT Actual</b></apex:outputText>
            <apex:inputtext value="{!theText}" id="OTGoalInput">
                <apex:actionsupport event="onchange" rerender="table" status="status"/>
            </apex:inputtext>
            <apex:inputField value="{!End_of_Month_Report__c.OT_Actual_Station_1__c}" id="OTActualInput">
                <apex:actionsupport event="onchange" rerender="table" status="status"/>
            </apex:inputfield>
          <apex:outputText ><b>Hours Planned</b></apex:outputText>
          <apex:outputText ><b>Hours Actually Worked</b></apex:outputText>
            <apex:inputField value="{!End_of_Month_Report__c.Hours_Planned_Station_1__c}"/>
            <apex:inputField value="{!End_of_Month_Report__c.Hours_Worked_Station_1__c}"/>
            <apex:outputText ><b>OPs Taken Total </b></apex:outputText>
            <apex:outputText ><b>OP-04 Delays Total </b></apex:outputText>  
            <apex:inputField value="{!End_of_Month_Report__c.OPs_Taken_Station_1__c}"/>
            <apex:inputField value="{!End_of_Month_Report__c.OP_04_Delays_Station_1__c}"/>
        </apex:panelGrid>
    </apex:pageblockSection>
    </td>
        
        <td>
        <apex:pageblocksection title="Customer Interactions" collapsible="false">
        <apex:panelGrid columns="2" width="50%">
            <apex:outputText ><b>Sales Call Comments</b></apex:outputText>
            <apex:outputText ><b>Customer Issues</b></apex:outputText>
            <apex:inputField value="{!End_of_Month_Report__c.Sales_Call_Customer_Comments_1__c}"/>            
            <apex:inputField value="{!End_of_Month_Report__c.Customer_Issue_1__c}"/>
        </apex:panelGrid>
        </apex:pageblockSection>
        </td></tr>
        </table>    
      
    <apex:pageblockButtons location="Top" Title="Add/Remove a City?">
        <div style="text-align:left;font-weight:bold;">
            <apex:commandLink value="Add Another City" action="{!addRow}" rerender="table" immediate="true" />
&nbsp;|&nbsp;&nbsp;
            <apex:commandLink value="Remove City" action="{!removeRow}" rerender="table" immediate="true" />                
        </div>
    </apex:pageblockButtons>  
    </apex:pageBlock>
    </apex:form>
</apex:page>

 Controller.

Public class ReportEntry {

    public List<End_Of_Month_Report__c> Report {get; set;}

    public ReportEntry(ApexPages.StandardController myController) {
        Report = new List<End_Of_Month_Report__c>();
        Report.add(New End_Of_Month_Report__c());
        }
        

    public void addrow() {
        Report.add(new End_Of_Month_Report__c());}
            
    public void removerow(){
        Integer i = Report.size();
        Report.remove(i-1);}
    
    public PageReference save() {
        system.debug('xxxxxxxxxxxxxxxxx'+ Report);
        insert Report;
        PageReference gorecord = new PageReference('/a1N/o');
        gorecord.setRedirect(true);
        return gorecord; }}

 The fields that do not save are between the <table> tags. 

 

Anyone know where I have gone awry?

 

Thanks!

  • June 27, 2013
  • Like
  • 0

I know you can create a custom button and create a task on click using Javascript. can you apply the same thing to visualforce pages? The button code looks like this:

{!REQUIRESCRIPT("/soap/ajax/17.0/connection.js" )}
var t1= new sforce.SObject("Task" );
      t1.OwnerId = "##############3";
      t1.Subject = "This is my subject";
      t1.Status = "Not Started";
      t1.Priority = "Normal";
      t1.whatId = "#############";
      result = sforce.connection.create([t1]);

So would the VF page code look like this?

<apex:page >
<script language="Javasript">

var t1= new sforce.SObject("Task" );
      t1.OwnerId = "##############3";
      t1.Subject = "This is my subject";
      t1.Status = "Not Started";
      t1.Priority = "Normal";
      t1.whatId = "#############";
      result = sforce.connection.create([t1]);
</script>
</apex:page>

This doesn't work though. Any thoughts?

  • July 29, 2013
  • Like
  • 0

I've looked but have failed to find a remedy thus far. Any input is welcome. 

 

I have a page that creates multiple records at once, with buttons that can add or remove rows(new records) to a pageblocktable. This works. All the records save perfectly. 

 

In addition to these rows there are other inputfields that contain information that should be applied to every single new record. The data from these inputfields does not save. All the fields are found under the same object "End_of_Month_Report__c". Below is the VF page. HTML has been added to format the layout.  

 

<apex:page standardController="End_of_Month_Report__c" extensions="ReportEntry" Title="New End of the Month Report">
<h1><b><font size="5" face="Times New Roman">New End of the Month Report</font></b></h1>

    <apex:form title="New End of the Month Report">
     
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}" rerender="table" />
                <apex:commandButton value="Cancel" action="{!cancel}" rerender="table" />
            </apex:pageBlockButtons>
            <apex:pageblocksection title="Data for All Cities in the Region" id="PBS" collapsible="false">
           
            <apex:pageBlockTable value="{!Report}" var="a" id="table">
                <apex:column headerValue="Station [Domicile First] :">
                    <apex:inputField value="{!a.Station_1__c}"/>
                </apex:column> 
                               
                <apex:column headerValue="Fully Staffed?">
                    <apex:inputField value="{!a.Staffing_Station_1__c}"/>
                </apex:column>
                
                <apex:column headerValue="Staffing Comments :">
                    <apex:inputField value="{!a.Staffing_Comments_Station_1__c}"/>
                </apex:column>
                
                <apex:column headerValue="Date of Station Visit :">
                    <apex:inputField value="{!a.Visit_Date_Station_1__c}"/>
                </apex:column>
                
                <apex:column headerValue="Comments Regarding Visit :">
                    <apex:inputField value="{!a.Visit_Comments_Station_1__c}"/>
                </apex:column>
                
            </apex:pageBlockTable>
            </apex:pageblockSection>
            
<table width="54%">
    <tr><td>
    <apex:pageblocksection title="Domicile Specifics" collapsible="false" ID="DomicileSpecifics">
        <apex:panelGrid columns="2" width="50%" id="DomicileSpecificsGrid">
          <apex:outputText ><b>OT Goal</b></apex:outputText>
          <apex:outputText ><b>OT Actual</b></apex:outputText>
            <apex:inputtext value="{!theText}" id="OTGoalInput">
                <apex:actionsupport event="onchange" rerender="table" status="status"/>
            </apex:inputtext>
            <apex:inputField value="{!End_of_Month_Report__c.OT_Actual_Station_1__c}" id="OTActualInput">
                <apex:actionsupport event="onchange" rerender="table" status="status"/>
            </apex:inputfield>
          <apex:outputText ><b>Hours Planned</b></apex:outputText>
          <apex:outputText ><b>Hours Actually Worked</b></apex:outputText>
            <apex:inputField value="{!End_of_Month_Report__c.Hours_Planned_Station_1__c}"/>
            <apex:inputField value="{!End_of_Month_Report__c.Hours_Worked_Station_1__c}"/>
            <apex:outputText ><b>OPs Taken Total </b></apex:outputText>
            <apex:outputText ><b>OP-04 Delays Total </b></apex:outputText>  
            <apex:inputField value="{!End_of_Month_Report__c.OPs_Taken_Station_1__c}"/>
            <apex:inputField value="{!End_of_Month_Report__c.OP_04_Delays_Station_1__c}"/>
        </apex:panelGrid>
    </apex:pageblockSection>
    </td>
        
        <td>
        <apex:pageblocksection title="Customer Interactions" collapsible="false">
        <apex:panelGrid columns="2" width="50%">
            <apex:outputText ><b>Sales Call Comments</b></apex:outputText>
            <apex:outputText ><b>Customer Issues</b></apex:outputText>
            <apex:inputField value="{!End_of_Month_Report__c.Sales_Call_Customer_Comments_1__c}"/>            
            <apex:inputField value="{!End_of_Month_Report__c.Customer_Issue_1__c}"/>
        </apex:panelGrid>
        </apex:pageblockSection>
        </td></tr>
        </table>    
      
    <apex:pageblockButtons location="Top" Title="Add/Remove a City?">
        <div style="text-align:left;font-weight:bold;">
            <apex:commandLink value="Add Another City" action="{!addRow}" rerender="table" immediate="true" />
&nbsp;|&nbsp;&nbsp;
            <apex:commandLink value="Remove City" action="{!removeRow}" rerender="table" immediate="true" />                
        </div>
    </apex:pageblockButtons>  
    </apex:pageBlock>
    </apex:form>
</apex:page>

 Controller.

Public class ReportEntry {

    public List<End_Of_Month_Report__c> Report {get; set;}

    public ReportEntry(ApexPages.StandardController myController) {
        Report = new List<End_Of_Month_Report__c>();
        Report.add(New End_Of_Month_Report__c());
        }
        

    public void addrow() {
        Report.add(new End_Of_Month_Report__c());}
            
    public void removerow(){
        Integer i = Report.size();
        Report.remove(i-1);}
    
    public PageReference save() {
        system.debug('xxxxxxxxxxxxxxxxx'+ Report);
        insert Report;
        PageReference gorecord = new PageReference('/a1N/o');
        gorecord.setRedirect(true);
        return gorecord; }}

 The fields that do not save are between the <table> tags. 

 

Anyone know where I have gone awry?

 

Thanks!

  • June 27, 2013
  • Like
  • 0

I have used the dynamic search code from Jeff Douglas http://blog.jeffdouglas.com/2010/07/13/building-a-dynamic-search-page-in-visualforce/

 

i have run into some difficulties - the dynamic search is not working and i can not work it out so i added a submit button but this just gives an error

Attempt to de-reference a null object 

 

this is the controller

public with sharing class ContactSearchController {

    

  // the soql without the order and limit
  private String soql {get;set;}
  // the collection of contacts to display
  public List <Contact> contacts {get;set;}

  // the current sort direction. defaults to asc
  public String sortDir {
    get  { if (sortDir == null) {  sortDir = 'asc'; } return sortDir;  }
    set;
  }

  // the current field to sort by. defaults to last name
  public String sortField {
    get  { if (sortField == null) {sortField = 'lastName'; } return sortField;  }
    set;
  }

  // format the soql for display on the visualforce page
  public String debugSoql {
    get { return soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20'; }
    set;
  }

  // init the controller and display some sample data when the page loads
  public ContactSearchController() {
    soql = 'select firstName, lastName, account.name, Employee_Number__c from contact where account.name != null';
    runQuery();
  }

  // toggles the sorting of query from asc<-->desc
  public void toggleSort() {
    // simply toggle the direction
    sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
    // run the query again
    runQuery();
  }

  // runs the actual query
  public void runQuery() {

    try {
      contacts = Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20');
    } catch (Exception e) {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
    }

  }

  // runs the search with parameters passed via Javascript
  public PageReference runSearch() {

    String firstName = Apexpages.currentPage().getParameters().get('firstName');
    String lastName = Apexpages.currentPage().getParameters().get('lastName');
    String accountName = Apexpages.currentPage().getParameters().get('accountName');
    
    soql = 'select firstName, lastName, account.name, Employee_Number__c, from contact where account.name != null';
    if (!firstName.equals(''))
      soql += ' and firstName LIKE \''+String.escapeSingleQuotes(firstName)+'%\'';
    if (!lastName.equals(''))
      soql += ' and lastName LIKE \''+String.escapeSingleQuotes(lastName)+'%\'';
    if (!accountName.equals(''))
      soql += ' and account.name LIKE \''+String.escapeSingleQuotes(accountName)+'%\'';
    

    // run the query again
    runQuery();

    return null;
  }

  

}

 and this is the VF Page

 

If anyone can help me you would be a lifesaver!!!

<apex:page controller="ContactSearchController" sidebar="false">

  <apex:form >
  <apex:pageMessages id="errors" />

  <apex:pageBlock title="Find Me A Customer!" mode="edit">
<table width="100%" border="0">
<tr>
<td width="200" valign="top">

      <apex:pageBlock title="Parameters" mode="edit" id="criteria">

      <script type="text/javascript">
      function doSearch() {
        searchServer(
          document.getElementById("firstName").value,
          document.getElementById("lastName").value,
          document.getElementById("accountName").value,
                    );
      }
      </script> 

      <apex:actionFunction name="searchServer" action="{!runSearch}" >
          <apex:param name="firstName" value="" />
          <apex:param name="lastName" value="" />
          <apex:param name="accountName" value="" />
       
      </apex:actionFunction>
<table cellpadding="2" cellspacing="2">
<tr>
<td style="font-weight:bold;">First Name<br/>
<input type="text" id="firstName" onkeyup="doSearch();"/>
        </td>
</tr>
<tr>
<td style="font-weight:bold;">Last Name<br/>
<input type="text" id="lastName" onkeyup="doSearch();"/>
        </td>
</tr>
<tr>
<td style="font-weight:bold;">Account<br/>
<input type="text" id="accountName" onkeyup="doSearch();"/>
        </td>
      <tr>
        <td>
<apex:commandButton value="Search" action="{!runSearch}" rerender="results,debug,errors"/>
</td>
</tr>
</tr>
<tr>

</tr>
</table>

      </apex:pageBlock>
</td>
<td valign="top">

    <apex:pageBlock mode="edit" id="results">

        <apex:pageBlockTable value="{!contacts}" var="contact">

<apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Employee ID" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="Employee_Number__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!contact.Employee_Number__c}"/>
            </apex:column>


            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="First Name" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="firstName" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!contact.firstName}"/>
            </apex:column>

            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Last Name" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="lastName" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!contact.lastName}"/>
            </apex:column>

            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Account" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="account.name" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!contact.account.name}"/>
            </apex:column>


            

        </apex:pageBlockTable>

    </apex:pageBlock>
</td>
</tr>
</table>

  <apex:pageBlock title="Debug - SOQL" id="debug">
      <apex:outputText value="{!debugSoql}" />
  </apex:pageBlock>    

  </apex:pageBlock>

  </apex:form>

</apex:page>

Pretty simple question. How do you set the height of a Rich Text field in a visualforce page. It seems like no matter what I do it is stuck at 35px which is obviously not very useful.

 

None of these seem to work:

 

 

<apex:page controller="Image">
    <style>
        .customImage{
            height: 240px;
            width: 180px;
} </style> <apex:outputField id="image" value="{!obj.Image__c}" styleClass="customImage" /> <apex:outputField id="image" value="{!obj.Image__c}" style="height:240px;width:180px" /> </apex:page>

 

What's the secret?

 

Thanks,

Jason

Hi,

I'm trying to incorporate a rich text textarea into a Visualforce page. I tried using the richtext="true" attribute,  but it seems like I don't have
very little control over the size and location of the textarea once it's rendered. This creates the rich text editor fine:

Code:
            <apex:pageBlockSection collapsible="true" title="My Form">        
                <apex:inputField value="{!event.Field1__c}"/>
                <apex:inputTextarea value="{!event.Field3__c}" id="specialTextArea" richtext="true"/>
                <apex:inputField value="{!event.Field2__c}"/>
            </apex:pageBlockSection>

 
but adding rows & cols attributes doesn't work, nor does adding css to the element (e.g. style="width:150px; height: 100px"). It just 
displays as wide as it can fit. I'm getting input for a SObject, so I'm using inputField elsewhere, but this seems to work as far as 
getting input in and out goes -- it gets and saves the field data with no problem.

Unlike inputField though, this won't automatically generate a label, so I also tried something like this:
Label <apex:inputTextarea value="{!event.Field3__c}" id="specialTextArea" richtext="true"/>

But that doesn't work either -- it just pushes the rich textarea over to the right.

Has anyone had any luck using this inside a PageBlockSection amongst other inputFields?

I also tried a few other WYSIWYG packages that I used in other work -- TinyMCE and the WYMeditor plugin for jquery. However,
I was not able to get either to work in the visualforce page. Both require a class or id attribute to identify the textArea to make
rich text. Identifying class doesn't seem to work. I also tried using the id, but the id seems to get transformed in the output.
Looking at the source of the html frame, I see something like
id="j_id0:j_id3:j_id4:j_id32:specialTextArea".
I also tried that id, but it didn't work either. If anyone has gotten another
WYSIWYG editor working with visualforce, I'd be interested
in hearing about that also.

thanks,
-paul


Message Edited by ptepper on 07-09-2008 01:21 PM