根据日期(非空验证)计算弓箭手GRC中的价值列表 [英] Calculation from Value-List in Archer GRC based on date (with non-empty validation)

查看:210
本文介绍了根据日期(非空验证)计算弓箭手GRC中的价值列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试实现这个Stack Overflow问题中的问题:



根据日期计算Archer GRC中的状态


尝试根据
用户选择的一些值列表创建一个状态字段,但是已经提出了一个请求,我们检查一个日期
字段以确保值估计日期已设定,以便
计算可以确定记录的状态是否为$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ / blockquote>

...现在,我有一个实际的弹出警告消息的要求,提示用户确保日期字段



如何添加此功能?

解决方案

为了提供您正在查看的功能g你必须使用自定义对象。在Archer中包含JavaScript代码的应用程序的布局是一个对象。一旦应用程序的形式加载,该代码将被执行。在Archer的应用程序生成器中的每个应用程序的Layout编辑器中都有一个特殊类型的自定义对象。



注意 - 我不建议一般使用自定义对象,也不使用RSA支持。每当您修改给定应用程序中的布局时,您都会重新测试,有时会为自定义对象添加正确的ID。您可以编写独立于ID的自定义对象并使用字段名称,但在这种情况下,自定义对象将具有更多的代码。我喜欢使自定义对象尽可能的简短。



您的自定义对象应该执行以下操作:


  1. 覆盖Archer中每个应用程序表格顶部工具栏中保存和应用按钮的行为。

  2. 保存和应用 按钮被覆盖,每次点击你的功能将被调用。所以您需要创建一个点击处理函数。

  3. 您的点击处理函数将检查用户是否需要填写并返回警告的值,否则将调用原始处理程序保存/应用 按钮。

这是一个代码模板,您可以从以下开始:

 < script type =text / javascript> 
// ids用于查找按钮
var buttons_ids = [
master_btnSave,//保存按钮ID
master_btnApply//应用按钮ID
];
//参数在onclick默认处理程序中用于调用原始处理程序
var buttons_parameters = [
master $ btnSave,//保存参数
master $ btnApply//Apply参数
];

document.getElementById(buttons_ids [0])。onclick = function(){Validator_of_required_fields(buttons_parameters [0])};
document.getElementById(buttons_ids [1])。onclick = function(){Validator_of_required_fields(buttons_parameters [1])};
//脚本体结束

// ==验证函数附加到保存和应用按钮
函数Validator_of_required_fields(参数){
// ids的输入字段来验证
var inputs_to_validate_ip_address = [master_DefaultContent_rts_XXX_YYY_t];

//这里使用jQuery选择器。 Archer v5.x具有默认加载的jQuery库
//您将需要修改此选择器
var field_value = $('#'+ inputs_to_validate_ip_address [0] +':first')。val() ;

if(field_value.length = 0){
//这里你调用的是Archer Warning函数
var msg =[Text to display to user]
var title ='必填字段';
WarningAlert(msg,title);
返回false;
};

//默认onclick处理器
ShowAnimationAndPostback(参数);
返回false;
};



对此代码的一些注释:




  • 您需要修改验证功能才能使用存储在所需字段中的值。

  • 我使用一个相当不寻常的方式来覆盖保存和应用按钮的行为,使用以下代码:

    document.getElementById(buttons_ids [0] ).onclick = function(){bla,bla,bla}
    有更简单的方法来做同样的事情,但是这种方式在IE8-11,FF,Chrome和Opera中可以正常工作。让我知道,如果你找到一个更简单的方法来覆盖浏览器不可知的按钮。

  • 功能 WarningAlert(msg,title); 一个内置的射手警告消息功能。它在Archer v5.4中工作得很好。如果WarningAlert在您的Archer版本中不起作用,则可能需要使用简单的JavaScript Alert功能。

  • 请注意,保存和应用按钮的行为可能会被覆盖回如果用户打开任何弹出对话框窗口来填充值列表或交叉引用字段,则为默认值。如果是这种情况,您将必须将提供的代码包装到另一个函数中,并将其附加到OnLoadWindow事件(或类似的)。

  • 我尽量避免在我的自定义对象。这样,支持它们就更简单,而且依赖性更低。我在所提供的例子中使用了jQuery,只因为在加载页面后,Archer已经使用了这个库。



