- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2022 11:20 AM
I want to update current records in cmdb_ci table but when user clicks on the UI action it should open the comment box and when user clicks on ok it should update data along with that comment in short description.
can anyone help me with this requirement, that would be really helpful.
thanks!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2022 04:31 AM - edited 11-01-2022 04:33 AM
Please try the below script:
function UpdateData() {
var answer = confirm('Do you want to update this record');
if (answer) {
gsftSubmit(null, g_form.getFormElement(), 'function_name');
}
}
if (typeof window == 'undefined')
updateValues();
function updateValues() {
current.setValue("state", 7);
current.update();
var childInc = new GlideRecord("incident");
childInc.addQuery("parent_incident", current.getUniqueValue());
childInc.query();
while (childInc.next()) {
childInc.state = "7";
childInc.comments = "Your comments here";
childInc.update();
}
action.setRedirectURL(current);
}
I hope this help.
Please mark this helpful if this helps and Accept the solution if this solves your issue.
Regards,
Kamlesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2022 03:55 AM
Is your UI button's Action Name 'function_name' ? If not make it 'function_name', it will work
If it still do not work, please share screen shot of your ui action page, something must be wrong in it. Also there is an issue of curly bracket. I am re-structing your code, try this, it should work:
function UpdateData() {
var answer = confirm('Do you want to update this record');
if (answer) {
gsftSubmit(null, g_form.getFormElement(), 'function_name');
}
}
if (typeof window == 'undefined')
updateValues();
function updateValues() {
current.setValue("state", 7);
current.update();
action.setRedirectURL(current);
}
I hope this help.
Please mark this helpful if this helps and Accept the solution if this solves your issue.
Regards,
Kamlesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2022 04:03 AM
awesome!!it worked braces were the issue.
Also, how can i close the child task with an short description that this updated this and stop the workflow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2022 04:16 AM - edited 11-01-2022 04:16 AM
Your use-case is not clear, on the basis of confirm button which related task record you want to update ? What is parent here and what is child. Is this RITM and SCTASK you are working with
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2022 04:21 AM
am trying to update the incident record but when its updated the child incident record should be closed and workflow should be cancelled.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2022 04:31 AM - edited 11-01-2022 04:33 AM
Please try the below script:
function UpdateData() {
var answer = confirm('Do you want to update this record');
if (answer) {
gsftSubmit(null, g_form.getFormElement(), 'function_name');
}
}
if (typeof window == 'undefined')
updateValues();
function updateValues() {
current.setValue("state", 7);
current.update();
var childInc = new GlideRecord("incident");
childInc.addQuery("parent_incident", current.getUniqueValue());
childInc.query();
while (childInc.next()) {
childInc.state = "7";
childInc.comments = "Your comments here";
childInc.update();
}
action.setRedirectURL(current);
}
I hope this help.
Please mark this helpful if this helps and Accept the solution if this solves your issue.
Regards,
Kamlesh