• emandra_kf
  • NEWBIE
  • 25 Points
  • Member since 2012

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 10
    Replies

I'm using a controller extension with a custom object to provide a SaveandReturn method. The code is basically a copy/paste from other similar controllers posted on this board. My problem is that the Catch portion of the Try/Catch never gets invoked - even when there is a clear validation error. My VF page includes the <apex:PageMessages /> tag. The controller looks like this:

 

public with Sharing class SaveAndReturnController
{
    private ApexPages.StandardController controller;

    public SaveAndReturnController(ApexPages.StandardController controller)
    {
        this.controller = controller;
    }

    public PageReference saveAndReturn()
    {
        try {  
        
           PageReference cancel = controller.cancel();
           controller.save();
           System.Debug('Saving');
           return cancel;  
        }
           
           // Don't redirect if something goes wrong. May be a validation or trigger issue on save.
         catch(exception e) {
            ApexPages.addMessages(e);
            System.Debug('Exception');
            return null;  }
    }
}

 

When the Save button is clicked, the record is NOT saved and the page is redirected to the parent page. No error message is ever displayed. Does anyone have a suggestion about how to catch the Validation errors when they occur?

 

 

I am trying to use a child-to-parent relationship to obain a Name value from the parent object on a "new" VisualForce page.

 

The child object is Data_Transaction__c and the parent object is Data_Activity__c.

 

The field Data_Activity__c is selected by a user and triggers a rerendering of the page. I then need to use the value of Data_Transaction__c.Data_Activity__r.Name as criteria for rendering the portion of the page appropriate for the selected Data Activity. Problem is Data_Transaction__c.Data_Activity__r.Name is null because the record is not actually saved yet. If I try to use just Data_Transaction__c.Data_Activity__c, it evaluates to the 18 character Id of the selected Data_Activity__c object.

 

Any suggestions on an alternative approach? Code sample below.

 

 

 

<apex:page standardController="Data_Transaction__c"  sidebar="false" id="thePage">

  <apex:sectionHeader title="Data Transaction Edit"subtitle="New Data Transaction"/>

  <apex:form id="theForm">

    <apex:pageBlock title="Data Transaction Edit" id="thePageBlock"mode="edit">

      <apex:pageMessages rendered="false"/>

      <apex:pageBlockButtons >

        <apex:commandButton value="Save" action="{!save}"/>

        <apex:commandButton value="Cancel" action="{!cancel}"/>

      </apex:pageBlockButtons>

      <apex:actionRegion >

        <apex:pageBlockSection title="Data Transaction Information"columns="1">

          <apex:outputField value="{!Data_Transaction__c.Production_Number__c}"/>

          <apex:pageBlockSectionItem >

            <apex:outputLabel value="Activity Type"/>

            <apex:outputPanel >

              <apex:inputField value="{!Data_Transaction__c.Data_Activity__c}">

                <apex:actionSupport event="onchange"

                                    rerender="thePanel"

                                    status="status"/>

              </apex:inputField>

 

              <apex:actionStatus startText="     Updating..."

                                 id="status"/>

            </apex:outputPanel>

          </apex:pageBlockSectionItem>

         </apex:pageBlockSection>

      </apex:actionRegion>

      <apex:outputPanel id="thePanel">

      <apex:pageBlockSection title="Mortgage Details" columns="1" rendered="{!Data_Transaction__c.Data_Activity__r.Name == 'Mortgage'}">

        <apex:inputField value="{!Data_Transaction__c.AS400__c}" rendered="{!Data_Transaction__c.Transaction_Type__c == 'Completed Work'}"/>   

        <apex:inputField value="{!Data_Transaction__c.HDES__c}" rendered="{!Data_Transaction__c.Transaction_Type__c == 'Completed Work'}"/>

        <apex:inputField value="{!Data_Transaction__c.Not_Processed__c}" rendered="{!Data_Transaction__c.Transaction_Type__c == 'Completed Work'}" label="Canceled"/>

        <apex:inputField value="{!Data_Transaction__c.Items__c}" required="true"/>              

        <apex:inputField value="{!Data_Transaction__c.Hours__c}" required="{!Data_Transaction__c.Transaction_Type__c == 'Completed Work'}" rendered="{!Data_Transaction__c.Transaction_Type__c == 'Completed Work'}"/>

      </apex:pageBlockSection>

 

I am attempting to access parent data fields from a child object in a Visualforce page used to create new records in the child object.

 

I have a similar detail page for viewing records in the child object, and on that page I can simply access parent data with the apex component:

<apex:outputfield value="{!child_object__c.parent_object__r.fieldname}".

 

However, with the "new" page, the same approach just comes back null. Do I need to create a controler extension instead? I'm lost and not sure what the right approach might be.

 

 

 

 

