Help me with the script for below scenario

ARAVINDA11
Tera Contributor

@Ankur Bawiskar  @Community Alums  @Sohail Khilji  @Maik Skoddow 

 

Please help me with the script on attached sceenshot if budget number field & vendor account field value are equal the I need to mark the status value as Closed

 

please help me with the script please

ARAVINDA11_0-1716447619539.png

 

1 ACCEPTED SOLUTION

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @ARAVINDA11 ,

 

Create a before update or insert business rule

 

Condtion : 

if Budget number changes

or Vendor number changes.

 

Advance Script :

 

if (current.u_budget_number == current.vendor_account) {

current.status = 'success'; // set the field value here 

} 

☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@ARAVINDA11 

it's an easy one.

you can use before update/insert BR and write script

what did you start with and where are you stuck?

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

dgarad
Giga Sage

Hi @ARAVINDA11 

 try the below code.

var gr = new GlideRecord("tablename");
gr.addQuery("budgetnumberfield", 1);
gr.addQuery("vendor account field ", 1);
gr.query();
if (gr.next()) {
gr.status= 'closed';  // add bacend value of closed
gr.update();
}
If my answer finds you well, helpful, and related to the question asked. Please mark it as correct and helpful.

Thanks
dgarad

Community Alums
Not applicable

Hi @ARAVINDA11 ,

Please create Before Business Rule and select your appropriate table and check insert/updated as per your requirement and add below code 

 

var vendor = current.getValue('vendor');
var budget = current.getValue('budget');
if(vendor == budget){
	current.setValue('status', 'Closed');
}

 

Note: Please give the backend name of field for Vendor, Budget and Status.

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards 

Sarthak

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @ARAVINDA11 ,

 

Create a before update or insert business rule

 

Condtion : 

if Budget number changes

or Vendor number changes.

 

Advance Script :

 

if (current.u_budget_number == current.vendor_account) {

current.status = 'success'; // set the field value here 

} 

☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect