Community

Identify responsible field behind triggering Field Rule

Hi All,

If I create a rule under any field and refer some fields under that rule, so generally the rule gets triggered whenever any field value gets changed under that rule.
But in rule script I am not able to identify the field because of the change in which the rule gets triggered. Please let me know how can I identify it.
Thanks in advance.

Regards,
Rahul

0

Comments

1 comment

  • Avatar
    Scott Chau

    Rahul,

     

    Put this script in the document-level event “After document rules are checked”  Create a field call "ErrorMessage"

    var strEM = "";
    var strSection = "";
    var strFullField = "";
    var strField = "";
    var strVal;

    for (i = 0; i < this.RuleErrors.Count; i++)
    {
    strFullField = this.RuleErrors.Item(i).GetFields(0).FullName;
    strSection = (strFullField.split("\\"))[0];
    strEM = "|" + (i + 1).toString() + "|" + strSection + "|" + this.RuleErrors.Item(i).GetFields(0).Caption + "|" + this.RuleErrors.Item(i).Message;
    strField = strSection + "\\ErrorMessage" + "\n";

    strVal = this.Field(strField).Value;
    if (strVal.length > 0)
    {
    this.Field(strField).Value += "\r" + strEM
    }
    else
    {
    this.Field(strField).Value += strEM;
    }
    }

     

    The field errormessage will list the rule error and what field it came from.

    0

Please sign in to leave a comment.