- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2022 02:08 AM
copy related list of existing record to new record using client side UI action.
I have a below ui action code implemented to create a copy of existing record. Now I want related list of my orginial record should get copied to newly created record using ui action.
function showQuickForm(){
//Get the table name and sys_id of the record
var tableName = g_form.getTableName();
var sysID = g_form.getUniqueValue();
var desc = g_form.getValue('description');
//Create and open the dialog form
var dialog = new GlideDialogForm('Update incident', tableName); //Provide dialog title and table name
dialog.setSysID(-1); //Pass in sys_id to edit existing record, -1 to create new record
dialog.addParm('sysparm_view', 'Default view'); //Specify a form view
dialog.addParm('sysparm_form_only', 'true'); //Add or remove related lists
dialog.setLoadCallback(function(iframeDoc) {
// To get the iframe: document.defaultView in non-IE, document.parentWindow in IE
var dialogFrame = 'defaultView' in iframeDoc ? iframeDoc.defaultView : iframeDoc.parentWindow;
dialogFrame.g_form.setValue('description', desc);
dialogFrame = null;
});
dialog.render(); //Open the dialog
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2022 09:12 PM
Below mentioned is how I achieved this:
( just described in short - business use case create a copy of parent record which can be used as a starting point for new record instead of filling every details from scratch on new form as well as with its associated related lists)
GLideAjax don't work over here though UI action is client callable because there is no other way stop at ---> dialog.render() until form is submitted.
Without submitting form, and if you write/have any code after dialog.render() method it executes immediately.
Instead of building normal ui action + business rule I could simply create a copy with changing pre-filled random name just to distinguish records .
What I used is GlideModalForm as shown above in code which pops-up on click of ui action will all fields pre-filled except name and gives ability to for end-user to give its own name and by submitting a copy of record will be created.
Since, record is going to be inserted in table on submit of form, I used after Business Rule to copy related list content from parent record to new record which will be inserting.
🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2022 10:31 PM
Hi Harshal,
Is there any business reason for using UI action for related list migration? You can achieve this using Async BR as soon as your new record is created via UI Action. Will that not work in this case?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2022 08:56 PM
Yes, There was business reason for using UI action. With above mentioned code I basically duplicated a record (business use case create a copy of parent record which can be used as a starting point for new record instead of filling every details from scratch on new form as well as with its associated related lists)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2022 09:12 PM
Below mentioned is how I achieved this:
( just described in short - business use case create a copy of parent record which can be used as a starting point for new record instead of filling every details from scratch on new form as well as with its associated related lists)
GLideAjax don't work over here though UI action is client callable because there is no other way stop at ---> dialog.render() until form is submitted.
Without submitting form, and if you write/have any code after dialog.render() method it executes immediately.
Instead of building normal ui action + business rule I could simply create a copy with changing pre-filled random name just to distinguish records .
What I used is GlideModalForm as shown above in code which pops-up on click of ui action will all fields pre-filled except name and gives ability to for end-user to give its own name and by submitting a copy of record will be created.
Since, record is going to be inserted in table on submit of form, I used after Business Rule to copy related list content from parent record to new record which will be inserting.
🙂