• nothingisreal68
  • NEWBIE
  • 25 Points
  • Member since 2008

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

Hello,

 

I have the following trigger, aimed to populate a Contact Lookup field with the Contact Id of a related record called Rep ID.

 

Here is the trigger I have:

trigger AccommodationsBeforeTrigger on Accommodations__c (before insert, before update) 
{
    for (Accommodations__c a: trigger.new)
    {
        a.Contact__c = a.Rep_ID__r.Contact__r.Id;
    } 
}

 

This trigger is returning a blank value for the Contact lookup field whenever a record is saved.

However, what's interesting is that if I create a formula field, and use my trigger to set the Contact lookup value equal to this formula field, it works. 

For example, I created a Formula field: test__c whose value is Rep_ID__r.Contact__r.Id.

 

Then, I adjusted my trigger to the following

trigger AccommodationsBeforeTrigger on Accommodations__c (before insert, before update) 
{
    for (Accommodations__c a: trigger.new)
    {
        a.Contact__c = a.Test__c;
    } 
}

 I don't get why it works this way and not the first way since the formula code is the same as the code in my first trigger example. I'd like the trigger to work without the need to create a separate field.

 

Thanks!

Mikey

I have a formula field that is converting a date/time into just a date. Based on conditional logic, this formula attempts to take the Datevalue() of a datetime.

 

On the problem record, the value of the datetime field is "5/1/2013 12:00 AM".

 

When viewing the standard view page for this record, the formula correctly displays "5/1/2013".  When I navigate to a related list that displays the same formula field, however, the value shown is "4/30/2013".

 

Why would the exact same field display differently in a related list and on a standard view? I have been able to reproduce this in several orgs with brand new sObjects. My current user is in the eastern time zone. This same issue seems to happen regardless of the time zone my user is in.

 

Steps to reproduce:

1. Create a brand new object "Parent"

2. Create another object, "Child".

3. On the child record, create three fields:

    1) a lookup field to the parent object.

    2) a datetime field, "Datetime 1" that is a sample field.

    3) a formula field, "Formula Field" that returns the datevalue of the other created field. The formula should be:

 

            Datevalue(Datetime_1__c)

 

4. Create a record of the parent object. 

5. Create a record of the child object. Populate the Datetime 1 field with 5/1/2013 12:00 AM and save the record. Notice that the formula field correctly displays "5/1/2013".

6. Navigate to the parent record and view the child record in the related list. Note that "Datetime 1" displays correctly, but "Formula Field" now shows "4/30/2013."

 

 

In my tests, when the value of the datetime field is set to "1:00 AM" instead, the formula displays correctly in both places. It seems like on related lists, SFDC does not taken into account Daylight Savings Time when converting Datetimes to Dates in formulas.

 

 

 

I am running into an error attempting to use the wsdl2apex functionality to generate apex classes from an extenal WSDL. I want to send outbound faxes using the Interfax service, following the directions as written on this blog.

 

After removing the multiple port type and bindings, when I consume the wsdl, I am presented with the following error:

 

