CA Service Management

 View Only

 Prevent users to submit request

asim Shah's profile image
asim Shah posted Nov 02, 2021 03:58 AM
Dear Members

We need to prevent users to submit a new request for specific category if there is already 3 requests submitted for that category & currently active(Status OPEN or In Progress), the system should give popup mesg like "Try after sometime"  when click on Save button.
If the active request for that specific category is less than 3, then user should able to submit their request.

Can anyone share some script how can we achieve this 


Many THanks​​​​
Lindsay Estabrooks's profile image
Lindsay Estabrooks
I don't have a solution for you but I am curious to know the business justification behind this. This sounds more like anti-service than service, making it harder for someone to request something.
asim Shah's profile image
asim Shah
Dear Lindsay
The business case is that we have a request category 'Elextrical Building Entry', any employee of the organization need to enter this building must submit a request on CA mentioning Time before the entry. 
Most of times, there are many employees entry at the same time and we need to limit by this way if atleast 3 active request already there for the same time in CA, then any employee should not able to submit more request until the active count is less than 3. 
Basically,  we have custom dropdown Time field and we need to compare this field with the number of active ticket to allow or prevent the user. 
Hope u got it,
 actually this is an appointment system requirement, if selected time is avaialble then user should allow to submit else mesg appear Selected time not avaialble 
Can you provide any solution for this? 
Lindsay Estabrooks's profile image
Lindsay Estabrooks
I understand. The requirement is more like "How do I enhance the Service Desk system to behave as a reservation system in this situation?".

The approach I would take would involve creating a Process Automation Manager (PAM) process that I would associate with the Request Area. Within the process, I could query other tickets in the system and either approve or reject the submitted request.

Perhaps someone else has another idea for you.
asim Shah's profile image
asim Shah
Dear @Lindsay Estabrooks

Can you tell me the query so i can try via pam process

Many THanks​
Nicholas Kozell's profile image
Nicholas Kozell

You could build a Data Object in Catalog that looks for these requests and then perform your actions based on what it returns. If nothing else this may give you some ideas of what tables to look at in the MDB.

Here is an example of a query that is looking for active requests, of a specific offering_id, within the last 30 days, and requested by a specific user. You could probably modify this to look for what you want. I'm pulling in request data from the associated SDM ticket because we have some values written to a ticket from our submitted form data that are not available. 

SELECT DISTINCT usm_request.request_id,usm_request.status,call_req.summary,usm_request.req_by_user_id,CONVERT(varchar, usm_request.modified_date) as Modified_Date
FROM usm_request
left join usm_subscription_detail

on usm_subscription_detail.request_id = usm_request.request_id

left join [dbo].[call_req]

on [dbo].[call_req].[zcatalog_properties] = CONVERT(varchar, usm_request.request_id)

WHERE usm_request.modified_date > DATEADD(day,-30,GETDATE())
AND (usm_request.status != 103 OR usm_request.status != 4)
AND usm_request.req_by_user_id = %userid%
AND usm_subscription_detail.offering_id = '10701'
AND usm_request.created_date >= (SELECT [date_last_modified] FROM [mdb].[dbo].[usm_offering] where offering_id = '10701')
ORDER BY request_id DESC

Possibly in code behind you could do something like this where the parameters match the category you need to restrict submissions for. After the alert you could disable the submit functionality.

ca_reportQuery('YourQueryName', { 'Parameter to Search': 'Value to Search' }
     function (rows) {
          if (rows.length > 3) {
alert('You cannot submit this at this time.')
 } else {
}, null);