Make field mandatory if agent reject the request using ask for approval action

KapileshS
Tera Contributor

i have created a flow using flow designer in servicenow which has an action of ask for approval if request gets approved then using update record action i am updating the state field to resolved and if the request gets rejected then using update record action i am updating the state field to rejected now i am want that if request get rejected then first make the work notes fields mandatory and user get a info message - work note field is mandatory. Then when user add the reason then request get rejected

i am updating the request value to rejected using list editor (means double clicking on the column and select rejected and click green tick) in the approval table which is the related table below the form


So my query is - how i can make the work notes fields mandatory and user get a info message - work note field is mandatory. Then when user add the reason then request get rejected

3 REPLIES 3

Martin Friedel
Mega Sage

Hello, 

 

I am not sure it is possible. You can accomplish same by following these steps:

 

  1. Disable list edit to force user open an approval record
  2. Make comment mandatory when user rejecting approval
    • Create onChange Client Script for field 'State' on Approval table [sysapproval_approver]
    • If newValue = rejected, make field 'Comments' mandatory
  3. Copy comments to work notes of the record being rejected
    • Create Business Rule on Approval table [sysapproval_approver]
    • Advanced: true
    • Run async and on update
    • Condition: State changes to Rejected and Approval for.Task type is Request
      You can paste encoded query: stateCHANGESTOrejected^sysapproval.sys_class_name=sc_request^EQ
      eq.JPG
    • In the script take the record reference from 'Approval for' field (sysapproval) and copy last Approval comment to Request work notes and update the request.

Are you able to accomplish it with your knowledge or you need to provide exact configuration and scripts?

 

If my answer helped you, please mark it as correct and helpful, thank you 👍
Martin

Singha8
Tera Expert

Hi @KapileshS,

 

You can make the work notes field mandatory when the request is rejected by using a client Script or a UI policy.

 

By using UI policy:

  1. Go to System UI - UI policies and click NEW.
  2. Set the table to your request table.
  3. Set the condition to state is Rejected.
  4. In the Ui policy Actions, choose Work notes - Mandatory : True and save it.

By using Client Script:

 

  1. Go to System Definition - Client Scripts and click New.
  2. Set the Table.
  3. Choose Type : onChange and select state field.
  4. Use the given script:

 

Singha8_0-1740042398106.png

 

If my answer helped you, please mark it as correct and helpful,

Thank you,

Ananya. 

Singha8
Tera Expert

Hi @KapileshS,

 

You can make the work notes field mandatory when the request is rejected by using a client Script or a UI policy.

 

By using UI policy:

  1. Go to System UI - UI policies and click NEW.
  2. Set the table to your request table.
  3. Set the condition to state is Rejected.
  4. In the Ui policy Actions, choose Work notes - Mandatory : True and save it.

Singha8_0-1740045784085.pngSingha8_1-1740045833183.png

 

If my answer helped you, please mark it as correct and helpful,

Thank you,

Ananya.