Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

After Business Rule Not Updating Records

Steven McCray1
Giga Guru

Desired Solution: I need a business rule to trigger on the core_company table to glide over to another table and update a value on that table. The matching condition is a value called the 'u_branchkey' which is a 3 digit number.

I've gone through the code a few times, tried a few different solutions but nothing seems to be successful in getting the action to function as expected.

find_real_file.png

 

I've confirmed in my testing, that the field 'u_branchkey' is accurate and exists on both the core_company and the u_agency_it_state_tracker tables. The value is 100 for both, so as far as I understand, the query should be going to the agency table, and finding what matches 100, then proceeding to update that record.

I've successfully been able to create/insert records on the table so I know the communication to the target table isn't hindered (we also have other processes that work and communicate with our agency table).

 

1 ACCEPTED SOLUTION

sachin_namjoshi
Kilo Patron
Kilo Patron

You don't need "==" in your business rule script.

Update your code like gr.addQuery('u_branchkey',current.u_bkey);

Also, i hope that this custom branch key field on company table is a reference field to your custom table in which you are updating records.

 

Regards,

Sachin

 

View solution in original post

7 REPLIES 7

sachin_namjoshi
Kilo Patron
Kilo Patron

You don't need "==" in your business rule script.

Update your code like gr.addQuery('u_branchkey',current.u_bkey);

Also, i hope that this custom branch key field on company table is a reference field to your custom table in which you are updating records.

 

Regards,

Sachin

 

The strangest thing is I actually had it in that format from the beginning but was trying a few different things out when it didn't work, guess I just had something else wrong at the time of setting that up.

 

It isn't a reference field though, it still worked.

Allen Andreas
Tera Patron

Hi,

As has been mentioned, it's a formatting issue.

Also, the screenshots were great, but please include the script in your post in the future and you can use the "Insert/Edit code sample" feature as well:

find_real_file.png

For the formatting of the GlideRecord query, here's documentation to look over as well: https://developer.servicenow.com/dev.do#!/reference/api/paris/server/no-namespace/c_GlideRecordScope...

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Ah ok I will remember that going forward, thank you!