Custom validation for unique custom field

好久不见. 提交于 2019-12-02 08:32:58

Let's say you want to validate the sic_code Field in the Accounts module.

Following example was tested in SuiteCRM 7.11.2 using the Extension framework.

Go create a file in the custom/Extension/modules/Accounts/Ext/Vardefs folder.

You can name the file sugarfield_sic_code.php.

Inside of the file add this example snippet:

  $dictionary['Account']['fields']['sic_code']['validation']= array (
  'type' => 'callback',
  'callback' => 'function(formname,nameIndex){alert("validating"+formname); return false;}',
);

Now make sure sic_code is inside the editview (duh) and when you click SAVE you will be shown the alert + an error message below the field (in red)

That is the overall idea.

If you need something more elaborated doing Ajax, some templating, there is a great answer here on SO (for sugarcrm but should work for Suite)

prevent duplicate value using ajax in sugar crm

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!