Prevent Save of Opportunity

This question is not answered

I am looking to create a field on the Company Entity that when you attempt to create an Opportunity for that Company it will not Save if this Company field equals a particular value... Seems simple enough but I have failed at all attempts

All Replies
  • you can use the validate event on the opportunity summary screen to define the validation

     

    Kannan Srinivasan

  • I appreciate your response. I am fairly new to Sage CRM administration and development. Would you be able to provide an example... I think I know where you are going with this, but we are going live 1/1/2018 and there is so much more that needs my attention having an example would cut down on my trail and error time. Thank you either way!

  • In the example below I have added a field to the company called "comp_myfield".  This is a selection list and may be null or may contain a value such as 'Orange' or 'Banana'.

    If the comp_myfield value is 'Banana' I don't want to allow Opportunities to be saved against the company.

    To do this I can go to the OpportunityDetailBox screen in the

    Admininstration > Customisation > Opportunity area.

    I can add the following Validate script to the field oppo_description or another of the other fields.

    The script will look like this

    var myfield = CRM.GetContextInfo("company","comp_myfield")

    if (myfield == "Banana")

    {

    Valid = false;

    ErrorStr = "You may not save opportunities against a company with the status 'Banana'".

    }


  • Thank you Mr. Richards

    var myfield = CRM.GetContextInfo("company","comp_myfield")

    was the piece that would have been the piece that took me a bit to figure out... Thanks again bud.