How do I write a business rule to take the value in a field and populate it to the close notes field on an incident record

jimphelps
Tera Contributor

I have a requirement where I am needing to populate the incident close notes field with the value of a string field that was added to the approver form.  The incident is tied to another form that is being approved.  How do I write a business rule that will accomplish this?

5 REPLIES 5

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Jimphelps,

 

You can create an After business rule on Incident table and via script query the table "sysapproval_approver" based on the Approving field(document_id). There can be multiple approvers generated for each record. Please make sure to adjust your query as per your req.

Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi,

If i understood you correct. Then you want to copy a field value which is of string type on Approval form when approver has updated that Field to Close note field on Incident form.

If yes, then you have to write a After update BR on Approval table. With condition as String field changes or not empty.

 

In script you have to query Incident table as below:

var gr =new GlideRecord('incident');

gr.addQuery('sys_id',current.sysapproval);

gr.query();

if(gr.next())

{

gr.close_notes = current.string_field_name;

gr.update();

}

 

Thanks,

Ashutosh Munot

Please Hit Correct, Helpful,, if you are satisfied with this response.

Hi Ashutosh,

Thank you for the response.  To get a little more specific here is what I have for the requirements:

 

A user submits an incident on the incident table.  If it meets certain criteria they are directed to fill out a form called a Request Questionnaire on a new table I created called IT Request Questionnaire and that form has a reference field tying it back to the incident submitted.  This form then has to be approved.  On the approval form I created a new field titled Reason for Rejection that is mandatory and only shows if the approver rejects the form.  Whatever is written in this field on the approver form I need it to populate the close notes on the incident that the rejected form is tied to.  How do I write the business rule to dot walk through to these tables in order to do this for all of these fields?

 

Thank you for your help,

Jim

Hi Jim,

 

Thanks for the clarification.

 

Here can you tell me what you see in approving field or approval for field. Is it showing new table record or Incident record?


If incident then my previous script will work for you.

If new table record then we have to modify the script little bit.


Thanks,

Ashutosh Munot

Please Hit Correct, Helpful or like,if you are satisfied with this response.