• NM
  • NEWBIE
  • 0 Points
  • Member since 2007

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 1
    Replies
Hi,
I need to populate a field value when a new Opportunity Patrner is created.
How can I use a trigger on this event?
When I use the following code, I get an error message:
ErrorError: Compile Error: SObject type does not allow triggers: OpportunityPartner at line 1 column 34

trigger GetPrimaryPartnerName on OpportunityPartner (after insert) {

Opportunity[] currOppt = trigger.new;

Account[] Accnt;

OpportunityPartner[] OppPartner;


OppPartner = [select AccountToId from OpportunityPartner where OpportunityId = :currOppt[0].Id AND IsPrimary = true];

Accnt = [select Id, Name from Account where Id = :OppPartner[0].AccountToId];

currOppt[0].Partner_Name__c = Accnt[0].Name;

}

 

Is there a solution for that?

Thank you,

Noa.

  • April 22, 2008
  • Like
  • 0
Hello,
I'm trying to write a trigger that takes the Opportunity Primary Partner name and populates it in a custome opportunity field.
 
I thought of writing an Opportunity before update trigger, but I realised this is not the right event. I changed the trigger to a Partner after insert trigger, but I got the message:
 
ErrorError: Compile Error: Incorrect SObject type: Partner should be Opportunity at line 1 column 1

I also tried to changed it to an OpportunityPartner trigger, but got the message:

ErrorError: Compile Error: SObject type does not allow triggers: OpportunityPartner at line 1 column 34
 
Does anyone have a way to implement this requirement?
Thank you :)
NM
  • April 14, 2008
  • Like
  • 0
Hello,
I'm trying to update an Account record by using an Opportunity "after update" trigger.
I want to update the Account record, which has the same id as the id of the Opportunity Account Name.
My code is as follows:
 
trigger changeAccountToActive on Opportunity (after update) {
Opportunity[] opp = trigger.new;
Account[] acct;

acct = [select id, Active__c from Account where id = :opp[0].Account.id];
//acct = [select id, Active__c from Account where Site = :opp[0].NextStep];
if (acct.size()>0)
{
  if (opp[0].status__c == 'Full Payment')
  {
  acct[0].Active__c = 'Yes';
  }
  update acct[0];
}
}
 
I used some debug printing code and I realised that the code doesn't get the lookup field value, but it does get the values of other fields. If I use the code in comments, where the "where" statement works on another opportunity field, it works...
 
Does anyone have an idea???
Thanks.


Message Edited by NM on 01-19-2008 10:57 PM

Message Edited by NM on 01-19-2008 11:00 PM
  • January 19, 2008
  • Like
  • 0
Hello,
I'm trying to update a field by s-control and then use the printAnything application. It doesn't work. It looks like it stops in the update request. The code is:
 
*****************************************************************************************************************
<script type="text/javascript" src="/soap/ajax/9.0/connection.js" > </script>
<script language=javascript>

var Invoice = new sforce.SObject("Invoice_Object__c");
Invoice.Id= "{!Invoice_Object__c.Id}";
Invoice.Name= "{!Invoice_Object__c.Name}";
Invoice.Amount__c= "{!Invoice_Object__c.Amount__c}";
if(sforce.connection.update([Invoice])[0].getBoolean("success"))
{
window.parent.location.href="{!URLFOR(
$SControl.PRINTANY__PrintAnythingDriver,Event.Id,
[packageId="InvoiceLines", invoiceId=Invoice_Object__c.Id, debug="1"])}";
}
else
{
alert("Problem Updating");
}
</script>
*****************************************************************************************************************
I hope someone has an idea...
Thank you.
  • December 11, 2007
  • Like
  • 0
Hello,
I'm trying to update an Account record by using an Opportunity "after update" trigger.
I want to update the Account record, which has the same id as the id of the Opportunity Account Name.
My code is as follows:
 
trigger changeAccountToActive on Opportunity (after update) {
Opportunity[] opp = trigger.new;
Account[] acct;

acct = [select id, Active__c from Account where id = :opp[0].Account.id];
//acct = [select id, Active__c from Account where Site = :opp[0].NextStep];
if (acct.size()>0)
{
  if (opp[0].status__c == 'Full Payment')
  {
  acct[0].Active__c = 'Yes';
  }
  update acct[0];
}
}
 
I used some debug printing code and I realised that the code doesn't get the lookup field value, but it does get the values of other fields. If I use the code in comments, where the "where" statement works on another opportunity field, it works...
 
Does anyone have an idea???
Thanks.


Message Edited by NM on 01-19-2008 10:57 PM

Message Edited by NM on 01-19-2008 11:00 PM
  • January 19, 2008
  • Like
  • 0