作者:蘑菇雪雪_585 | 来源:互联网 | 2023-05-17 13:53
Ineedtocheckfieldphone_mobileforduplicateintodatabase.Iffieldvalueisnotaduplicateth
I need to check field phone_mobile
for duplicate into database. If field value is not a duplicate then continue saving. And if such phone already exists in database, then show the alert message and stop process(form submittion).
我需要在数据库中检查字段phone_mobile是否重复。如果字段值不是重复的,那么继续保存。如果这样的电话已经存在于数据库中,那么显示警报消息并停止进程(表单提交)。
My actions:
我的行为:
In the file ./modules/Contacts/metadata/editviewdefs.php
connected custom js file:
在文件中。/模块/联系人/ / editviewdefs元数据。php连接自定义js文件:
$viewdefs['Contacts']['EditView'] = array(
'templateMeta' => array(
'includes' => array (
array (
'file' => 'custom/include/Javascript/custom_contact.js'
),
),
'form'=>array(
...
Works great.
伟大的工作。
In custom_contact.js
file overload check_form(formname)
function:
在custom_contact。js文件重载check_form(formname)函数:
function check_form(formname)
{
if(formname === 'correct')
{
// This part does not work right for me
var _form = document.getElementById('EditView');
_form.action.value='Save';
SUGAR.ajaxUI.submitForm(_form);
return false;
}
if(formname === 'EditView')
{
// Ajax query works perfectly
$.ajax({
url : '/',
method : 'POST',
data : {},// some data
success : function(data) {
data = JSON.parse(data);
if(!data.success)
{
var text = 'The phone already exists';
return false;
}
check_form('correct');
}
});
}
return false;
}
But the if(formname === 'correct') ...
block does not work correctly.
但是if(formname === 'correct')…块不能正确工作。
I need to stop the work of the form_save and include when necessary.
我需要停止form_save的工作,并在必要时包含它。
Please help to solve the problem correctly.I'm new to SugarCRM.
请帮助正确地解决这个问题。我新到SugarCRM。
2 个解决方案