CA Service Management

  • 1.  How to Prevent a Value to be Changed in HTMPL Form?

    Posted Mar 24, 2017 08:16 AM

    Hi Team,

     

    I want to set the value of a field through javascript. After setting the value, I want that the user cannot be able to change its value.

     

    When I am using the dtlTextbox, I am able to set its value (after binding it with attribute let's say zservicelevel) using the code:

    document.main_form.elements["SET.zservicelevel"].value="XYZ";

     

    But the disadvantage of this is that user can change its value on front end after it is set by javascript call.

     

    When I am using dtlReadonly field, I am not able to set its value using javascript like this:

    document.main_form.elements["SET.zservicelevel"].value="XYZ";

     

    So kindly provide a way in which I can set the value in dtlReadonly field or make the textfield to be in readonly mode.

     

    Thanks & Regards,

    Balram



  • 2.  Re: How to Prevent a Value to be Changed in HTMPL Form?
    Best Answer

    Posted Mar 24, 2017 12:07 PM

    Did you tried

    document.main_form.elements["SET.zservicelevel"].disabled=true;

    and

    document.main_form.elements["SET.zservicelevel"].readOnly=true;



  • 3.  Re: How to Prevent a Value to be Changed in HTMPL Form?

    Posted Mar 25, 2017 10:09 PM

    Little explanation about the difference of that attribute types:

    1. Readonly makes input Read Only as it should, nothing to add here;

    2. But disabled attributes are excluded from the form and then you submit it, disabled attributes will not be passed. It means if you have disabled attribute with some value for newly created object, this attribue will not be passed to object and it will left blank or will get schema default value. Disabling schema required attributes can cause AHD errors, so use this carefully.

     

    Regards,

    cdtj



  • 4.  Re: How to Prevent a Value to be Changed in HTMPL Form?

    Posted Mar 27, 2017 01:30 AM

    Hi Cdtj,

     

    Thanks for sharing this useful information.

     

    Regards,

    Balram



  • 5.  Re: How to Prevent a Value to be Changed in HTMPL Form?

    Posted Mar 27, 2017 01:29 AM

    Hi Gutis,

     

    Thanks for the solution. It is working.

     

    I set the readOnly property to be false every time the javascript function is called. After modification in the function, I set it again to true before the function returns.

     

    To prevent the user changing its value on form load, I set it to true in the onLoad method (provided out of box) of the form.

     

    Regards,

    Balram