Validation on New Opportunity

Hello,

We have a custom field named "Type of Customer" on the Company Entity, however, we would like it so that it is not possible to create new opportunities for companies with a specific type of customer. I have used the existing validation in place to stop Opportunities getting created where Company Type is Supplier, however, this isn't working and we can still make opportunities regardless of the Type of Customer.

Please see the validation below:

var company = eWare.FindRecord('Company', 'comp_primaryaccountid='+Values('oppo_primaryaccountid'));
if(company.comp_c_typeofcustomer=='Type A')
{
Valid = false;
ErrorStr="You cannot create an opportunity for a company with Type A";
};

This has been added to the 'Validate Script' for the oppo_primarycompanyid. I'm not sure on what I may be doing wrong as to why it isn't working, please does anyone have any suggestions?

CRM Version: Sage 200 CRM 2018 R3.3

Kind Regards,

Jamie

Parents
  • 0

    Use oppo_primarycompanyid. You could use the SQL filter on the tab but you'd need to add scripts in several places to stop them creating opportunities.

    This: if(company.comp_c_typeofcustomer=='Type A')

    You should be comparing the translation code which won't have a space in it. If the translation is Type A then the code might be TypeA but check in translations.

Reply
  • 0

    Use oppo_primarycompanyid. You could use the SQL filter on the tab but you'd need to add scripts in several places to stop them creating opportunities.

    This: if(company.comp_c_typeofcustomer=='Type A')

    You should be comparing the translation code which won't have a space in it. If the translation is Type A then the code might be TypeA but check in translations.

Children
No Data