[SOLVED] Problems with simple script

[SOLVED] Problems with simple script

Good evening,

I've been working on creating templates for various business needs.  I keep running into an issue where my basic script gives random results based on the condition field.

This is the script, it simply pulls one field and adds it to the existing subject line.

      var Office=$CS.getText("WorkOrder_Fields_UDF_CHAR9");
      var Subject=$CS.getValue("SUBJECT");
      var new_subject = Subject + " : " + Office;

      $CS.setValue("SUBJECT", new_subject);

In this case, I don't need it to trigger by a specific condition, so that field can be left blank.  The issue is the condition impacts the output of the script on the subject line.  Below are two examples:

Method 1:


Method 2:



The resulting tickets appear as follows:


So, when I designate exactly what the subject will contain, it adds the office location only once.  If I don't specify exactly what the subject will be, it gives me the office location twice.  Depending on the settings, I've even had it appear three times. 

To be clear, the only way I've been able to give me "Method 2"'s results is via setting the specific subject.  I've tried various other combos and none of them have worked.

For this purpose, I don't want a specific subject line as it is the default template.  I just want to know which office is requesting something.

Any help would be greatly appreciated on this issue, it certainly slows down template building.

Thank you in advance,
Dave

                  New to ADSelfService Plus?