• juppinger
  • NEWBIE
  • 0 Points
  • Member since 2007

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

Hi everybody,

 

could you post me a simple example (code snipped) please, how to create a visualforce page with an input-field (text) and a "submit"-button.

After inserting text in the textbox and click on the submit button, the text should call a apex-class (java) and simlpy append the string "_abc" to the text.

The new text should appear on the visualforce page under the submit button.

 

Thanks for every post.

 

joerg

 

 

Hi,

 

I want to loop through all field names and compare the values of a lineitem object...

 

Heres my not working code:

 

 

trigger HistoryOpportunityLineItemV001_test on OpportunityLineItem (after insert, after update, before delete) {

// Get the sObject describe result for the Opportunity object
Schema.DescribeSObjectResult r = OpportunityLineItem.sObjectType.getDescribe();
//Generate a Map of the fields
Map<String, Schema.SObjectField> M = r.fields.getMap();

//Now loop through the list of Fields
for (Object fieldName : M.keySet()){
//system.debug('fieldName: ' + fieldName);
if(Trigger.old[0].fieldName.value != Trigger.new[0].FieldName.value) {
System.debug('CHANGED fieldName/fieldValue: ' + fieldName + ' / ' + FieldName.value);
}

}
}

 

 



Any ideas?

 

Thx,

jup

 

 

Message Edited by juppinger on 03-24-2009 03:29 AM
Message Edited by juppinger on 03-24-2009 03:30 AM

Hi,

 

I want to create a trigger that fires after an opportunity will be updated.

First the trigger has to check, if specified fields in the opportunity has changed. If so, the trigger has to log this changes into a new simple custom object (text only).

I wrote my code and the first part works very well:

 

trigger HistoryOpportunityV001_test on Opportunity (after update) { // no bulk processing; will only run from the UI if (Trigger.new.size() == 1) { String strChanges = ''; //// Checking fields if the value has changed // 1. Field: Opportunity.Name if (Trigger.old[0].Name != Trigger.new[0].Name) { cnt++; strChanges += cnt + '. <Name>: "' + Trigger.old[0].Name + '" -> "' + Trigger.new[0].Name + '"\n'; } // 2. Field: Opportunity.Order_ID__c if (Trigger.old[0].Order_ID__c != Trigger.new[0].Order_ID__c) { cnt++; strChanges += cnt + '. <Order_ID__c>: "' + Trigger.old[0].Order_ID__c + '" -> "' + Trigger.new[0].Order_ID__c + '"\n'; } if (cnt > 0) { OpportunityLog__c oppLog = new OpportunityLog__c( OpportunityID__c = Trigger.old[0].Id, OpportunityName__c = 'oppName', OpportunityChangesUser__c = UserInfo.getUserId(), Changes__c = strChanges ); insert oppLog; } } }

 

 

 

Now I want to implement, that the trigger will check if the value of some specific fields of the updated opportunitys line items (products in the opportuity) has changed. If so, I want to log this lineitems field changes, too.

I know that I have to loop through all line items and have to check the field values.

- BUT HOW CAN I DO THIS?

 

Could anyone help me, please? It would be great if you post me your code or ideally complete the existing code ;)

 

Next... I want to log if the user adds a new product/lineitem or deletes a lineitem.

 

Any ideas?

 

Thanks a lot,

jup

 

 

 

Hi everybody,

 

