Script to display Sub status based on status

XYZ
Tera Contributor

Hello Community,

 

I'm looking for a script which will change sub status of incident form to "permanently resolved" if status is resolved.I wrote one script for the same on change of "status" field in incident form.

This below code is actually displaying the back end value first which is 8 and then changes to its display value within a microsecond to  display value-"permanently resolved". Please help someone to correct this code and suggest me some solutions.

 

var status=g_form.getValue('state');

if(status=='6')

g_form.setValue('hold_reason', '8');

 

 

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hello @XYZ,

 

Requirement indicates that you want to set the value for sub-status as “permanently resolved", If the state is “Resolved”.

 

  1. Write onChange client script as follows : 
  2. Table : Incident
  3. Type : OnChange
  4. Field name : State 
  5. Script :

 

 function onChange(control, oldValue, newValue, isLoading, isTemplate) {

   if (isLoading || newValue === '') {

      return;

   }

if(newValue == '6'){// Checking Value of state

    g_form.setValue('u_sub_status','5') // Setting Value of Sub status as Permanently Resolved i.e. 5

}   

}

Refer below screenshot for result :
client scirpt.png

View solution in original post

3 REPLIES 3

Harshal Aditya
Mega Sage
Mega Sage

Hi ,

 

OOB hold_reason field is visible only if the state is resolved. I guess you have modified this behaviour.

If that's the case the script seems fine to me. Could you please check the backend value of permanently resolved choice ?

 

If my answer has helped with your question, please mark it as helpful and give it a thumbs up!

Regards,
Harshal

Community Alums
Not applicable

Hello @XYZ,

 

Requirement indicates that you want to set the value for sub-status as “permanently resolved", If the state is “Resolved”.

 

  1. Write onChange client script as follows : 
  2. Table : Incident
  3. Type : OnChange
  4. Field name : State 
  5. Script :

 

 function onChange(control, oldValue, newValue, isLoading, isTemplate) {

   if (isLoading || newValue === '') {

      return;

   }

if(newValue == '6'){// Checking Value of state

    g_form.setValue('u_sub_status','5') // Setting Value of Sub status as Permanently Resolved i.e. 5

}   

}

Refer below screenshot for result :
client scirpt.png

Community Alums
Not applicable

Hello @XYZ,

 

Requirement indicates that you want to set the value for sub-status as “permanently resolved", If the state is “Resolved”.

 

  1. Write onChange client script as follows : 
  2. Table : Incident
  3. Type : OnChange
  4. Field name : State 
  5. Script :

 

 function onChange(control, oldValue, newValue, isLoading, isTemplate) {

   if (isLoading || newValue === '') {

      return;

   }

if(newValue == '6'){// Checking Value of state

    g_form.setValue('u_sub_status','5') // Setting Value of Sub status as Permanently Resolved i.e. 5

}   

}

Refer below screenshot for result :
client scirpt.png