Home     |     MS SQL Server    |     MS SharePoint    |     MS Visual Studio    |     MS Certifications    |     MS CRM     |     MS Office    |     MSF


Cervo Technologies
The Right Source to Outsource

microsoft.public.crm

Close Opportunity programmatically


Is it possible to close opportunity programmatically using callouts or client
script?

For example, if I will change the value of some field on the form and save
the changes, crm calls PostUpdate callout and depending on the the field
value close opportunity with different status.

Or, if I will use onSave() or onChange() events and close opportunity using
javascript.

What kind of code I should use? Should I create new Opportunity Close entity?

You can close opportunity in a PostUpdate callout by using one of the
following CRM service messages:

SetStateOpportunity
WinOpportunity
LoseOpportunity

The last two have an advantage of being able to add OpportunityClose entity
as part of the process.
See http://msdn2.microsoft.com/en-us/library/aa681604.aspx for all
Opportunity messages.

Since you will be updating the same entity the callout is for, there is a
danger of a loop. Be careful to add some flags to prevent looping as
mentioned in http://msdn2.microsoft.com/en-us/library/aa680676.aspx

Hope it helps
--
George Doubinski
CRM Certified Professional - Developer

"elena" <e@discussions.microsoft.com> wrote in message

news:7611842B-57B7-4097-99DF-8AF316D4D094@microsoft.com...

If it is on the same form. You can solve this better by using simple java
script for Onchage event of the field (the field where you are changing
value). As soon as you move out of the field the depending field
probability will take the new value as per your script. If you have more
conditions use switch-case than if-else.

What kind of script I should use?
I have tried any possibilities to close opportunity (callouts, onChange and
onSave events), but I could not find the right solution. When I use callouts
it looks like nothing happened with opportunity. When I try to use javascript
I get the error message.

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc