locked
How to find opportunity is opened or closed? RRS feed

  • Question

  • Hi,

    Now how can I find in form's load event if the opportunity is open or closed?

    When I am going to read the statecode attribute value for any opportunity in form's load event to ascertain the state of opportunity if it is open or closed, it appears to be undefined.

    This link details the values for statecode. Howerver this link says it is not valid for create or update.


    Paradise lies at the feet of thy mother. - Prophet Mohammed (PBUH)
    Wednesday, February 9, 2011 6:21 AM

Answers

  • Hi Ali,

        You can use Javascript for the same and store it in variable as:

       function getStatus()

       {

        var status=crmForm.all.statecode.DataValue;

        alert(status);

        }

       You ll get  the desired output.U ll get the value.Then u have to check the statuscode field and set it accordingly in the javascript like,

     if(status==1){ Opportunity Status="Open";} and so on.

     


    Bilal Sayed.
    Wednesday, February 9, 2011 1:39 PM

All replies

  • Hello Ali.

    You can try to use following code:

    var oStatus = document.all.EntityStatusText.innerText;

    alert(oStatus);


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Wednesday, February 9, 2011 6:57 AM
    Moderator
  • Hello Ali.

    You can try to use following code:

    var oStatus = document.all.EntityStatusText.innerText;

    alert(oStatus);


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)

    innertText is undefined. However EntityStatusText is of type DispHTMLElementCollection

    Paradise lies at the feet of thy mother. - Prophet Mohammed (PBUH)
    Wednesday, February 9, 2011 7:04 AM
  • I have found out one method of achieving the same.

    crmForm.all.statuscode.DataValue

    It would be from 1 to 5 for different status reasons.

    However, I got confused by reading this documentation, as it is saying value would be 1 for canceled opportunity, but practically it is showing 4 for the same.

    Thank you Andriy for being supportive every time :)

     


    Paradise lies at the feet of thy mother. - Prophet Mohammed (PBUH)
    Wednesday, February 9, 2011 7:08 AM
  • Don't be confused as this document is relating to MS CRM 1.2. Won and Lost Opportunities are closed.
    Regards Faisal
    Wednesday, February 9, 2011 1:03 PM
  • Oh. I c.

    Thx anyway.


    Paradise lies at the feet of thy mother. - Prophet Mohammed (PBUH)
    Wednesday, February 9, 2011 1:05 PM
  • Hi Ali,

        You can use Javascript for the same and store it in variable as:

       function getStatus()

       {

        var status=crmForm.all.statecode.DataValue;

        alert(status);

        }

       You ll get  the desired output.U ll get the value.Then u have to check the statuscode field and set it accordingly in the javascript like,

     if(status==1){ Opportunity Status="Open";} and so on.

     


    Bilal Sayed.
    Wednesday, February 9, 2011 1:39 PM