UI Action Issue

Dave_p
Giga Guru

Hi,

 

I have two questions please.

 

1. The code isn't working. 

 

function demoClientScript() {
    var answer = confirm('Do you want to close Child incident?');
    if (answer == true) {
        gsftSubmit(null, g_form.formElement(), 'sys_demoaction');
    }
}

var gr = new GlideRecord('incident');
gr.addQuery('parent_incident',  current.sys_id);
gr.query();
while(gr.next()){
	gr.state = '7';
	gr.resolution_code='duplicate';
	gr.resolution_notes='I love you Cloeh';
	gr.update();
}
action.setRedirectURL(current);

 

1.png

 

 

2. In very simple terms please explain me when should I use 'current' and when should I use 'gr.

 

Regards

Suman P.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

@Dave_p 

current means the glideRecord object of the form being opened

gr is just name of gliderecord object for your table mentioned i.e. incident

update script as this

 

function demoClientScript() {
    var answer = confirm('Do you want to close Child incident?');
    if (answer == true) {
        gsftSubmit(null, g_form.getFormElement(), 'sys_demoaction');
    }
}

if (typeof window == 'undefined')
    runServerCode();

function runServerCode() {
    var gr = new GlideRecord('incident');
    gr.addQuery('parent_incident', current.sys_id);
    gr.query();
    while (gr.next()) {
        gr.state = '7';
        gr.resolution_code = 'duplicate';
        gr.resolution_notes = 'I love you Cloeh';
        gr.update();
    }
    action.setRedirectURL(current);
}

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron

@Dave_p 

current means the glideRecord object of the form being opened

gr is just name of gliderecord object for your table mentioned i.e. incident

update script as this

 

function demoClientScript() {
    var answer = confirm('Do you want to close Child incident?');
    if (answer == true) {
        gsftSubmit(null, g_form.getFormElement(), 'sys_demoaction');
    }
}

if (typeof window == 'undefined')
    runServerCode();

function runServerCode() {
    var gr = new GlideRecord('incident');
    gr.addQuery('parent_incident', current.sys_id);
    gr.query();
    while (gr.next()) {
        gr.state = '7';
        gr.resolution_code = 'duplicate';
        gr.resolution_notes = 'I love you Cloeh';
        gr.update();
    }
    action.setRedirectURL(current);
}

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

@Dave_p 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.