- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hey Thanks All for your replies. I was able to work with one of the other developers to get it working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello.
Just try below, if it can help you.
You checked Client on a Related List UI Action.
In a related list,
g_formdoes not exist.So your script fails and nothing happens.
Fix (best practice)
Uncheck “Client”
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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
