locked
Detect click on Action menu( Click on Close Opportunity menu item ) in CRM RRS feed

  • Question

  • Hi,

    I wanted to check whether user has entered value in Sales Opportunity before closing it.

    If not then user should prompt to enter value in "Sales Opportunity" as he/she Click on Close Opportunity menuitem.

    Thanks in Advanced!!

    Plz help me

    Thursday, September 23, 2010 8:01 AM

Answers

  • you can show user alter based on the sample that is available at above URLs.

    1. check even.Mode

    2. Check if the field has value or not ( you can compare crmfield with null)

    if(crmForm.all.<fieldname>.DataValue==null)

    2. alert user

    3. event.returnValue = false; to cancel save event

    that's it

    Let me know if you need anything else


    Mahain : http://mahenderpal.wordpress.com
    • Proposed as answer by HIMBAPModerator Thursday, September 23, 2010 12:43 PM
    • Marked as answer by Jim Glass Jr Thursday, September 23, 2010 4:08 PM
    Thursday, September 23, 2010 12:43 PM
    Moderator

All replies

  • you can do this easily with JS code just you need to capture close opportunity event

    you can use event.Mode value in onsave event

    you can refer mypost http://mahenderpal.wordpress.com/2010/09/10/close-activity-event-in-ms-crm/

    for more inforamton on event.Mode http://msdn.microsoft.com/en-us/library/cc150868.aspx


    Mahain : http://mahenderpal.wordpress.com
    • Proposed as answer by HIMBAPModerator Thursday, September 23, 2010 8:11 AM
    Thursday, September 23, 2010 8:11 AM
    Moderator
  • Thanks !

    But I wanted to show javasript alert as user Click on close opportunity.

    Because when I do not put any thing in sales  Opportunity title which is [name ] in OpportunityBase table  and I closed the  Opportunity it showed me Microsoft Dynamic error . I goggle on it and I found that it should not be null if null then update name=' ' . 

    In my case I wanted to point out to user to that he has not enter the value  so enter the value in sales  Opportunity title and close .

     


     

    Thursday, September 23, 2010 12:34 PM
  • you can show user alter based on the sample that is available at above URLs.

    1. check even.Mode

    2. Check if the field has value or not ( you can compare crmfield with null)

    if(crmForm.all.<fieldname>.DataValue==null)

    2. alert user

    3. event.returnValue = false; to cancel save event

    that's it

    Let me know if you need anything else


    Mahain : http://mahenderpal.wordpress.com
    • Proposed as answer by HIMBAPModerator Thursday, September 23, 2010 12:43 PM
    • Marked as answer by Jim Glass Jr Thursday, September 23, 2010 4:08 PM
    Thursday, September 23, 2010 12:43 PM
    Moderator
  • Thanks sir!!  

    I have tried this code. But it not working.

    I wanted the process as below.

    user entered value in all fields except Sales Opportunity and closes the opportunity form. At that point user should prompt to enter the value in that field.

    but With out clicking on Save button if I trying to close the opportunity it is showing error.

    So that's why I wanted to check that particular field is empty or not  before clicking on close opportunity and without saving  i.e. as I click on action menu user should prompt to enter the value in that field.

    Is this possible?

    kindly reply

     

    Friday, September 24, 2010 7:48 AM
  • Did you follow the steps that I have mentioned,Could you please paste your code here ???
    Mahain : http://mahenderpal.wordpress.com
    Friday, September 24, 2010 7:58 AM
    Moderator
  • I have followed ur steps sir,

    This are given below:

    OnSave()

     

    if (event.Mode == 5)
    {

    var productcategory=crmForm.all.<field>.DataValue;

    if(productcategory==null || productcategory=="undefined")
    {

    alert("Enter value for the Sales Opportunity");
    event.returnValue = false;           
     return false;

    }

    }

    help me

     

    Friday, September 24, 2010 8:44 AM
  • if (event.Mode == 5)
    {

    var productcategory=crmForm.all.<field>.DataValue;  //you need to use actual crm field name here

    if(productcategory==null || productcategory=="undefined")
    {

    alert("Enter value for the Sales Opportunity");
    event.returnValue = false;           
     return false;

    }

    }


    Mahain : http://mahenderpal.wordpress.com
    Friday, September 24, 2010 9:01 AM
    Moderator
  • Sorry sir,

    I think I failed to explain u properly.

    I had put there actual field only. I put <field> for understanding purpose only.

    my code is as below:

    f (event.Mode == 5)
    {

    var productcategory=crmForm.all.new_productcategory. DataValue; 

    if(productcategory==null || productcategory=="undefined")
    {

    alert("Enter value for the Sales Opportunity");
    event.returnValue = false;           
     return false;

    }

    }

    Friday, September 24, 2010 9:15 AM
  • I just checked this code it's working fine for me , Please make sure you are publishing entity


    if(event.Mode==5)
    {
    if(crmForm.all.estimatedvalue.DataValue==null)
    {
    alert('hi');
    event.returnValue=false;
    crmForm.all.estimatedvalue.SetFocus();
    return;
    }
    }

     (also can't you make this field required ??, then there is no need to go this way )


    Mahain : http://mahenderpal.wordpress.com
    Friday, September 24, 2010 9:27 AM
    Moderator