Creating a new related record from the Related list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2022 11:27 AM
I want to create a new UI action on the m2m Relationship table created for a custom table extending the case table,
I want to copy all fields to the Case record when i create a new case from the custom record. Can someone help me adding the UI action, when i clear the 'omit New button" from the list action default case record is created but the relationship is not created and cannot see the related records in the related list.
Please help me on the UI action, i want to copy the Short description, Description, Category, subcategory, Application service and Populate Parent field on the Case record to the custom record.
- Labels:
-
Customer Service Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2022 01:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2022 10:47 PM
Hi Nishant
How did you end up going with this? Did you get it sorted?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2022 07:17 PM
I had the same business need and have a solution.
For context, I'm creating a Test Version from a SAFe Story via the out-of-the-box m2m table.
For me, after showing the 'New' button on the related list, it still wouldn't work, so I used a workaround.
I created two UI Actions, one on the m2m related list table, and the other on the Story table. I use the related list UI Action to call the UI Action on the Story table and perform its logic. Doing this meant I could use things like 'gr.short_description = current.short_description;'.
m2m UI Action looks like this:
Table: sn_test_management_m2m_task_test (enter whatever your m2m table is here)
Action name: create_new_test
Make sure 'Client' is ticked
Onclick: newTestClient()
In my scenario I was creating a test from a safe story. I didn't want the new UI Action to show on the related list when looking at the Test though, only while looking at the story. So I added a condition:
Condition: gs.action.getGlideURI().toString().startsWith('sn_safe_story');
Script:
function newTestClient(){
gsftSubmit(null, g_form.getFormElement(), 'create_new_test'); //This is calling the /sys_ui_action.do?sys_id=sys_id="entered my custom tables ui action sys_id"
}
The above code calls the sysID of the UI Action on the record which does the work:
Table: sn_safe_story (obviously enter your custom table here)
Action name: create_new_test
Untick Show Insert, Show update & Form button. You don't want this UI Action showing on your form, it just needs to be callable from the Related list UI Action.
Script:
var newTest = new GlideRecord('sn_test_management_test_version');
newTest.initialize();
newTest.setValue('short_description', current.short_description);
newTest.update();
var relate = new GlideRecord('sn_test_management_m2m_task_test');
relate.initialize();
relate.task = current.sys_id;
relate.test = newTest.test.sys_id;
relate.update();
action.setRedirectURL(newTest);
Hope this helps somewhat if you are still having issues.