- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 06:09 AM
Hello there,
We are taking a stab at automating our billing process and the approach we've taken is at the end of each service offering's workflow we place a 'Run Script' activity that will generate a line item in our billing repository table. We are doing that as such:
// Initialize a record into the Billing Repository.
var bill = new GlideRecord('u_enterprise_billing_repository');
bill.initialize();
bill.u_record_number = current.sys_id;
bill.u_customer_id = current.variables.u_username.user_name;
bill.u_customer_name = current.variables.u_username.first_name + ' ' + current.variables.u_username.last_name ;
bill.u_service_item = 'JVPN(' + current.variables.u_username.user_name + ')';
bill.u_service_code = 'JVPN';
bill.u_action = 'Add';
bill.u_speed_chart = current.variables.u_speedchart;
bill.insert();
And that insert is working great with no issues. However, on this table we have two business rules that are set to 'Before' an 'Insert/Update' that go query the record number (in our case a RITM number) and then pull it's closed date to populate a field and then another BR to calculate when we are going to bill based upon that date - before the 15th, the first of the current month & after the 15th, the beginning of the next month.
These business rules work great upon a manual insert or a manual update of records into the table;however, they are not working / triggered upon the initial creation of the record using the scripted activity inside the workflow of the catalog item.
Anyone have any ideas on this? Am I going to have to instead take these scripts and make them a scheduled job?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 08:49 AM
Ended up using a Scheduled Job and that fixed the issue since the billing records were being created in the workflow and technically the parentrecords had not closed yet. Thanks all for the suggestions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 07:51 AM
The issue was that the BR was triggered before the actual record had time to close and was pulling back empty data. I'm going to have to populate the current system time into the field in the scripted activity... order matters... lol.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 08:49 AM
Ended up using a Scheduled Job and that fixed the issue since the billing records were being created in the workflow and technically the parentrecords had not closed yet. Thanks all for the suggestions.