Help: Business Rule is not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2023 11:13 AM
Developers,
I am seeking guidance on resolving an issue that is currently impeding progress. In my scope application, I have implemented a Business Rule that validates supplier matches and creates/updates records accordingly. However, I have encountered a problem with a particular section of the script that fails to update the value in the Global. Specifically, it is unable to update the 'u_last_verified_date' field with today's date. This field is of the Date type. I would greatly appreciate your advice on how to rectify this issue. Thank you in advance.
Here is the BR script (part that is not working):
// Update 'u_last_verify_date' in 'u_current_sup' table in Global to today's date
// I tried this and it is not working
supplierGR.u_last_verify_date = gs.nowDateTime();
supplierGR.update();*/
// I tried this and it is not working
var today = new GlideDate();
supplierGR.u_last_verify_date = today;
supplierGR.update();
Here is the BR Script in the scope application:
(function executeRule(current, previous /*null when async*/ ) {
// Check if there is a matching supplier in 'u_current_sup'
var supplierGR = new GlideRecord('u_current_sup');
if (supplierGR.get('u_supplier_code', current.supplier_code)) {
// Reconcile for existing supplier code
var outputGR = new GlideRecord('x_new_sup');
outputGR.addQuery('supplier_code', current.supplier_code);
outputGR.query();
if (outputGR.next()) {
// Update existing record for reconciliation
// Bring over the status to the output table
outputGR.new_status = current.supplier_status; // copy over new active status
outputGR.current_status = supplierGR.u_active; // copy over current active status
outputGR.update();
} else {
// Create a new record for reconciliation
outputGR.initialize();
outputGR.supplier_code = current.supplier_code;
outputGR.supplier_name = current.supplier; //supplierGR.supplier;
outputGR.new_status = current.supplier_status;
outputGR.current_status = supplierGR.u_active;
outputGR.insert();
}
// Update 'u_last_verify_date' in 'u_current_sup' table in Global to today's date
/*supplierGR.u_last_verify_date = gs.nowDateTime();
supplierGR.update();*/
var today = new GlideDate();
supplierGR.u_last_verify_date = today;
supplierGR.update();
} else {
// Reconcile for new supplier code
var newSupplierOutputGR = new GlideRecord('x_new_sup');
newSupplierOutputGR.initialize();
newSupplierOutputGR.supplier_name = current.supplier;
newSupplierOutputGR.supplier_code = current.supplier_code;
newSupplierOutputGR.new_status = current.supplier_status;
newSupplierOutputGR.current_status = current.supplier_status; // Assuming 'u_supplier_status' for new suppliers
newSupplierOutputGR.new_supplier = true; // set new supplier to true
newSupplierOutputGR.insert();
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2023 12:57 PM
Can you try
gd.getDisplayValueInternal()
So try with below code
var gdt = new GlideDate();
supplierGR.u_last_verify_date = gdt.getDisplayValueInternal();
supplierGR.update();
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2023 01:03 PM
Thanks again. The script is not updating the field as well.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2023 11:36 AM
Is there any other issue with your script?
I have tested this and seems fine to me.
var gdt = new GlideDate();
supplierGR.u_last_verify_date = gdt.getDisplayValueInternal();
supplierGR.update();
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2023 11:44 AM
The script is working, based on the gs.info it logged the Date/Time just not updating the value in the Global table.
I actually solved the issue about an hour ago. I copied the script and ran it from the Global applications.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2023 12:07 PM
@YummyAmericano : As you are trying to update the table field in global scope from the scoped application, could you check if the table allows CRUD operations from different scopes? This can be checked from the table configuration. If that's not the case, could you try with the below code?
var gdt = new GlideDateTime();
supplierGR.u_last_verify_date = gdt.getDate();
supplierGR.update();
Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.