I want to update an asset record after closing the catalog task.

Gulfam Shafee3
Tera Expert

Hi, 

 

My requirement is submit a request for laptop using Service catalog . A task will be created to deliver the Laptop. Fulfillment teams has to respond to the task .

I have added a asset variable on the catalog task to select the asset. fulfillment team will select the asset, dispatch it and close the task.

After task is close complete it should update the asset state in asset table. and map the ritm with the asset.

8 REPLIES 8

There is not an asset field out of the box on sc_task. If for some reason you need that mapping you would have to add a custom field. Why do you need to map that record to the asset?

So that i can keep record of asset. against which RITM, i have issued the asset. 

Amit Gujarathi
Giga Sage
Giga Sage

HI @Gulfam Shafee3 ,
I trust you are doing great.
Please find the sample code for the same :

(function executeRule(current, previous /*null when async*/) {

    // Check if the task is closed complete
    if (current.state == 'closed_complete') {
        var assetId = current.u_asset; // Assuming 'u_asset' is the field for asset on the task

        // Query the asset record
        var asset = new GlideRecord('alm_asset');
        if (asset.get(assetId)) {
            asset.install_status = 'in_use'; // Set the asset state to 'In Use'
            asset.u_request_item = current.request_item; // Linking the RITM to the asset
            asset.update();
        }
    }

})(current, previous);

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



Thank you Amit for your response.

Actually I am using flow designer to update the asset based on selection.

I have achieved it. 

I used "Get Catalog variable" OOB action. where I can fetch catalog variable on flow designer 

Then I used "look up record" and search for the asset which I want to update. 

After that I have used the "update record" OOB action to update the asset.