I'm looking for some advice on how to approach a complex "Lookup Filter" that I am unable to create through the normal interface. I'm assuming there may be a way with a VF page or possibly an Apex trigger.

 

My objects include Order__c and Order_Details__c in a Master/Detail relationship plus Vendor__c and Product__c in a Master/Detail relationship. Vendor_Name__c is a field on the Order__c object defined as Lookup(Vendor__c), and Product_Name__c is a field on the Order_Details__c object defined as Lookup(Product__c).

 

My challenge is that I need to create a Lookup Filter on Product_Name__c in my Order_Details__c records such that only products for the Vendor_Name__c chosen in the parent Order__c record are displayed.

 

In other words, a user will first create an Order record and chose the Vendor from whom goods are being purchased. The user will then create one or more Order Detail records (line items) for each Product he wishes to purchase. The list of available Products to purchase should be limited to those offered by the Vendor receiving the Order. Hope this makes sense.

 

Any techniques, approaches you can offer would be greatly appreciated.

I have a custom object with a checkbox field that is defaulted to "checked". When creating a new record, I would like to retain the state of the checkbox (either checked or unchecked) from the previous new record rather than always reverting to the default state of "checked".

 

I'm using a VF page and a custom controller extension based on the example provided here: http://www.fishofprey.com/2012/03/salesforce-save-and-new-method-for.html to create a "Save & New" type of rapid data entry form. 

 

Now, I just need the checkbox field on the VF page to be "sticky" so that it only has to be selected once for a batch of work that is all "unchecked".

 

Any suggestions on how to do that?

I'm having trouble with two picklist fields in my VF page. To start, I created a page using the example provided here:  http://developer.force.com/cookbook/recipe/dynamically-updating-a-page. As the cookbook illustrates, I'm dynamically displaying different fields based on the selection of a picklist field. In my case, the picklist field triggering the rerendering is called "Activity Type". It all works great. 

 

At the same time, "Activity Type" is also configured in my custom object as a Controlling Field and its Dependent Field is called "Device". On my VF page, when an Activity Type is selected, the appropriate pageBlockSection rerenders and the Device picklist is updated; however, the Device field remains set to its prior value and the prior value is part of the new picklist values - even though it is no longer a valid option based on the Field Dependecy configuration.

 

If I use a standard layout page (non VF page), the Activity Type - Device dependency works fine so there is something about the rerendering that is causing the prior value of Device to remain set. Also, I tried moving the Device field inside and outside the rerendered pageBlockSection and the behavior did not change.

 

Any suggestions on how to clear out the Device field's prior value so the updated picklist includes only the valid options?

I'm using Flow Designer to model my process and need to compare two text fields to be sure they are the same ("Email Address", "Confirm Email Address". The validation feature in the cloud version makes this very easy, but I can't figure out how to do it in Flow Designer. Is an Apex plug-in the only option?

I'm using Flow Designer to model a process that will be invoked from a public site. I've created two different pages that utilize the same flow - the pages are more or less the same, but they are designed for two different constituencies.

 

Is there a way for the flow itself to lookup, or in some way determine the page that invoked the flow?

 

I would like to track which page was used for reporting purposes.

I'm encountering a problem with an Apex trigger and a workflow rule on a custom object that I think relates to order of execution. Here's the scenario:

 

1.) Custom object has a Due Date field that is populated by an Apex trigger using a "before" trigger type.

 

2.) Workflow rule sends an Email Alert upon "only when record is created".

 

3.) The Email Alert uses an Email Template that includes Due Date, yet the Due Date is null (missing) in the email that is generated.

 

The Email Template is also used to send emails on an ad hoc basis, and in those cases the Due Date is displayed in the email as expected. Because of this, I do not believe there is a problem with the Email Tempalte or the Apex trigger.

 

Nonetheless, the standard order of execution would indicate the "before" trigger should fire prior to the workflow rule and the Due Date should be available to include in the email generated by the workflow rule.

 

Am I overlooking something? Any suggestions would be appreciated.

I'm not sure how to properly format a URLFor statement to reference a view that I've defined. I do not wish to go to the default Tab view for my custom object. Listed below is a Javascript which is assigned to a custom button; the last line of the Javascript is a hard-wired URL to the View itself.

 

Any advice as to how I could do it properly with the URLFOR statement?

 

{!requireScript("/soap/ajax/11.1/connection.js")}
var url = parent.location.href; //string for the URL of the current page
var update_Request = new sforce.SObject("emandra__EOI_Request__c"); //create a new sObject for storing updated record details
update_Request.Id = '{!emandra__EOI_Request__c.Id}'; //set the Id of the selected Request record
update_Request.emandra__Status__c = "Completed"; //set the value for Status to 'Completed'
result = sforce.connection.update([update_Request]); //push the updated records back to Salesforce
window.parent.location.href="https://na14.salesforce.com/a05?fcf=00Bd0000004IUMt"

