Sugarcrm支持产品指南糖开发人员糖开发人员指南11.0建筑学糖逻辑依赖行动setRequired.

setRequired.

概述

The SugarLogic setRequired. action, located in ./include/Expressions/Actions/SetRequiredAction.php, is used to determine if a field is required. 

执行

While the dependency metadata for your module can be defined in ./modules/<module>/metadata/dependencydefs.php and  ./custom/modules/<module>/metadata/dependencydef.php, it is recommended to use the 扩展框架 自定义库存模块以防止第三方插件与您的自定义相冲突。以下部分将演示如何实现只读依赖项。

setRequired参数

范围 类型 描述
目标 细绳 要做的字段的名称。
标签 细绳 此字段的标签元素的ID
价值 细绳 用于确定是否应要求该字段的公式。

有关依赖性定义中各种参数的更多信息,请参阅 依赖行动 documentation.

例子

For our example, we will create a dependency on the Cases module that will mark the resolution field as required when the status field is set to "Closed". Our example extension definition is shown below:

./custom/extension/modules/<module>/ ext/dependencies/required_resolution_dep.php.

<?php

$dependencies['Cases']['required_resolution_dep'] = array(
    'hooks' => array("edit"),
    'trigger' => 'true',
    'triggerFields' => array('status'),
    'onload' => true,
    //Actions is a list of actions to fire when the trigger is true
    'actions' => array(
        array(
            'name' => 'SetRequired',
            //The parameters passed in will depend on the action type set in 'name'
            'params' => array(
                'target' => 'resolution',
                'label' => 'resolution_label',
                'value' => 'equal($status, "Closed")',
            ),
        ),
    ),
);

有文件到位后,您需要导航到管理员> Repairs >并进行快速修复和重建。

笔记:重要的是,模块名称是复数(“案例”与“案例”)并且依赖于依赖项的名称,“必需_Resolution_dep”在此示例中是唯一的。

最后修改:2021-02-17 02:44:13