1. if I create a trigger directly in the sandbox and use a system.debug('test)';-Command, where can I find this message diectly in salesforce?

Do I have to active something in the setup to see the system log window?

 

2. if I create something in eclipse, where can I see the debug-messages in eclipse?

 

Thanks,

jup

Hi everybody,

 

first of all: Does anybody know where to get an introduction or better a full documentation of the SOQL database language?

Because not all SQL commands are supported an I want mor about this.

 

I want to list next contacts birthdays from the logged in user. Display them in an apex page.

 

Here is the code of my apex page:

 

 

<apex:page title="Geburtstage" standardController="Contact" extensions="ContactsNextBirthdays"> <apex:pageBlock title="Next Birthdays of your contacts"> <apex:dataTable value="{!NextBirthdayContacts}" var="contact" styleClass="list"> <apex:column > <apex:facet name="header">Birthdate</apex:facet> <apex:outputText value="{0,date,dd.MM.yyyy}"> <apex:param value="{!contact.Birthdate}" /> </apex:outputText> </apex:column> <apex:column > <apex:facet name="header">Name</apex:facet> <apex:outputText value="{!contact.Name}" /> </apex:column> <apex:column > <apex:facet name="header">Firstname</apex:facet> <apex:outputText value="{!contact.FirstName}" /> </apex:column> <apex:column > <apex:facet name="header">Company</apex:facet> <apex:outputText value="{!contact.account.name}" /> </apex:column> </apex:dataTable> </apex:pageBlock> </apex:page>

 And the class code:

 

 

public class ContactsNextBirthdays { private final Contact contactObj; public ContactsNextBirthdays(ApexPages.StandardController controller) { this.contactObj = (Contact)controller.getSubject(); } public Contact[] getNextBirthdayContacts() { String UserId = UserInfo.getUserId(); // UserId des eingeloggten Users holen Date Now = System.now().date(); Contact[] contactList = [SELECT Id, Name, FirstName, Birthdate, Account.Name FROM Contact WHERE Birthdate > :Now AND OwnerId = :UserId ORDER BY Birthdate]; return contactList; } }

 

I tried a lot of queries, but I received never the result I want :-(

 

Any ideas, help or links for me?

 

Thanks very much

j.

 

 

 

 

 

Hi,

my clame is to clear some specified fields while cloning an opportunity. It is necessary to clear some fields in the opportunity-line-items, too.

I want to hide the salesforce opportunity duplicate-button and create a new one with a scontrol on it.


This works fine:

1. I fetch all fields of the source opportunity from the database. Now I put this fields into a new opportunity-object (array). The specified affected fields will be leave blank in this step.

2. This new array will now created in the database as a new opportunity and the new opportunity-id will be kept in mind. (Opportunity)

3. Now all opportunity line-items from the old (source) opportunity will be passed through and the line-items will be created in the database with the new opportunity-id. (OppotunityLineItem)

4. Pt. 3 will be repeated for the opportunitys contact roles. (OpportunityContactRole)

5. This should be repeated like Pt. 3 for the opportunity-partners, too. But here is the problem:
The structure (metadata) of the table OpportunityPartner is looking like it isn’t allowed to append/create fields/lines or modify/update any fields in this table.
Can anybody help me to clone the opportunity this way and duplicate the opportunity-partners (create/append them in the table OpportunityPartner)?

Screenshot from metadata of table OpportunityContactRole (create/update allowed):

http://fachpost.de/screenshot_opportunitycontactrole.GIF


Screenshot from metadata of table OpportunityPartner (create/update forbidden):

http://fachpost.de/screenshot_opportunitypartner.GIF

Thanks for your replies.

Regards,
juppinger

 

 

Hi,

 

I want to loop through all field names and compare the values of a lineitem object...

 

Heres my not working code:

 

 

trigger HistoryOpportunityLineItemV001_test on OpportunityLineItem (after insert, after update, before delete) {

// Get the sObject describe result for the Opportunity object
Schema.DescribeSObjectResult r = OpportunityLineItem.sObjectType.getDescribe();
//Generate a Map of the fields
Map<String, Schema.SObjectField> M = r.fields.getMap();

//Now loop through the list of Fields
for (Object fieldName : M.keySet()){
//system.debug('fieldName: ' + fieldName);
if(Trigger.old[0].fieldName.value != Trigger.new[0].FieldName.value) {
System.debug('CHANGED fieldName/fieldValue: ' + fieldName + ' / ' + FieldName.value);
}

}
}

 

 



Any ideas?

 

Thx,

jup

 

 

Message Edited by juppinger on 03-24-2009 03:29 AM
Message Edited by juppinger on 03-24-2009 03:30 AM

HI,

I have written one after update trigger on Opportunity standard object, which will update one field in Contact Object. But this trigger is getting fired twice.

 

Any idea on why the trigger is getting fired twice and how to resolve the problem?

 

Thanks in Advance,

Suvra

  • March 23, 2009
  • Like
  • 0