diff --git a/Client-Side Components/Client Scripts/Count Assigned To Field/README.md b/Client-Side Components/Client Scripts/Count Assigned To Field/README.md new file mode 100644 index 0000000000..24bc571aa9 --- /dev/null +++ b/Client-Side Components/Client Scripts/Count Assigned To Field/README.md @@ -0,0 +1,14 @@ +Count Assigned To Field + +1. Write a Client Script name as getAssignedToCount +2. Glide the Incident Table +3. Use onChange Client Script +4. Use the Field name as "assigned_to" field +5. Glide the Script Include using "GlideAjax". +6. Call the function "getCount" from Script Include +7. Add the parameter for the newValue. +8. Use the getXML for asynchronous response. +9. Get the answer using the callback function +10. Use the logic for the more than how many tickets that error needs to populate +11. Use the addErrorMessage for marking the error message +12. Use the setValue for the "assigned_to" field. diff --git a/Client-Side Components/Client Scripts/Count Assigned To Field/getAssignedToCount.js b/Client-Side Components/Client Scripts/Count Assigned To Field/getAssignedToCount.js new file mode 100644 index 0000000000..31105ebe56 --- /dev/null +++ b/Client-Side Components/Client Scripts/Count Assigned To Field/getAssignedToCount.js @@ -0,0 +1,18 @@ +function onChange(control,oldValue,newValue,isLoading,isTemplate) { + if(isLoading || newValue === '') { + return; + } + + var ga = new GlideAjax('countAssignedUtil'); + ga.addParam('sysparm','getCount'); + ga.addParam('sysparm_assignedto', newValue); + ga.getXML(callback); + + function callback(response){ + var answer = response.responseXML.documentElement.getAttribute("answer"); + if(answer >=5){ + g_form.addErrorMessage("Please select another person to work on this Incident, selected user is already having 5 tickets in his/her Queue"); + g_form.setValue("assigned_to", ""); + } + } +}