- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
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
yesterday
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
yesterday
is it taking long for all records?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Didn't get you when you said all records ?
It is taking long time and went on infinite loop when I am simply inserting record.
sample scriipt
var newRecordGR = new GlideRecord('table_name');
field1 = 'value';
newRecordGR.insert()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
how it behaves when you insert manually?
Also you are not using initialize() method?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @bishalsharm ,
sample insert code
var gr = new GlideRecord("table_name");
gr.initialize(); //or you can use newRecord() inplace of initialize()
gr.field_name = 'value'; //field_name is field on your table
gr.insert();
you need to use initialize() or newRecord() method on the GlideRecord object first and set the field values and use the insert() after the field are set
order
- initialize or newRecord
- set fields
- insert
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya