SC_Task with asset update ability

Bidduam
Tera Guru

Hi,

 

I'm wondering if it is possible to have a catalog item that a client uses to request for example a laptop. 

When it comes through to the Service Desk they have a sc task to provide the laptop, what I'd like to have is the ability for the desk to add the details of the laptop into the sc task and have the asset be updated at the same time - it the assigned user and comments, status etc can be updated from the sc task.

 

Is this possible? If so does anyone know how?

1 ACCEPTED SOLUTION

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Bidduam ,

 

Yes, it's absolutely possible to achieve this in ServiceNow. You can create a Service Catalog item for requesting a laptop and then handle the fulfillment using a Service Catalog Task (sc_task). When the Service Desk fulfills the request, they can update the associated asset record and various related fields from the Service Catalog Task.

Here's a general outline of how you can set this up:

### 1. **Create a Service Catalog Item:**
- Create a catalog item for requesting a laptop. Include all the necessary fields for capturing user information, laptop specifications, etc.

### 2. **Fulfillment with Service Catalog Task:**
- When a user requests a laptop, it generates a Service Catalog Task (sc_task) associated with the requested item.
- Service Desk agents work on this task to fulfill the request.

### 3. **Update Asset and Related Fields from the Service Catalog Task:**
- ServiceNow provides several methods to link assets to configuration items (CIs) and incidents, including asset APIs and scripts.
- When the Service Desk updates the Service Catalog Task to indicate that the laptop has been provided, you can write a Business Rule or a Script Include to update the associated asset record and related fields.
- For example, you can update the asset's assigned user, comments, status, etc., based on the information provided in the Service Catalog Task.

### Sample Business Rule (Script):

(function executeRule(current, previous /*null when async*/) {
if (current.fulfillment_status == 'complete') {
var asset = new GlideRecord('alm_asset');
if (asset.get(current.asset_id)) {
asset.assigned_to = current.assigned_to; // Update assigned user
asset.comments = 'Laptop provided as per request: ' + current.comments; // Update comments
asset.install_status = 'In use'; // Update status, adjust this based on your requirement
asset.update();
}
}
})(current, previous);

In this script, it checks if the Service Catalog Task's fulfillment status is set to 'complete'. If so, it updates the associated asset record with the assigned user, comments, and changes the install status.

### Important Considerations:
- Ensure that proper access controls are in place to restrict who can modify asset records.
- Customize the script according to your specific fields and requirements.
- Thoroughly test the solution in a non-production environment before deploying it to production.

By following this approach, you can effectively manage laptop requests, update asset records, and maintain a streamlined workflow for your Service Desk.

 

Mark my answer as helpful & accepted if it helps you.

 

Thanks,

Danish

View solution in original post

4 REPLIES 4

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Bidduam ,

 

Yes, it's absolutely possible to achieve this in ServiceNow. You can create a Service Catalog item for requesting a laptop and then handle the fulfillment using a Service Catalog Task (sc_task). When the Service Desk fulfills the request, they can update the associated asset record and various related fields from the Service Catalog Task.

Here's a general outline of how you can set this up:

### 1. **Create a Service Catalog Item:**
- Create a catalog item for requesting a laptop. Include all the necessary fields for capturing user information, laptop specifications, etc.

### 2. **Fulfillment with Service Catalog Task:**
- When a user requests a laptop, it generates a Service Catalog Task (sc_task) associated with the requested item.
- Service Desk agents work on this task to fulfill the request.

### 3. **Update Asset and Related Fields from the Service Catalog Task:**
- ServiceNow provides several methods to link assets to configuration items (CIs) and incidents, including asset APIs and scripts.
- When the Service Desk updates the Service Catalog Task to indicate that the laptop has been provided, you can write a Business Rule or a Script Include to update the associated asset record and related fields.
- For example, you can update the asset's assigned user, comments, status, etc., based on the information provided in the Service Catalog Task.

### Sample Business Rule (Script):

(function executeRule(current, previous /*null when async*/) {
if (current.fulfillment_status == 'complete') {
var asset = new GlideRecord('alm_asset');
if (asset.get(current.asset_id)) {
asset.assigned_to = current.assigned_to; // Update assigned user
asset.comments = 'Laptop provided as per request: ' + current.comments; // Update comments
asset.install_status = 'In use'; // Update status, adjust this based on your requirement
asset.update();
}
}
})(current, previous);

In this script, it checks if the Service Catalog Task's fulfillment status is set to 'complete'. If so, it updates the associated asset record with the assigned user, comments, and changes the install status.

### Important Considerations:
- Ensure that proper access controls are in place to restrict who can modify asset records.
- Customize the script according to your specific fields and requirements.
- Thoroughly test the solution in a non-production environment before deploying it to production.

By following this approach, you can effectively manage laptop requests, update asset records, and maintain a streamlined workflow for your Service Desk.

 

Mark my answer as helpful & accepted if it helps you.

 

Thanks,

Danish

@Danish Bhairag2 thank you that got me to a solution, although the script wasn't 100% correct at least for my instance.

 

The difference just for anyone else looking at this in the future was that the following actually got the variables that I had added:

(function executeRule(current, previous /*null when async*/) {
if (current.fulfillment_status == 'complete') {
var asset = new GlideRecord('alm_asset');
if (asset.get(current.request_item.variables.asset_id)) {
asset.assigned_to = current.request_item.variables.assigned_to; // Update assigned user
asset.comments = 'Laptop provided as per request: ' + current.request_item.variables.comments; // Update comments
asset.install_status = '1'; // Update status, adjust this based on your requirement
asset.update();
}
}
})(current, previous);

Ankur Bawiskar
Tera Patron
Tera Patron

@Bidduam 

on sc_task there is already a field which refers CMDB table

you can try to re-use that

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 

I can refer to a table easily enough, but how do you use that to make an update to the record of the asset?