Community

Javascript Error in Script Rule

Hello,

In my document definition, I have individual checkmarks (NOT in a checkmark group) that are based on object collections in the corresponding FlexiLayout. The checkmarks represents boxes on the form where someone would put their signature and signature date. I created the object collection/checkmark to verify that ANYTHING has been written into these signature and signature date boxes.

I'm trying to create a script rule for the signature box that throws an error if either the signature or signature date checkboxes are NOT filled in when an insurance type of "Medicaid" is chosen in a checkmark group on top of the page. Here is the script rule code:

if (this.Field("grpInsuranceType").Field("chkMedicaid ").Value == true)
{
if ((this.Field("chkClientSign").Value = false)
|| (this.Field("chkClientSignDate").Value = false)
|| (this.Field("chkEmployeeSign").Value = false)
|| (this.Field("chkEmployeeSignDate").Value = false))
{
this.CheckSucceeded = false;
this.ErrorMessage = "Both the Client and Employee Signatures/Dates are required for Medicaid Patients!";
}
}

When I save the document definition and test it against a form example, I get the following error:

"Unable to modify a read-only field 'chkClientSign'

Can someone tell me why my script would result in this error?

Thanks,

Ben Holton

0

Comments

3 comments

  • Avatar
    Ben Holton
    Please disregard this last post. I failed to see that I was using the single = operator in the IF statement rather than the == operator. Duh!

    Ben

    0
  • Avatar
    Sushi
    Not sure if you also fixed the error ""Unable to modify a read-only field..." but just in case anyone else has this error, this is because you're trying to write the value to a field that is read only. Go back to the rule you created and make sure "Read Only" is deselected. By default this is enable.
    0
  • Avatar
    Ben Holton
    Hi Sushi,

    Just for the benefit of anyone else reading this thread, the problem was with the person controlling the keyboard.

    I used the single "=" operator in the IF statement, which in JavaScript means that you're trying to ASSIGN a value to that variable. This is why I received the "unable to modify a read-only field" error.

    What I should've used was the "==" operator, which compares the variable to the value to the right of the == operator. Once I did this, the error went away.

    Thanks!

    Ben Holton



    0

Please sign in to leave a comment.