How to set RITM state value from Client Script running on SC_TASK

kshaw
Giga Guru

I have a client script running on a sc_task. Script is onChange reacting to a choice variable that is Review Status.  (script  is shown below).

Intent of script is to get the value of the Review Status variable (4 choices: Under Review, Awaiting Client,  Awaiting Job Builder, and Completed) and then use the selected value to set the state on the requested_item from the catalog task. Based on the alerts, I am going to the correct switch elements but the RITM state is not being updated.

Possibly guessing that using g_form.SetValue('request_item.state', 'XX') is not working and maybe I need glide record but I am not sure.

Please help with correct coding to do this.

Thanks

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    var status = g_form.getValue('comp_reviewStatus');
	alert("The selected reveiw status is " + status);
    switch (status) {
        case "under_review":
            //g_form.setValue('state', '2');
			g_form.setValue('request_item.state', '2');
			alert("On the Under Review branch");
            break;
        case "awaiting_client":
            //g_form.setValue('state', 'Awaiting Client');
			g_form.setValue('request_item.state', '5');
			alert("On the Awaiting Client branch");
            break;
        case "job_builder":
            //g_form.setValue('state', 'Awaiting Job Builder');
			g_form.setValue('request_item.state', '22');
			alert("On the Awaiting Job Builder branch");
            break;
        case "completed":
            //g_form.setValue('state', '2');
			g_form.setValue('request_item.state', '2');
			alert("On the Completed branch");
            break;
    }
}

 

5 REPLIES 5

Amelia5634
Tera Contributor

Thanks for sharing or Organic Chicory Syrup great ideas and i really appreciate it.