On UI Page: Upon selecting checkbox and clicking on Save button the SCTASK has to be close complete.

Raj_Esh
Kilo Sage
Kilo Sage

Hello Experts,

I am trying to develop, when a user selects the checkbox on UI Page and then clicks on the save button, the SCTASK of the RITM has to close complete.

The following code is not working. 

Defined 2 variables:

var ritm_available_checkbox = false;
var ritm_not_available_checkbox = false;

HTML tags

<td><input type="checkbox" id="accept" name="ritmAvailableCheckbox" value="yes"></input></td>
<td><input type="checkbox" name="ritm_not_available_checkbox"></input></td>

<button onclick="myFunction()">Save</button> 

<script>
            var check = ritm_available_checkbox;
            if (check.checked) {
                function myFunction() {
                    var tableGr = new GlideRecord('sc_task');
                    tableGr.addQuery('sys_id', 'xxxxxxxxxxxxxxxxx');
                    tableGr.query();
                    if (tableGr.next()) {
                        tableGr.state = 3;
                        tableGr.update();
                    }
                }
            }
 </script>
 
Any help on the code is much appreciated. 
 
Thanks,
Raj
--Raj
1 ACCEPTED SOLUTION

Raj_Esh
Kilo Sage
Kilo Sage

 

Thank you, @Logan Poynter and @Anjaneyulu Muvva for the inputs.

 

I moved the function to the client script and called it in HTML code.

It worked.

 

Thanks,

Raj

 

 

--Raj

View solution in original post

7 REPLIES 7

Logan Poynter
Mega Sage
Mega Sage
Your script var doesn't look right but I'm not at a computer to test. You're looking at "var check = ritm_available_checkbox" but the checkbox itself is ritmAvailableCheckbox. You've basically said "var check = false".

Hi Logan,

 

Thank you for your response.

 

We have defined it to test, but I have changed the value and tested, but no luck.

 

Thanks,

Raj

--Raj

Anjaneyulu Muv1
Tera Expert

Hi Raj,

 

Written script is correct it will update task status. but your not mapping check box value to variable.

 var check = ritmAvailableCheckbox;

use above code it will work

Hi Anjaneyulu,

 

Thank you for your response.

 

I was testing with multiple attempts and missed the paste proper variable. It did not work even if i declared as 

 var check = ritmAvailableCheckbox;

 

Thanks,

Raj

--Raj