
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2017 06:02 AM
Hi All,
I have created one custom table A (which is not extending any table), and also I have created one another table B (which is extending task table).
Now when even a new record created on table A i want to create a new record on table B with reference fields values is table A's sys_id. I have tried to use the below script for creating new record, but no record is creating on the form.
gs.log("executing busines rule", "Swamy");
var gr = new GlideRecord('u_data_discovery_task');
gr.initialize();
gr.short_description = 'New incident 1';
gr.u_cloud_migrations = current.sys_id;
gr.insert();
When I used gr.initialize(), I could not see any record created on u_data_discovery_task table. So I have used gr.newRecord() instead of gr.initialize().
gs.log("executing busines rule", "Swamy");
var gr = new GlideRecord('u_data_discovery_task');
gr.newRecord();
gr.u_cloud_migrations = current.sys_id;
gr.short_description = "Please completed the application "+current.u_application_name.getDecryptedValue();
By using gr.newRecord() I am getting the sys_id of created record, But i could not see record created on u_data_discovery_task table. So I thought that record is not saving on the form. So I tried to update the record by giving gr.update() as shown in the below script, But no result.
gs.log("executing busines rule", "Swamy");
var gr = new GlideRecord('u_data_discovery_task');
gr.newRecord();
gr.u_cloud_migrations = current.sys_id;
gr.short_description = "Please completed the application "+current.u_application_name.getDecryptedValue();
gr.update();
All the time I am getting the log which i mentioned in the 1st line of the script.
Could anyone tell me what I am missing ? why my script is not working, why record is not creating ?.
Note : Initially I have created the Before, After business rule to create the new task record, when even i submitted the record on table A, the form is saving and not available for me. So i have created the async type business rule. I can see the there is no delay in saving the form. But backed record is not creating.
Thanks for your response,
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
-
Team Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2017 06:47 AM
There might be a business rule on 'u_data_discovery_task' which is aborting the insert. Use setWorkflow(false) and see if it works. If it works then you know who the culprit is. Use this code
var gr = new GlideRecord('u_data_discovery_task');
gr.newRecord();
gr.u_cloud_migrations = current.sys_id;
gr.short_description = "Please completed the application "+current.u_application_name.getDecryptedValue();
gr.setWorkflow(false);
gr.insert();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2017 06:27 AM
Hi Harish,
I am getting logs in all cases which i mentioned above.
Thanks,
Swamy.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2017 06:36 AM
Hi
There is nothing wrong in your script.
Run the below script in background script and try either record is inserting or not.
var gr = new GlideRecord('u_data_discovery_task');
gr.initialize();
gr.short_description = 'New incident 1';
gr.u_cloud_migrations = "Hard code some sys of here"
gr.insert();
Regards,
Harish Murikinati.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2017 06:47 AM
There might be a business rule on 'u_data_discovery_task' which is aborting the insert. Use setWorkflow(false) and see if it works. If it works then you know who the culprit is. Use this code
var gr = new GlideRecord('u_data_discovery_task');
gr.newRecord();
gr.u_cloud_migrations = current.sys_id;
gr.short_description = "Please completed the application "+current.u_application_name.getDecryptedValue();
gr.setWorkflow(false);
gr.insert();