Updating Request Additional Fields With Deluge (Business Rule/Custom Function) Errors

Updating Request Additional Fields With Deluge (Business Rule/Custom Function) Errors

Hello, I have a business rule set up to run a Custom Function when a ticket is created through email. I want to change the contents of certain fields based on the subject of the email.
  1. Mode
  2. An Additional Pick List
  3. An Additional Sline
  4. Category/Subcategory/Item
The docs for this (https://help.servicedeskplus.com/request-custom-function) Say: "Changes that are made to 'requestObj' values will be updated in the request on which the automation rule acts. " however this doesn't seem to be the case. My code never updates the fields and gives errors in the history of the ticket. I stripped my code down to just update one field to figure out why it's not working.


  1. udf_field_api_name = "udf_pick_7202";
  2. new_value = "Valley Fiber";

  3. requestObj.put("udf_fields", {udf_field_api_name : new_value});

  4. return requestObj; 
 and here is the error I see in the ticket that was created by the business rule:
  1. Change Company: To Valley Fiber - Executed from business rule id 6902. Result : Execution failed Message : sdp.custom.script.improper.json


I have also tried this method: https://pitstop.manageengine.com/portal/en/kb/articles/update-request-additional-fields-during-request-create-update-using-business-rules
My Code:

  1. udf_field_api_name = "udf_pick_7202";
  2. new_value = "Valley Fiber";

  3. returnjson = {
  4. "operation": [{
  5. "INPUT_DATA": [{
  6. "request": {
  7. "udf_fields": {
  8. udf_field_api_name: {"value": new_value}
  9. }
  10. }
  11. }],
  12. "OPERATIONNAME": "UPDATE",
  13. "FORMAT": "V3"
  14. }],
  15. "result": "success",
  16. "message": "Additional field updated successfully!!"
  17. };

  18. return returnjson;

This gives me this error:
  1. Change Company: To Valley Fiber (API) - Executed from business rule id 6902. Result : Execution failed Message : {"status_code":4000,"messages":[{"status_code":4012,"field":"udf_fields","type":"failed","message":"Value not provided"}],"status":"failed"}


Why doesn't this work? I based it on the example found in your documentation. I would really appreciate any help figuring out where I went wrong! Thank you.


EDIT: Update

These are the two custom functions I have now:



  1. description = requestObj.get("description");
  2. if(description.contains("A voice message was left from")) {

  3. requesturl = "http://helpdesk.vispnet.ca:8080/api/v3/requests/" + requestObj.get("id");

  4. input_data = {
  5. "request": {
  6. "mode": {
  7. "name": "Phone Call",
  8. "id": "3"
  9. }
  10. }
  11. };
  12. response = invokeurl
  13. [
  14. url: requesturl
  15. type: PUT
  16. parameters: {"input_data":input_data}
  17. headers: {"authtoken":"myauthtoken","PORTALID": "1"}
  18. ];

  19. returnObj = Collection();
  20. if(response.get("response_status").get("status_code") == 2000) {
  21. returnObj.insert("result":"Success","message":"Status Updated!");
  22. }
  23. else{
  24. returnObj.insert("result":"failure","message":"Error occured changing the request. Code: " + response.get("response_status").get("status_code") + response.get("response_status").get("description") );
  25. }
  26. }//endif
  27. //info "request mode is " + requestObj.get("mode");

  28. return returnObj;
and


  1. //Get basic request info
  2. requesturl = "http://helpdesk.vispnet.ca:8080/api/v3/requests/" + requestObj.get("id");
  3. requestSubject = requestObj.get("subject");

  4. //debug
  5. //info requestObj.get("id") + " " + requestSubject;

  6. //Set up variables to change
  7. company = "No Company Provided";
  8. impactedService = "(No Impacted Service Provided)";
  9. category = null;
  10. subcategory = null;
  11. item = null;

  12. //--Set up defaults for Cat/SubCat/Item to reduce repetition
  13. //Internet
  14. internetCategory = {
  15.             "name": "No Internet",
  16.             "id": "1504"
  17.         };
  18. internetSubcategory = {
  19.             "name": "Known Issue",
  20.             "id": "2701"
  21.         };
  22. //---End Defaults

  23. if ( requestSubject.contains("Valley Fiber") ||  requestSubject.contains("VF")) {
  24. company = "Valley Fiber";
  25. impactedService = "Internet";
  26. category = internetCategory;
  27. subcategory = internetSubcategory;
  28. } else if (requestSubject.contains("VISP")){
  29. company = "VISP";
  30. impactedService = "Internet";
  31. category = internetCategory;
  32. subcategory = internetSubcategory;
  33. } else if (requestSubject.contains("VFTV") || requestSubject.contains("TV") || requestSubject.contains("IPTV")) {
  34. company = "VFTV";
  35. impactedService = "TV";


  36. subjectString = "Known Impact - ".concat(company).concat(" - ").concat(impactedService);

  37. input_data = {
  38.     "request": {
  39. "subject": subjectString,
  40. "category": category,
  41. "subcategory": subcategory,
  42. "item": item,
  43.         "udf_fields": {
  44. "udf_sline_6001": company
  45.         }
  46. }
  47. };


  48. //TODO add category, subcat, and item to api call
  49. response = invokeurl
  50. [
  51. url: requesturl
  52. type: PUT
  53. parameters: {"input_data":input_data}
  54. headers: {"authtoken":"myauthtoken","PORTALID": "1"}
  55. ];

  56. returnObj = Collection();
  57. if(response.get("response_status").get("status_code") == 2000) {
  58. returnObj.insert("result":"Success","message":"Status Updated!");
  59. }
  60. else{
  61. returnObj.insert("result":"failure","message":"Error occured changing the request. Code: " + response.get("response_status").get("status_code") );
  62. }

  63. return returnObj;


And it updates the request properly when I use 'save and test', however running the same code gives errors when triggered through a business rule:




Why does my code work in save and test, but not when triggered by a business rule? here's how one of the business rules is configured:

                New to ADManager Plus?

                  New to ADSelfService Plus?