CA Service Management

 View Only
  • 1.  alert banner on checkbox

    Posted Dec 04, 2017 10:25 AM

    Greetings,


    We need to customize the employee detail_in.htmpl form to add myfunction alert message on click on checkbox.

     

    I tried below methods but the popup is coming but the value is not storring in databse that is 1 if checked and if unchecked 0, no values are storing 

     

    <PDM_MACRO name=dtlCheckbox hdr="Business Critical" attr="zbuscrit" evt="onClick='myFunction(this.value)'">

    I have also tried another one. but the result is same. no values are storing in database

    <PDM_MACRO name=dtlCheckbox hdr="Business Critical" attr="zbuscrit" evt="onclick=\\\"myFunction(this.value)\\\"">

    and if I remove the "evt="onClick='myFunction(this.value)'" then the values are storing in database.

     

    function myFunction(v)
    {
    if (v == 1)
    {
    alert("You checked that interruption is Business Critical. If both selected, Your Incident ID is IN"+ $args.ref_num);
    }

    }

     

    Any guidance or help are highly appreciated.

     

    Thanks

    Mayur



  • 2.  Re: alert banner on checkbox

    Broadcom Employee
    Posted Dec 04, 2017 11:10 AM

    what if you add "off=No on=Yes", assuming zbuscrit is bool? that is

    <PDM_MACRO name=dtlCheckbox hdr="Business Critical" attr="zbuscrit" evt="onClick='myFunction(this.value)'" off=No on=Yes>



  • 3.  Re: alert banner on checkbox

    Posted Dec 04, 2017 12:41 PM

    Thanks for the update, I will try this and we are using zbuscrit as integer and on new is 0.

     

    Thanks

    Mayur Malhotra



  • 4.  Re: alert banner on checkbox
    Best Answer

    Posted Dec 04, 2017 12:46 PM

    hi,

    visible checkbox is not used to publish data, actually there is hidden input which is used to pass values to server. Seems like alert(); interrupts hidden changes, so you need to change hidden input manually. Try this code:

    function zcbxclick(obj) {
         if (obj.checked == true) {
              jq("[name=SET." + jq(obj).attr("pdmqa") + "]").val(1);
              alertmsg('checking'); // Here is checking message
         } else {
              jq("[name=SET." + jq(obj).attr("pdmqa") + "]").val(0);
              alertmsg('unchecking'); // Here is unchecking message
         }
    }
    detailSetEventHandler("onclick='zcbxclick(this)'");
    <PDM_MACRO name=dtlCheckbox hdr="Business Critical" attr="zbuscrit">

     

    PS: I prefer to use dropdowns with initial empty value and force user to select between Yes or No, instead of showing alert that some checkbox is very important.

     

    Regards,

    cdtj



  • 5.  Re: alert banner on checkbox

    Posted Dec 05, 2017 05:17 AM

    Thanks cdtj :-) I had tried with dropdown option and it was working fine but the customer dont want drop rather they want check boxes.

    By using this code, our requirement has been fulfilled.

    Thanks

    Mayur