I want to display pending reason custom filed on sc_task table based on state choices?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2019 12:16 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2019 12:20 AM
Instead of Client Script, You should do it with UI Policy.
Write a UI Policy with conditions as state is pending, and then make Pending Reason Visible. Check the reverse if false field on ui form also.
Let me know if you face any challenges.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2019 12:56 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2019 12:30 AM
Hi,
What is your use case?
Because if i see your question it is straightforward that you need to make field pending reason visible only if the state is pending, right?
It can be easily done using Simple UI policy and no need of the Client script. UI policy will serve as Change script for you mark verse if false as true.
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2019 12:56 AM
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