State should be inprogress when assignment group is not empty and if i change state to onhold it is not updating.

Mallika4
Tera Contributor

Hello Developers!

My requirement is when assignment group is not empty then state should be change to in progress.

I wrote a client script code it is working fine. Here is the code

function onLoad() {
var assign = g_form.getValue('assignment_group');
var assignedto = g_form.getValue('assigned_to');
var state = g_form.getValue('state');
if(assign != '' || assignedto != '')
{
g_form.setValue('state','2');
}

But, the issue is when i change state to another state like on-hold, it is not updating to on-hold, it is still showing inprogress only.

So, please help me out on this issue.

Thank you!

1 ACCEPTED SOLUTION

Willem
Giga Sage
Giga Sage

Hi Mallika,

Create a business rule for this like below to do this. That way no scripting is needed:

find_real_file.png

 

find_real_file.png

 

This will set the State to 'In progress' when the Assigned to or Assignment group is not empty and the State is in New. For all other states ('closed'/'cancelled' etc) I assume you would not want to change the state. But of course you can change the conditions to your liking.

View solution in original post

6 REPLIES 6

If you want that happening on the screen and not just after save, can you create a new question for that? Next to this business rule you need some Client scripts. I know there is a lot of people who can help with that.

Kind regards,

Willem

Hi Malika,

If you want it happening on the screen when you change Assignment group or Assigned to, you need 2 client scripts:

The script in them is this:

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

   g_form.setValue('state', 2);//in progress
   
}

 

find_real_file.png

find_real_file.png