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 11:23 AM
Hello @YummyAmericano ,
Can you check the type of u_last_verify_date ? It should be date time field not only date field. As you are settling the date time value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2023 11:41 AM
The field 'u_last_verify_date' is of type (Date); this is the really the output I am looking for which is without the time.
However, I also have another field called 'u_last_verified_date' which is of type (Date/Time), for testing purposes as my script is not working. The script is not updating this field too.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2023 11:33 AM
Can you try below?
var gdt = new GlideDate();
supplierGR.u_last_verify_date = gdt.getValue();
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 11:42 AM
Thanks for the script but it is not updating the value as well.