Parent/Child Related list record creation

purdue
Kilo Sage

Hello,

I created a custom ui action for a related list on our scoped app parent table to create a child task.   However nothing is happening.   What am I missing?  Thanks, Chad

 

Screenshot 2026-03-03 at 3.34.41 PM.png

Screenshot 2026-03-03 at 3.36.22 PM.png

1 ACCEPTED SOLUTION

purdue
Kilo Sage

Hey Thanks All for your replies.  I was able to work with one of the other developers to get it working.

var uri = action.getGlideURI();
var path = uri.getFileFromPath() + '';
path = path.substring(0, path.length - 5) + '.do';

uri.set('sys_id', '-1');

path = checkWizard(uri, path);

if (path)
action.setRedirectURL(uri.toString(path));

action.setNoPop(true);

function checkWizard(uri, path) {
var already = uri.get('WIZARD:action');
if (already == 'follow')
return null;

var wizID = new GlideappWizardIntercept(path).get();
if (!wizID)
return path;

uri.set('sysparm_parent', wizID);
uri.deleteParmameter('sysparm_referring_url');
uri.deleteMatchingParameter('sysparm_list_');
uri.deleteMatchingParameter('sysparm_record_');
uri.deleteParmameter('sys_is_list');
uri.deleteParmameter('sys_is_related_list');
uri.deleteParmameter('sys_submitted');
uri.deleteParmameter('sysparm_checked_items');
uri.deleteParmameter('sysparm_ref_list_query');
uri.deleteParmameter('sysparm_current_row');

uri.set('sysparm_referring_url', uri.toString());
uri.deleteMatchingParameter('fancy.');
uri.deleteMatchingParameter('sys_rownum');
uri.deleteMatchingParameter('sysparm_encoded');
uri.deleteMatchingParameter('sysparm_query_encoded');
uri.deleteParmameter('sysparm_refer');

return 'wizard_view.do';
}

View solution in original post

5 REPLIES 5

Dinesh_Now
Tera Guru

Hello.

Just try below, if it can help you.

 

  • You checked Client on a Related List UI Action.

  • In a related list, g_form does not exist.

  • So your script fails and nothing happens.

Fix (best practice)

  1. Uncheck “Client”

  2. Use server-side script:

 

 

var child = new GlideRecord('x_cons_dealer_analytics_task_do');
child.initialize();
child.u_parent_cda_request = current.sys_id;
child.insert();

action.setRedirectURL(child);



If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Animesh Das2
Mega Sage

Hi @purdue ,

 

It seems you missed the 'Action name' and 'Onclick' fields, and put the entire code inside the function that you put in the 'Onclick' field.

 

For example can you try with the values as below, 

'Action name' is New_Child_Incident

'Onclick' is createNewChildIncident()

and put your code inside function createNewChildIncident() {YOUR CODE}

 

Let see if that works.

 

If this address your question, please don't forget to mark this response correct by clicking on Accept as Solution and/or Kudos.

You may mark this helpful as well if it helps you.

Thanks, 

Animesh Das

BhavaniYamsani
Tera Contributor

Hi @purdue ,

Give Action Name, name, table name

Check List Banner Button

Uncheck the client checkbox

Put Condition as current.parent.nil()

 

Script is 

var parentSysId = RP.getParameterValue('sysparm_collectionID');

var url = new GlideURL('url of child task');

url.addParam('sysparm_query', 'parent=' + parentSysId);

url.addParam('sysparm_view', 'default');

action.setRedirectURL(url);

 

Try to add this code & replace the url of task(2nd line of script) from your instance

 

Let me explain this code like the UI Action creates a child task from the related list. 

RP.getParameterValue('sysparm_collectionID') - retrieves the parent record sysid, GlideURL opens the child task form, and sysparm_query pre-fills the parent field.
action.setRedirectURL(url) - then redirects the user to that task form

 

And give condition/check the box if required like when it should create the task on insert or on update ---- on update means on every update it will create the task, so check that checkboxes if it is required.

 

Please mark as helpful and accept as solution if this approach works for you.

Thanks
Yamsani Bhavani

Aditya_hublikar
Mega Sage

Hello @purdue ,

 

Your entire code in client side , so you need to wrap up all your code in one function,

 

For example

 

function functionName()

{
var parentId = g_form.getUniqueValue();
var url = new GlideURL('x_cons_dealer_analytics_task.do')
url.addParam('sys_id', '-1');
url.addParam('sysparm_query', 'u_parent_cda_request=' + parentId);
url.addParam('sysparm_view', g_form.getViewName());
window.open(url.getURL());
}

 

and call your function in onClick field like functionName().

 

Then it will get called when you click ui action.

 

 

If this helps you then mark it as helpful and accept as solution.

Regards,

Aditya