• kingsix
  • NEWBIE
  • 0 Points
  • Member since 2011

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

Hello,

 

I wrote a trigger for Opportunity. I want to do 'When closed the Opportunity, close its Quotes automatically', but it didn't work. Please help to check the code, thanks!!

 

 

trigger QuoteClose on Opportunity(after insert, after update) {
Quote[] cList = new Quote[]{};
for(Opportunity opp : trigger.new)
{if (opp.StageName == 'Closed Won')
cList.add(new Quote(OpportunityId=opp.Id, Status = 'Close'));
}
if (cList != null && !cList.isEmpty())
Database.update(cList);
}

 

Hello,

 

I want to do the special  auto number for the quote.

 

Our opportunity's number is S0001, S0002, S0003................... something like this.

 

If the opportunity number is S0001, its quote auto number should be S0001-1, S0001-2, S0001-3

 

If the opportunity number is S0002, its quote auto number should be S0002-1, S0002-2, S0003-3

 

How can I do the quote auto number like this? Should I write some trigger?

 

Thanks for the help.

Hello,

 

I have a question about make quote with different currencies.

 

I have enabled the multi currencies in our org. (main currency is USD, second currency is EUR)

 

For example, I add product01 into the standard price book with USD price.

 

And then, I create an Account, Opporunity and Quote with EUR currency.  After that, I try to add the quote line item, but it's blank, I cannot find the product01 in it.

 

Should I create another product01 with EUR price?

 

So I should add double products in the future?

 

Is it right?

 

Thanks for the help.

 

 

Our salesforce is enterprise edition and my account's profile is system admin. I go to system write trigger & class everyday.

 

When I login system today, I cannot find 'create' & 'edit' button in the trigger page (also class page)!

 

It's so strange! What can I do to solve the problem??

There is a custom picklist field (payment__c) in Account, same as in Quote

 

Ok, if one people create an Account (also select one payment in it), and then create one opportunity, and then click 'add new Quote', the payment__c will be got automatically before save the quote (because it's same as Account's payment__C).

 

Is it possible? Anyone can tell me how to do it? Or will one trigger?

 

Thanks.

Hello, I wrote a trigger for prevent duplicate account name and group__C, it works well when I create a account in account page. But it shows a error info when I convert lead to account.

 

trigger test2 on Account (before insert, before update) {
   if (Trigger.new[0].Name != NULL)  {
       Account[] acc = [ select id from account WHERE name = :Trigger.new[0].Name and group__C=: trigger.new[0].group__C];
       if (acc.size() > 0) {
           Trigger.new[0].Name.addError('Name with Group already exists');
       }
   }
}

 

Anyone can help me? Thanks!

I got a error message with my Trigger. I just want to do, if Quote's status is ''Accepted', so Opportunity's stage change to 'Closed Won' automaticlly.

 

trigger test on Quote(after insert, after update) {
List<Opportunity> stageToUpdate = new List<Opportunity>();

for(Quote quo : trigger.new)
{if (quo.status == 'Accepted')
stageToUpdate.add(new Opportunity(Id=quo.Id, StageName = 'Closed Won'));
}
if (stageToUpdate != null && !stageToUpdate.isEmpty())
Database.update(stageToUpdate);
}

 

Error message,

execution of AfterUpdate caused by: System.TypeException: Invalid id value for this SObject type: 0Q09000000009qYCAQ: Trigger.test: line 6, column 38