update in a display business rule

brumiou
Mega Guru

Hi,

I have a request from the business :
they want that if the service desk enter a comment, the record appears in the list with a specific color (that's easy)
But then, if someone from a specific group opens the record, this should put the record color to normal.
It means I have to update the record when the user opens it.

I tried to do that with a display business rule, but if I do a current.update() when the users open the form, he gets a blank screen.

I tried to use gs.setRedirect, but without result.

Have you any idea on how to update a record when someone opens the form? Without any action from him?

Thanks a lot

rgds

Xavier

10 REPLIES 10

CapaJC
ServiceNow Employee
ServiceNow Employee

Can you set a g_scratchpad variable in the "display" Business Rule, check the variable in an onLoad Client Script, and modify the value accordingly?


brumiou
Mega Guru

Hi,

thanks for the answer.

But then, how to update the record himself?
I can't update the current record in the onload client script isn't it?


Not applicable

What is it in the current record that you need to actually change?

(you can manipulate "current" values in a display business rule, in some cases, just as long as you don't call update())


pr17
Kilo Explorer

Was trying to do the same thing today for a client as required by your business and ran in to the same issue as you mentioned.
Got around it by NOT using "current.update()" but rather do a glide record query and updating the current record. Below is the code inside my display business rule on task table.



var gr = new GlideRecord(current.sys_class_name);
gr.get(current.sys_id);
gr.{your_flag_field_to_update} = false;
gr.update();