Create button to update current records

Priti18
Tera Expert

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!!

1 ACCEPTED SOLUTION

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

View solution in original post

15 REPLIES 15

Sai Kumar B
Mega Sage
Mega Sage

@Priti18 

You can replicate the same from the following link, Just modify the table in UI Action

http://servicenowguru.com/wp-content/uploads/2010/09/dialogWindow-UIPage.jpg 

kamlesh kjmar
Mega Sage
Mega Sage

Hi @Priti18 

 

Try the below link, same has been advised by Sai Kumar B as well, it's just that in Sai's link main content page is missing.

https://servicenowguru.com/system-ui/glidedialogwindow-advanced-popups-ui-pages/

I Hope this helps.

 

Please mark this helpful if this helps and Accept the solution if this solves your issue.

 

Regards,

Kamlesh

 

Priti18
Tera Expert

please check my below code, as am not able to figure out why the changes are showing on the record

 

ui action on cmdb_ci and client is ticked

 

function A() {

var answer = confirm('Do you want to update data');

if (answer) {

gsftSubmit(null, g_form.getFormElement(), 'function_name');
}

if (typeof window == 'undefined')


updateData();


function updateData() {

alert('code is running till here');

current.setValue("state", 7); // this is not updating
current.setValue("", gs.getMessage("record  updated by the user"));
current.update();
action.setRedirectURL(current);

}

}

 

 

Issue is in your third last line, filed name is missing in setValue().

Screenshot_2022-11-01-15-29-23-79_40deb401b9ffe8e1df2f1cc5ba480b12.jpg

Regards,

Kamlesh