Unable to find schema for element; {http://www.w3.org/2001/XMLSchema}int
 
While I thought that a standard "int" was a supported type, I tried changing all references to a double, and still received a similar message:
 

Unable to find schema for element; {http://www.w3.org/2001/XMLSchema}double

 

I tried to do this in multiple sandboxes as well as a developer org, to ensure that this wasn't a sandbox related issue.  Clearly something else is awry, what Am I doing wrong?

Hi Community,

 

I have a trigger that needs to match line items of the same custom object type and populate lookups to one another. The logic to find these matching items is straight forward, but I am wondering if I am overlooking the best way to actually populate the lookups.

 

The problem arises when one or both of the line items are being inserted (vs. updated), and therefore do not have access to a salesforce ID to use to populate the lookups in the context of the before trigger. These line items do have external Ids.

 

I tried populating the external ids in a reference to the other record in the trigger, and this seems to work when an actual insert DML statement is made in apex code - but does not work when used in the trigger (without a DML call). Example:

 

Line_Item__c first = new Line_Item__c();

Line_Item__c second = new Line_Item__c(External_ID__c = 'externalId2');

first.Line_Item__r = second;

 

This seemingly does not work in a trigger.

 

My thought now is to use an @future method. When the items are matched in the trigger, it will pass the two external id's of the line items to the @future method which will query the database for the correct ids and populate the lookups, and finally update the line items. 

 

Is there a better way to do this? Any help is appreciated. 

Hola,

 

I want to add a message to an sObject via a trigger, to provide some visualfeed back to users upon a save of a page.

 

The standard method addMessage() will not work because it prevents all dml from occuring - something I DONT want to have happen - I still want the record to save.

 

I also played with the visualforce method ApexPages.addMessage() - but this throws a runtime System.Final exception, because it is not being invoked in the context of a visualforce page. 

 

How can I add a message to the top of a page (be it the red error text, or a PageMessage) with a trigger while still saving the object?

 

Thanks in advance. 

In the dev docs, it states:

 

"Beginning with API version 20.0, an inputField matched to a field with a default value has the default value prepopulated on the Visualforce page."

 

This functionality works fine when the object is instantiated in the constructor on page load. However, I need to develop a page that renders different objects on a certain part of the page based on the click of a button by the user. When I instantiate this object in a controller action method from the user's click, the default value does NOT appear. Is this standard functionality? I am using an <apex:inputField /> as the document describes. 

 

Thanks in advance for the help!

 

I have a visualforce component utilizing dynamic bindings that I would like to use in multiple orgs. Everything works great in one org, but when I move it to another, I receive the following message after the component attempts to rerender itself:

 

Could not resolve the entity from <apex:inputField> value binding '{!obj[fieldName]}'. inputField can only be used with SObject fields.

 

 

The code is as follows:

 

<apex:inputField value="{!obj[fieldName]}" rendered="{!obj[fieldName] != otherValue && obj[fieldName] !=otherMessage}"> 

<apex:actionSupport event="onchange" reRender="thePanel" action="{!processSelection}" status="status" / >

</apex:inputField>

 

 

"obj" is a reference to a generic sObject in the controller, and "fieldName" is a String in the controller.

 

I find it interesting that the visualforce page compiles and saves, and that it only throws this error when it attempts to reRedner. I checked to ensure that the API version of the page the component is on, the component itself, and the component controller is the same in both orgs. 

 

Thanks in advance for any insight!

I created a simple visualForce page to test a class method that I created, which simple returns a string.

<apex:page standardController="Case" title="Date Test"
    extensions="caseExtension" showHeader="false" sidebar="false">
    {!shiftManager}
</apex:page>


In my extension caseExtension, I have a method called getShiftManager(), which like i said, returns a string.
yesterday everything was working fine, the string displayed correctly on my visualforce page. Today, when I
try to run it, I get the error message:

Unknown poperty 'CaseStandardController.shiftManager'

It seems like it is looking for a field on the standard controller now, which of course isn't there, and not recognizing my
extension. Any help would be greatly appreciated.

Hello,

 

I have the following trigger, aimed to populate a Contact Lookup field with the Contact Id of a related record called Rep ID.

 

Here is the trigger I have:

trigger AccommodationsBeforeTrigger on Accommodations__c (before insert, before update) 
{
    for (Accommodations__c a: trigger.new)
    {
        a.Contact__c = a.Rep_ID__r.Contact__r.Id;
    } 
}

 

This trigger is returning a blank value for the Contact lookup field whenever a record is saved.

However, what's interesting is that if I create a formula field, and use my trigger to set the Contact lookup value equal to this formula field, it works. 

For example, I created a Formula field: test__c whose value is Rep_ID__r.Contact__r.Id.

 

Then, I adjusted my trigger to the following

trigger AccommodationsBeforeTrigger on Accommodations__c (before insert, before update) 
{
    for (Accommodations__c a: trigger.new)
    {
        a.Contact__c = a.Test__c;
    } 
}

 I don't get why it works this way and not the first way since the formula code is the same as the code in my first trigger example. I'd like the trigger to work without the need to create a separate field.

 

Thanks!

Mikey

Hola,

 

I want to add a message to an sObject via a trigger, to provide some visualfeed back to users upon a save of a page.

 

The standard method addMessage() will not work because it prevents all dml from occuring - something I DONT want to have happen - I still want the record to save.

 

I also played with the visualforce method ApexPages.addMessage() - but this throws a runtime System.Final exception, because it is not being invoked in the context of a visualforce page. 

 

How can I add a message to the top of a page (be it the red error text, or a PageMessage) with a trigger while still saving the object?

 

Thanks in advance. 

In the dev docs, it states:

 

"Beginning with API version 20.0, an inputField matched to a field with a default value has the default value prepopulated on the Visualforce page."

 

This functionality works fine when the object is instantiated in the constructor on page load. However, I need to develop a page that renders different objects on a certain part of the page based on the click of a button by the user. When I instantiate this object in a controller action method from the user's click, the default value does NOT appear. Is this standard functionality? I am using an <apex:inputField /> as the document describes. 

 

Thanks in advance for the help!

 

I have a visualforce component utilizing dynamic bindings that I would like to use in multiple orgs. Everything works great in one org, but when I move it to another, I receive the following message after the component attempts to rerender itself:

 

Could not resolve the entity from <apex:inputField> value binding '{!obj[fieldName]}'. inputField can only be used with SObject fields.

 

 

The code is as follows:

 

<apex:inputField value="{!obj[fieldName]}" rendered="{!obj[fieldName] != otherValue && obj[fieldName] !=otherMessage}"> 

<apex:actionSupport event="onchange" reRender="thePanel" action="{!processSelection}" status="status" / >

</apex:inputField>

 

 

"obj" is a reference to a generic sObject in the controller, and "fieldName" is a String in the controller.

 

I find it interesting that the visualforce page compiles and saves, and that it only throws this error when it attempts to reRedner. I checked to ensure that the API version of the page the component is on, the component itself, and the component controller is the same in both orgs. 

 

Thanks in advance for any insight!