7 Replies Latest reply on Mar 7, 2018 8:12 AM by Christopher.Bakken

    Web Service Scripting Quick Action fails with a ArgumentNullException

    DrizztLU Apprentice

      Hi!

      I recently started to use Web Service Scripting as it would make it easier for a developer to reach his goal than using a bunch of workarounds.

       

      I'm developing a "Read functionality" (end-users and their outlook habits...), people can subscribe to "Parent objects" such as Incident, ServiceReq, Change, and Problem, and have a visual indicator when a new mail, note or task is created in it.

      I have two fields holding a list of logins (I find it easier to use Style rules with a simple Find() on the grid), people who subscribe and people who actually read it at its current state.

      When creating a "Child object" such as Task.Assignment or Journal (Note, Email), I want to get the list of parent object subscribers into the child object list of subscribers and empty the parent object reader list as no one actually read that update.

       

      TLDR (or in case I lost myself in explanation):

      I have a field which exists on any "parent object" such as Incident, ServiceReq, Change, and Problem, and its value must be transferred to a "child object" which holds a similar field

       

      To do so I use a quick action calling a Web Service Script:

       

      console.debug("Starting READ Task Initialization");
      //Get the current task
      var task = Get("Task#", "$(RecId)"); //Tried both Task# and Task#Assignment
      var taskParent = null;
      
      
      if (task){
           console.debug("\r\nTask "+ task.Fields.AssignmentID +" successfully retrieved\r\n");
           //Get the Parent object
           var getParameter = task.Fields.ParentLink_Category + '#'; //Hopefully something like Incident# or ServiceReq#
           taskParent = Get(getParameter, task.Fields.ParentLink_RecID);
      
           if(taskParent){
                console.debug("Parent "+taskParent.Fields.RecId+" successfully retrieved");
                //Update task' Subscribers
                task.UpdateField("READSubscribers", taskParent.Fields.READSubscribers);
      
                //Empty parent readers as the new task is an update
                ExecuteQuickAction("READClearReaders", getParameter, taskParent.Fields.ParentLink_RecID);
           }
           else{
                console.error("Couldn't get the parent");
           }
      }
      else{
           console.error("Couldn't get the task");
      }
      
      console.debug("Ending READ Task Initialization");
      

       

      At execution, I get the following logs from my scripts (line breaks for your eyes pleasure)

       

      Console output: 

           Starting READ Task Initialization

           Task 210783 successfully retrieved

           Parent B2A05562EEC3413D9BFAE7370D021155 successfully retrieved

       

      As you can see the script gets interrupted and I only get the error below in a separate log (stack trace enclosed to the post)

      System.ArgumentNullException: Value cannot be null.Parameter name: key

       

      Question is: How can I debug deeper? How can I fix this somewhat generic error?

       

      Thanks for your attention that far in my post!