locked
Prevent Closing Opportunity - Part II - How to inquire about the closing end state? RRS feed

  • Question

  • Hi all,

    I just finished reading a previous post inquiring about how to perform some validation in response to an opportunity closing. Great post under the same title of this one. The main thing I learned and applied from the previous discussion, is to script the ONSAVE event of the opportunity close and inquire for the event code in order to identify if the opportunity is actually being 'closed' or just saved.

    Event code 5 gives us that answer and by checking that particular code ot works wonderful to check other fields or conditions in order to validate the 'closing' to see if it should proceed or no then the javascript can return success or not to allow or abort the save.

    The problem (serious) that I have is that I don't want to perform the opportunity validations if it is closing because a LOSS. I only want to perform the field validations if it is a WIN. However I don't know how to query for the fields in the close dialog to see if the user has selected win or loss at the time of the onsave script. It looks like onsave only have the fields in the main opportunity form available. I cannot find how to reference the 'closing' state, neither the closing status reason nor the closing actual value.

    I need to check for example that no user is closing an opportunity as a 'win' but with zero actual or estimated value. Also if it was a loss, i may need to check the lost reason to perform some other validation or to display a warning to the user.

    Anyone can direct me on how to check if it is win or loss in the corresponding onsave javascript?

    Thanks all in advance!

    mrbello


    Here's the link to the previous post for everyone's reference: http://social.microsoft.com/Forums/en/crmdevelopment/thread/69967700-d4a8-43d5-bb6e-b46fd670200f

     

    • Edited by mrbello Sunday, June 20, 2010 5:52 AM Added link to previous post
    Sunday, June 20, 2010 5:50 AM

Answers

All replies

  • Hi.

    You should try to check following properties in OnSave event handler:

    crmFormSubmit.crActivityXml
    crmFormSubmit.crNewStatus
    crmFormSubmit.crNewState

    Check this article .


    Truth is opened the prepared mind

    My blog (english)
    Мой блог (русскоязычный)
    • Proposed as answer by Blake ScarlavaiMVP Sunday, June 20, 2010 3:58 PM
    • Marked as answer by mrbello Sunday, June 20, 2010 4:02 PM
    Sunday, June 20, 2010 7:25 AM
    Moderator
  • Andriy thanks so much! you hit exactly the answer. The informaiton gives me what I needed now I can validate correctly.

    You have been incredibly helpful. I think this will be of great use for many others. I'll link the thread that I referenced to this one. and to your blog.

    Thanks again!!

     


    mrbello
    Sunday, June 20, 2010 4:07 PM