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 ADManager Plus?

          New to ADSelfService Plus?

            • Related Articles

            • 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 --> ...
            • Update Request Additional fields during request create/update using Custom Trigger - Deluge

              This is a sample custom function script to update the Request Additional Field Values during request create/update based on certain criteria using Custom Triggers. Refer to this link for Python ...
            • Implementing Room Booking feature using custom module

              Usecase: This article outlines the steps for implementing a room booking feature using a custom module, and requires a feature that blocks the dates if a room is already booked. The objective is to prevent double booking of rooms and provide feedback ...
            • Update Request with another Group when the request is approved - Deluge

              Use case:   Assume a requester is requesting for a gadget asset and it requires approval from their managers.  This ticket needs to be moved to "Asset" group only when the ticket gets approved.  Depending on the availability of the requested gadget, ...
            • Asset System tab

              SELECT workstation.workstationname "Workstation",         ua.username                 "User Name",         ua.domainname               "Domain Name",         ua.description              "Description",         ua.status                   "Status",  ...