UI action is not working(the field value is not updated even when the button is pressed)

jinhui son
Tera Contributor

function onClick() {
    
    var gr = new GlideRecord('incident');
    gr.addQuery('sys_id',current.sys_id);
    gr.query();
    
    while(gr.next()) {
        gr.u_disability_report='true';
        gr.update();
    
    }
    action.setRedirectURL(current);

}

 

If I click the button on the form, I want to update the "u_disability_report" field value to true.

However, the field value is not updated even when the button is pressed.
Do you know the solution?

1 ACCEPTED SOLUTION

palanikumar
Mega Sage

Hi,

I think you checked "Client" Check box in UI Action, Uncheck it. You can use the below script to update current record in UI Action

action.setRedirectURL(current);
current.u_disability_report = true;
current.update();
Thank you,
Palani

View solution in original post

7 REPLIES 7

Voona Rohila
Kilo Patron
Kilo Patron

Hi Jinhui

Can you share the image agin and also the UI Action code.


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

You should use below logic.

current.u_disability_report = true;
current.update();
action.setRedirectURL(current);

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Mohith Devatte
Tera Sage
Tera Sage

Hello,

Can you try with this line

 gr.u_disability_report=true;

i have removed the quotes as it is a boolean value some times this also effects.

please accept the solution or mark helpful if it solves the issue

thanks

 

palanikumar
Mega Sage

Hi,

I think you checked "Client" Check box in UI Action, Uncheck it. You can use the below script to update current record in UI Action

action.setRedirectURL(current);
current.u_disability_report = true;
current.update();
Thank you,
Palani