Need to make assigned to as mandatory after Assignment group changes saved on the incident

Deepika61
Tera Contributor

Hi All,

 

Actually we have requirement that whenever if we change state to WIP and assignment group changes and save the incident form then assigned to make mandatory, while making changes to group , assigned to not mandatory after saved only it makes mandatory

 

Please give me suggestions on this

 

Thanks

Deepika

9 REPLIES 9

Rajesh Chopade1
Mega Sage

HI @Deepika61 

If you want the Assigned To field to become mandatory only after the incident is updated (i.e., after saving the record), rather than immediately when the State or Assignment Group changes, you'll need to rely more on Business Rules than UI Policies.

 

Create a Business Rule to check when the State is set to "WIP" and the Assignment Group changes, and make the Assigned To field mandatory after the record is updated.

 

Create 'After Update' BR with conditions 

current.state == 'WIP' && current.assignment_group != previous.assignment_group

 

I hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.

thank you

Rajesh

 

Hi @Rajesh Chopade1 

Thanks for the response, Actually i tried this approach, but in business rule i guess we are not make m,andatory, right?

 

 

Hi @Deepika61 

You're absolutely right! In a Business Rule, you can't directly make a field mandatory. The mandatory behavior is something that is controlled via UI policies and UI Policy Actions, not Business Rules.

 

Business Rule should be used for the validation logic: You can check if Assigned To is filled when the State is WIP and the Assignment Group has changed. If the Assigned To field is not filled, you can show an error message or prevent the record from being saved

 

UI Policy should be used to control the mandatory property of the field based on the conditions.

 

Create a new UI Policy for the Incident table.

  • Set Conditions to check if:
    • State is WIP.
    • Assignment group is changed.
  • In the UI Policy actions, set the Assigned To field to Mandatory = False (this will make the field optional when editing the record).

Create Before Update BR with Condition:

Check if STATE is "WIP" and Assignment group has changed.

Script: Check if Assigned To is empty and prevent save if necessary.

if (current.state == 'WIP' && current.assignment_group.changes()) {
    if (!current.assigned_to) {
        gs.addErrorMessage('Assigned To must be filled when State is WIP and Assignment Group is changed.');
        current.setAbortAction(true); // Prevent save if Assigned To is empty
    }
}

 

I hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.

thank you

Rajesh

 

 

Ankur Bawiskar
Tera Patron
Tera Patron

@Deepika61 

you can use UI policy or onChange client script.

what did you start with and where are you stuck?

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader