Ability to set fields on INC/TASK when attaching KB Articles

Nivlac1000
Kilo Expert

Hey All,

  I'm looking to modify the KnowledgeFunctions UI script to help set a couple of hidden reportable fields on INC/Catalog Tasks for our Knowledge team based on what type of article it is.   Caveat is we have some customizations on this script already which you'll see below.

I want to when an article is flagged as an "Internal" or when it's what we call a "Routing" document (both flags on the Knowledge article), that I set hidden fields on the task.

I assume it has to happen in the code here where I started to try just doing a g_form set value, but I'm sure I'm missing lots.   Anyone doing anything similar?

    //Below is where KB article text is copied to a ticket field.

    //RedHat wants this copy to occur only if the article is not internal

    if (internal != 'true'){

          if (target) {

                var ed = self.opener.g_form.getGlideUIElement(targetName);

                if (ed && ed.type == 'reference') {

                      self.opener.g_form.setValue(targetName, sourceID);

                } else {

                      var newValue = "";

                      if (target.value == "")

                            newValue = value;

                      else

                            newValue = target.value + "\n" + value;

                      self.opener.g_form.setValue(targetName, newValue);

                }

          }

    }

    if (internal == 'true'){

                    self.opener.g_form.setValue(current.u_internal_kb_attached, 'true');

          /*           targetName = 'work_notes';

          target = self.opener.document.getElementById(tableName + "." + targetName);

          if (target) {

                var ed = self.opener.g_form.getGlideUIElement(targetName);

                if (ed && ed.type == 'reference') {

                      self.opener.g_form.setValue(targetName, sourceID);

                } else {

                      var newValue = "";

                      if (target.value == "")

                            newValue = value;

                      else

                            newValue = target.value + "\n" + value;

                      self.opener.g_form.setValue(targetName, newValue);

                }

          }*/

    }

    self.close();

}

Thanks!

Cal

1 ACCEPTED SOLUTION

Nivlac1000
Kilo Expert

FYI if anyone runs across this, I was able to do this with some changes to the code above.


View solution in original post

1 REPLY 1

Nivlac1000
Kilo Expert

FYI if anyone runs across this, I was able to do this with some changes to the code above.