I want to display pending reason custom filed on sc_task table based on state choices?

Shantharao
Kilo Sage

 

I had created one custom filed called "pending reason" on sc_task table 

As a requester fulfiller, I should be able to navigate through requested item >> Catalog Task

 Make sure that the catalog Task is either in Open or Work in Progress state. Move the Task to Pending State

 System should provide field - Pending Reason and will be required field for state = Pending

 Pending Reason should have following three option to Select 

    • Awaiting Requester
    • Awaiting Change
    • Awaiting Vendor

 

I have created below onChnage client script it works for state filed on change but after loading getting wrong results

How can I get oldValue & newValue of state choices on load client script?

/**

states are  1 - open

              2- work-in progess

            3- closed complete

           4- closed incomplete

          -5 - pending

          7 - closed skipped

**/ 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {

return;
}
if ((oldValue == "1" && newValue == "-5") || (oldValue == "2" && newValue == "-5")) {
g_form.setDisplay("u_pending_reason", true);
alert("state are 1 2 -5 onchange if loop");
} else if ((oldValue == "4" && newValue == "-5") || (oldValue == "3" && newValue == "-5") || (oldValue == "7" && newValue == "-5")) {
g_form.setDisplay("u_pending_reason", false);
alert("state are 3 4 7 -5 onchange else if loop");
}
else{ g_form.setDisplay("u_pending_reason", false);}
}

 

 

Initially I have to hide pending reason filed onload then

if I change the state changes from open to pending or Work in progress to pending

I have to show "pending reason" field

Rest all scenarios like state changes from closed complete to pending or closed incomplete to pending or closed skipped to pending 

I don't want to show pending reason filed 

 

If I created UI policy when task is created by default it is "open" state so pending reason is filed visible directly but my use case is when state changes from open to pending or Work in progress to pending

I have to show "pending reason" field

10 REPLIES 10

Sumit Pandey1
Kilo Guru
Kilo Guru

If you still need to do this with client script, try this.

Hope it should help you.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	if (isLoading || newValue === '') {
		g_form.setDisplay("u_pending_reason", false);
		return;
	}
	if ((oldValue == "1" && newValue == "-5") || (oldValue == "2" && newValue == "-5")) {
		g_form.setDisplay("u_pending_reason", true);
		alert("state are 1 2 -5 onchange if loop");
	} else if ((oldValue == "4" && newValue == "-5") || (oldValue == "3" && newValue == "-5") || (oldValue == "7" && newValue == "-5")) {
		g_form.setDisplay("u_pending_reason", false);
		alert("state are 3 4 7 -5 onchange else if loop");
	}
	else
	{ 
		g_form.setDisplay("u_pending_reason", false);
	}
}
//Type appropriate comment here, and begin script below

 

Please mark it correct, if I was able to help you.