Flak,确保测试你的自定义对象非常好,祝你好运!


I've been trying to implement what's been asked in this Stack Overflow question, here:

Calculation for status in Archer GRC based on date

Trying to create a status field based on a number of Value Lists that users select from, but a request has been made that we check a date field for a value to ensure an estimated date has been set so that the calculation can determine if the status of the record is "In Progress", "Late" or "Not Started".

...and now, I have a requirement for an actual popup warning message of some sort to prompt the user to make sure the date field is not blank.

How would I add this functionality?

解决方案

In order to deliver the functionality you are looking for you have to use a "Custom Object". It is an object you put on the layout of the application in Archer that contains JavaScript code. This code will be executed as soon as the form of the application is loaded. There is a special type of the field "Custom Object" available in the Layout editor for each application in the Application Builder in Archer.

Note - I don't recommend to use custom objects in general and neither RSA Support. Every time you modify the layout in the given application, you have retest and sometimes correct IDs for your custom object. You can write an ID independent custom object and use field names, but in this case custom object will have more code. I prefer to make custom objects as short as possible.

Your custom object should do the following:

  1. Override the behavior of the "Save" and "Apply" button in the top tool bar available for every application form in Archer.
  2. Once "Save" and "Apply" buttons are "overwritten", every time they are clicked on your function will be called. So you need to create a click handler function.
  3. Your click handler function will check values user is required to populate and will either return warning, or will call the original handler for "Save/Apply" buttons.

This is a code template you can start with:

<script type="text/javascript">
// ids are used to locate buttons
var buttons_ids = [
    "master_btnSave",   //  "Save" button ID
    "master_btnApply"   //  "Apply" button ID
];
// parameters are used in the "onclick" default handlers to call original handlers
var buttons_parameters = [
    "master$btnSave",   //  "Save" parameter
    "master$btnApply"   //  "Apply" parameter
];

document.getElementById(buttons_ids[0]).onclick = function(){   Validator_of_required_fields(buttons_parameters[0])};
document.getElementById(buttons_ids[1]).onclick = function(){   Validator_of_required_fields(buttons_parameters[1])};
// end of the script body

//==== Validator function attached to Save and Apply buttons
function Validator_of_required_fields(parameter){
    // ids of the input fields to validate
    var inputs_to_validate_ip_address = [ "master_DefaultContent_rts_XXX_YYY_t" ];

    // jQuery selector is used here. Archer v5.x has jQuery library loaded by default
    // you will need to modify this selector
    var field_value = $('#'+inputs_to_validate_ip_address[0]+':first').val();

    if(field_value.length = 0) {
        // Here you are calling Archer Warning function
        var msg = "[Text to display to user]";
        var title = 'Required Field';
        WarningAlert(msg,title);
        return false;
    };

    // default onclick processor
    ShowAnimationAndPostback(parameter);
    return false;
};

Some comments on this code:

  • You will need to modify the validation function to work with values stored in the fields you need.
  • I used a rather 'unusual' way to override the behavior of the "Save" and "Apply" buttons using the following code:
    document.getElementById(buttons_ids[0]).onclick = function(){ bla, bla, bla }
    There are simpler way to do the same, but this way custom object works fine in IE8-11, FF, Chrome and Opera. Let me know if you find a simpler way to override buttons that is browser agnostic.
  • Function WarningAlert(msg,title); is a build-in Archer warning message function. It worked fine in Archer v5.4. You might need to use simple JavaScript Alert function if WarningAlert doesn't work in your version of Archer.
  • Note that behavior of the "Save" and "Apply" buttons might be overwritten back to default in case if user opens up any pop-up dialog windows to populate a value list or cross-reference field. If that is the case, you will have to wrap the code provided into another function and attach it to the OnLoadWindow event (or similar).
  • I try to avoid using any JavaScript libraries in my custom objects. This way it is simpler to support them and you have less dependencies. I used jQuery in the provided example only because Archer already uses this library once the page is loaded.

Flak, make sure to test your custom object very well and good luck!

这篇关于根据日期(非空验证)计算弓箭手GRC中的价值列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