The CreatorCon Call for Content is officially open! Get started here.

How to make a Additional Comments field mandatory using UI policy?

Abdul Ahad
Kilo Contributor

I am new to Service Now. I have been assigned a task in which in the first step I need to create a UI action on an incident table and I have done it. The second step includes setting the additional comments mandatory on clicking the UI action and deliver a field message reading: "Please add additional information".

Kindly help me completing my SNOW task.

1 ACCEPTED SOLUTION

MrMuhammad
Giga Sage

Salam Abdul,

Your Question title and question description is contradicting. UI action and UI policy are two different things. So, I am going by question description and this is your code to make additional comments field mandatory and showing the field msg using UI action

Make sure client checkbox is "checked", action name is "mandatory_comments" & onClick is "reopen()"

//Client-side 'onclick' function

function reopen(){
   if(g_form.getValue('comments') == ''){
      //Remove any existing field message, set comments mandatory, and show a new field message

      g_form.setMandatory('comments', true);
      g_form.showFieldMsg('comments','Please add additional Information.','error');
      return false;  //Abort submission

   }

   //Call the UI Action and skip the 'onclick' function
   gsftSubmit(null, g_form.getFormElement(), 'mandatory_comments'); //MUST call the 'Action name' set in this UI Action
}

 

Please mark this correct & helpful if it answered your question.

Thanks & Regards,
Sharjeel

Regards,
Muhammad

View solution in original post

12 REPLIES 12

Hi,

If you are somehow storing the INC record on the parent field of REQ once REQ and RITM are created then you can use after insert BR on REQ and update the INC with that state

Regards
Ankur

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

Hi Ankur,

 

Do we have a sample of how that code would look like in BR?

Also, should we just remove the state update that is happening in the UI Action?

 

Regards,

Surabhi

Hi Ankur,

 

I managed to achieve this by using the glide function.

Thanks for the help.

Regards,

Surabhi