when Assigned to changes from empty value then state should change to assigned state from open

anushadande1793
Tera Contributor

Hi 

 

Can anyone please help on the below query

 

Whenever Assigned to field changes from empty value then state field should automatically changes to Assigned state from open state. Can anyone please share scripting on how it can be achieved

 

Thank you

2 ACCEPTED SOLUTIONS

AndersBGS
Tera Patron

Hi @anushadande1793 ,

 

Instead of a client script as @nawalkishos  suggested, I would go for a business rule instead based on the informed requirement. If state should update in browser, then a client script would be the right approach. If state should change server side, then a business rule is the right approach. 

 

View solution in original post

Ankur Bawiskar
Tera Patron

@anushadande1793 

you can use before update BR on incident table

Condition: Assigned To changes AND Assigned to [IS NOT EMPTY]

Script:

current.state = '' ; // your state value here

If my response helped please mark it correct and close the thread so that it benefits future readers.

View solution in original post

3 REPLIES 3

nawalkishos
Kilo Sage

Hi @anushadande1793 ,

 

You need to create client script-

 

Type- onChange

field- assigned-to

 

and you need to write down the as shown below-

function onChange(control, oldValue, newValue, isLoading) {
  if (isLoading) {
    return; // don't run on form load
  }

  // If Assigned to changes from empty to a value
  if (!oldValue && newValue) {
    // Set state to Open (value 1)
    g_form.setValue('state', '1');
  }
}

 

please test and let me know.

 

If you found my response helpful, please mark it as helpful and accept it as the solution.

Thank you
Nawal Singh

AndersBGS
Tera Patron

Hi @anushadande1793 ,

 

Instead of a client script as @nawalkishos  suggested, I would go for a business rule instead based on the informed requirement. If state should update in browser, then a client script would be the right approach. If state should change server side, then a business rule is the right approach. 

 

Ankur Bawiskar
Tera Patron

@anushadande1793 

you can use before update BR on incident table

Condition: Assigned To changes AND Assigned to [IS NOT EMPTY]

Script:

current.state = '' ; // your state value here

If my response helped please mark it correct and close the thread so that it benefits future readers.