- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 10:53 AM
Hello experts,
We have created a button "inactive aset" in "alm_hardware" table and confrmation
pop up also with Ok and cancel. its working fine.
Requirement
1.If user clicks ok then some of the field values needs to change automatically
on the "alm_asset" table like below.
2.This button need to visible for only "smartphone" and "computer" category only.
comments | Add comment: 1) Retired on >Date< by >User<. 2) Automatically retired on >Date< by System. |
install_status | Retired -> ‘7’ |
I have tried with after insert BR for update fields. but no luck ,can you pls support!
any other approach
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 12:30 PM
Try this
function doRetire(){
if(confirm('Are you sure?'))
{
gsftSubmit(null, g_form.getFormElement(), 'inactive_device');
}
}
if(typeof window == 'undefined')
retireDevice();
function retireDevice(){
current.setValue('install_status', 7);
current.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 11:13 AM
If you want to update records of same table on which you are using after business rule then you need to use:
current.setWorkflow(false);
current.update();
For more information : read the following thread especially [Prevent Recursive Business Rule] heading.
https://www.servicenow.com/community/developer-forum/updating-records-with-after-business-rules/m-p/...
If my response is helpful mark is as helpful or correct. Thankyou
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 12:02 PM
Hey @akin9,
1. You can run both client and server scripts within a UI Action. Refer to the article below and give it a go
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1005843
2. Add some script in the 'Condition' field such as
current.getValue('category') == 'smartphone' || current.getValue('category') == 'computer'
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 12:26 PM
Hello @James Chun ,
Thanks for the quick reply!
I have tried that but no luck i want to upfate fields on "alm_asset" like below
install_status | Retired -> ‘7’ |
can you please help me on the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 12:30 PM
Try this
function doRetire(){
if(confirm('Are you sure?'))
{
gsftSubmit(null, g_form.getFormElement(), 'inactive_device');
}
}
if(typeof window == 'undefined')
retireDevice();
function retireDevice(){
current.setValue('install_status', 7);
current.update();
}