- 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 01:09 PM
Hello @James Chun ,
Thanks above code is working!
but i want to show the button for two categories only i have added on the condition but
now button is not visible.
current.getValue('model_category') == 'Smartphone' || current.getValue('model_category') == 'Smartphones_Insight'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 01:11 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 01:17 PM
Sorry, just realized it's a reference field.
You can either use the 'sys_id' of the Model categories or use its display name.
i.e. current.model_category.name.toString() == 'Smartphone'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 01:32 PM
Hi @James Chun ,
Thanks its category is working but one of the field operational status and "lifecycle" fields not able to update. pls correct me!
function doRetire(){
if(confirm('Are you sure want to inactive this device?'))
{
gsftSubmit(null, g_form.getFormElement(), 'inactive_device');
}
}
if(typeof window == 'undefined')
retireDevice();
function retireDevice(){
current.setValue('install_status', 7);
current.setValue('substatus','disposed');
current.setValue('life_cycle_stage','End of Life');
current.setValue('life_cycle_stage_status','Retired');
current.setValue('operational_status','Decommissioned');
current.comments = 'Automatically retired on ' + new Date() + ' by System'; current.install_status = '7';
current.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 12:01 PM
Hi @akin9,
I believe the life_cycle_stage and life_cycle_stage_status are both reference types, not a string type.
And I am not sure whether it's recommended to update the life cycle stage & life cycle stage status in this way. It may break/interfere with other OOB processes. Unfortunately, I can't comment too much on this.
Cheers