Asset Module Custom Functions

Asset Module Custom Functions

Sample Scripts for custom schedule.

Steps to configure:
1.  Copy the respective query and save the query report with a name.
2.  Update the query report name in the custom schedule function script.
3.  Configure a custom schedule with the custom function and the respective query report as the parameter.
4.  Query column names need to be updated in the script.



Use case - 1:
Default Custom Function:Asset Status Transition
Description: This custom function is designed to update a User-Defined Field (UDF) Picklist Field called Asset Status based on the last scan status of an asset. If the last scan was successful, the status will be set to Online otherwise, it will be set to Offline. The function requires a report as input, which should include the ResourceID,Resource state and the last audit status of each asset.Before using this Custom Action,create a udf  picklist Field and have values Online and Offline as a default value.
Pre-Requisites:
1.Create Asset pick-list additional field with name as "Asset Status" with values Online and Offline as default value.
2.Save the below report as "Asset Status".

Query:
select resources.resourceid as "RESOURCEID", audithistory.auditstatus as "AUDIT_STATUS", resourcestate.displaystate as "RESOURCE_STATE", ( select columnaliasesid from columnaliases where tablename = 'Resource_Fields' and aliasname = 'Asset Status' ) as "COLUMNID" from resources left join resource_fields on resources.resourceid = resource_fields.resourceid left join lastauditinfo on resources.resourceid = lastauditinfo.workstationid left join audithistory on lastauditinfo.last_auditid = audithistory.auditid left join resourcestate on resourcestate.resourcestateid = resources.resourcestateid where (audithistory.audittime >= <from_today> and audithistory.audittime <= <to_today>) or resource_fields.udf_char1 is null or ( resourcestate.displaystate = 'Disposed' and resource_fields.udf_char1 = 'Online' );



Use case - 2:
Default Custom Function:Asset Assign Mail Notification Function
Description: This Custom Function is designed to send a notification mail to the Asset owner,Asset owner's reporting manager and the admin who assigned the Asset to the User.This Function requires a report which includes the Asset name,Product,Product Type,barcode and Email Address of user,Reporting manager of user and admin who assigned the asset.
Pre-Requisites:
1.Configure mail server settings.
2.Save the below report as "Asset Assign Notification Mail".


Query:
select r.resourcename as "Asset Name", u.first_name as "Asset Owner", c1.emailid as "Asset Owner Email", u1.first_name as "Reporting To", c2.emailid as "Reporting To Email", u2.first_name as "Admin", c3.emailid as "Admin Email", b.barcode as "Barcode", cd.componentname as "Model", ct.componenttypename as "Product Type" from resources r left join componentdefinition cd on cd.componentid = r.componentid left join componenttype ct on ct.componenttypeid = cd.componenttypeid left join barcodes b on b.barcodeid = r.barcodeid left join resourceownerhistory h on r.resourceid = h.resourceid left join aaauser u on h.userid = u.user_id left join sduser sd on sd.userid = u.user_id left join aaauser u1 on sd.reportingto = u1.user_id left join aaauser u2 on h.taskuserid = u2.user_id left join aaausercontactinfo uc1 on u.user_id = uc1.user_id left join aaacontactinfo c1 on uc1.contactinfo_id = c1.contactinfo_id left join aaausercontactinfo uc2 on u1.user_id = uc2.user_id left join aaacontactinfo c2 on uc2.contactinfo_id = c2.contactinfo_id left join aaausercontactinfo uc3 on u2.user_id = uc3.user_id left join aaacontactinfo c3 on uc3.contactinfo_id = c3.contactinfo_id where h.resourceownerid is not null and h.starttime >= <from_today> and h.starttime <= <to_today>;



Use case - 3:
Default Custom Function:Move Asset to Expired State
Description:This custom function is designed to change the asset state to 'Expired' for assets whose expiry date has passed.This function required the report which include the resourceid of the expired assets.

Save the below report as "Expired Assets".

Query:
select resources.resourceid from resources where expirydate <= <to_yesterday> and resourcestateid not in (select resourcestateid from resourcestate where statedesc = 'Expired');




                  New to ADSelfService Plus?

                    • Related Articles

                    • Risk Matrix for Change using Custom Module

                      Overview: A risk matrix helps in identifying risks based on how likely they are to happen and how serious their impact could be. This makes it easier to decide which risks need urgent attention and which ones can be watched over time. It helps manage ...
                    • Notification script using Custom function in custom trigger

                      This is applicable from 10600 builds. From 10600 , Business rules dont have Email notification feature. The same use case be achieved through Custom triggers feature as mentioned below. Script to enable notification of request creation using custom ...
                    • Risk matrix for Change using Custom module

                      UseCase: Risk need to be calculated through Risk matrix (similar to Priority matrix in the request module) Steps to configure: Configure custom module as in the attached screenshot. 1. Navigate to Admin --> Developer space --> Custom module --> ...
                    • Restrict double booking of rooms and provide feedback using custom module

                      Usecase: This article outlines the steps for implementing a room booking feature using a custom module, Which blocks the dates if a room is already booked. The objective is to prevent double booking of rooms and provide feedback when attempting to ...
                    • Change Risk Assessment Questionnaire using Custom module - Implementation steps

                      We’re excited to share a step-by-step guide( Attached) on implementing a Change Risk Assessment Questionnaire in ServiceDesk Plus using the Custom Module feature. This solution leverages Custom Modules, Change Additional Fields, and Field & Form ...