In the last screen of my flow, I display the various input fields submitted by the user as a confirmation of what s/he enterred. This screen is preceeded by a Record Create task which posted the data to my custom object. All is well except for the fact that my last screen displays the default buttons of "Previous" and "Finish". How do I remove or hide the Previous button so a user does not make an inadvertent double entry by clicking the Previous button and invoking the Record Create a second time?

Is it possible to include Lookup fields with a Record Create? I know that one cannot update lookup fields with a Field Update action on a Workflow Rule, but I was hoping Visual Workflow would offer something new. 

 

If it does not, is the solution to write an Apex plug-in component?

 

Thanks.

I'm using a controller extension with a custom object to provide a SaveandReturn method. The code is basically a copy/paste from other similar controllers posted on this board. My problem is that the Catch portion of the Try/Catch never gets invoked - even when there is a clear validation error. My VF page includes the <apex:PageMessages /> tag. The controller looks like this:

 

public with Sharing class SaveAndReturnController
{
    private ApexPages.StandardController controller;

    public SaveAndReturnController(ApexPages.StandardController controller)
    {
        this.controller = controller;
    }

    public PageReference saveAndReturn()
    {
        try {  
        
           PageReference cancel = controller.cancel();
           controller.save();
           System.Debug('Saving');
           return cancel;  
        }
           
           // Don't redirect if something goes wrong. May be a validation or trigger issue on save.
         catch(exception e) {
            ApexPages.addMessages(e);
            System.Debug('Exception');
            return null;  }
    }
}

 

When the Save button is clicked, the record is NOT saved and the page is redirected to the parent page. No error message is ever displayed. Does anyone have a suggestion about how to catch the Validation errors when they occur?

 

I have a custom object with a checkbox field that is defaulted to "checked". When creating a new record, I would like to retain the state of the checkbox (either checked or unchecked) from the previous new record rather than always reverting to the default state of "checked".

 

I'm using a VF page and a custom controller extension based on the example provided here: http://www.fishofprey.com/2012/03/salesforce-save-and-new-method-for.html to create a "Save & New" type of rapid data entry form. 

 

Now, I just need the checkbox field on the VF page to be "sticky" so that it only has to be selected once for a batch of work that is all "unchecked".

 

Any suggestions on how to do that?

I'm encountering a problem with an Apex trigger and a workflow rule on a custom object that I think relates to order of execution. Here's the scenario:

 

1.) Custom object has a Due Date field that is populated by an Apex trigger using a "before" trigger type.

 

2.) Workflow rule sends an Email Alert upon "only when record is created".

 

3.) The Email Alert uses an Email Template that includes Due Date, yet the Due Date is null (missing) in the email that is generated.

 

The Email Template is also used to send emails on an ad hoc basis, and in those cases the Due Date is displayed in the email as expected. Because of this, I do not believe there is a problem with the Email Tempalte or the Apex trigger.

 

Nonetheless, the standard order of execution would indicate the "before" trigger should fire prior to the workflow rule and the Due Date should be available to include in the email generated by the workflow rule.

 

Am I overlooking something? Any suggestions would be appreciated.

In the last screen of my flow, I display the various input fields submitted by the user as a confirmation of what s/he enterred. This screen is preceeded by a Record Create task which posted the data to my custom object. All is well except for the fact that my last screen displays the default buttons of "Previous" and "Finish". How do I remove or hide the Previous button so a user does not make an inadvertent double entry by clicking the Previous button and invoking the Record Create a second time?

Is it possible to include Lookup fields with a Record Create? I know that one cannot update lookup fields with a Field Update action on a Workflow Rule, but I was hoping Visual Workflow would offer something new. 

 

If it does not, is the solution to write an Apex plug-in component?

 

Thanks.

Hi,

 

I created a new lead record via visual workflow and I binded that visual workflow into visualforce page.

 

Its working fine. But I need a latest created Lead record on visualforce page once I click the finish button on visual workflow.

 

I tried with finishlocation but its not working. Its just to move the home page only.

 

How to get that lead Id on visualforce page and redirect to the lead record?

 

 

Hi at all,

 

i'm a newbie in triggers and i hope someone can help me?

The function should be:

There is a Task, related to a Custom object (1:1). If the Task is updated (Status = Completed), some informations  should transferred and updated to the related object__c (Task.custom_code_c --> object__c.custom_code__c and object__c.closed=true)

 

Could somebody give me an advice?

 

Thanks

 

feliks

 

  • November 25, 2010
  • Like
  • 0