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

Hi Raj,

i tried below code it is working some modifications in your code.

<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>
		function myFunction() {
	//debugger;
		var check =gel("accept");
            if (check.checked) {              
                    var tableGr = new GlideRecord('sc_task');
                    tableGr.addQuery('sys_id', '3c711afe97740d10dd63732e6253af71');
                    tableGr.query();
                    if (tableGr.next()) {
                        tableGr.state = 3;
                        tableGr.update();
                    }
                }
            }
	</script>

Hi Anjaneyulu,

Thank you again.

 

I have tried in the same way, but still no luck. 

Note: I am trying it within the UI page(Jelly code)

Also, tried using <g:evaluate jelly="true"> instead of <script> tags, still no luck.

 

Thanks,

Raj

--Raj

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