- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Hi Team,
A simple GlideRecord code is taking infinity time to insert a new record into a custom table
I gave the sufficient role to logged in user to validate the create ACL but no luck
any idea on this ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
It could also have to do with Business rules on that table.
Can be tested by deactivating BRs on insert
var newRecordGR = new GlideRecord('table_name');
newRecordGR.newRecord();
newRecordGR.setValue('field_name', 'value');
newRecordGR.setWorkflow(false); //Disables running BRs when inserting the record
newRecordGR.insert();
If theres alot of BRs running, doing all kinds of weird stuff it might increase the time it takes overall
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Did you try creating the record manually with only the field used in gliderecord code and whether it is allowing to create the record ?
Check whether there are any Business Rules or UI Policy that is validating for mandatory fields and not allowing to create the record. Check if the role has necessary permissions in the custom table to create the record. You can check the system logs to check for any errors and troubleshoot what is causing this behavior.
If this helped to answer your query, please mark it helpful & accept the solution.
Thanks,
Bhuvan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
It could also have to do with Business rules on that table.
Can be tested by deactivating BRs on insert
var newRecordGR = new GlideRecord('table_name');
newRecordGR.newRecord();
newRecordGR.setValue('field_name', 'value');
newRecordGR.setWorkflow(false); //Disables running BRs when inserting the record
newRecordGR.insert();
If theres alot of BRs running, doing all kinds of weird stuff it might increase the time it takes overall
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
do you also have .initiliaze()?
And for the creation, are all mandatory fields populated?
Is it a BR? perhaps setWorkflow(false)?
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Using setWorkflow(false)
and initialize()
resolved the issue. I am, however, curious to understand why they were necessary in this case, as I typically do not include them in my code unless explicitly required.
Best regards,
Bishal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Hi @bishalsharm
You need to be very aware when using setWorkflow(false) because it will skip ALL logic running in Business rules - everything from event being triggered, checks and what not. - this can have major implications to the process and other functionalities for that table potentially impact other tables as well.
You need to analyze what is going on with the Business rules and eventually figure out whats causing it because its not only when creating a record from a GR but when users interact with ServiceNow triggering a record in that table.
I dont know if you are able to somewhat reproduce it when you create a record from the UI as that would also trigger the BRs to run.
You can active Debug Business rules to see if you can spot "slow business rules".
Else you can create a couple of BRs running in different order (10, 100, 1000, 10000) triggering a log entry when creating a record to get an idea of when the given "slow" BR is executed - to narrow down which BR could cause it.
But its hard for me at this point to assist in this as I have no insight of the setup or whats going on and if its intended in any way.
Regards.