I wanted to add an additional ticket source that staff members could choose when creating a ticket.

Therefore I updated /include/staff/newticket.inc.php and included the following:

<option value="IM" <?=($info=='IM')?'selected':''?>>IM</option>

However when I try to submit the ticket it says, "Unable to create the ticket. Correct the error(s) and try again" - "Invalid source - IM"

Is there something else I need to do in order to show that the source is in fact valid?

hoffmana,

You are getting this error because "IM" is not in the allowable sources array.

1.6 RC5

scp/tickets.php

if($_POST && !in_array(strtolower($_POST),array('email','phone','other')))

$errors='Invalid source - '.$_POST;

1.6 ST

include/class.ticket.php

if($var && !in_array(strtolower($var),array('email','phone','other')))

$errors='Invalid source - '.Format:($var);

Best practice: If you have access to the command line then the best thing to do is to search for the error message (in this case 'Invalid source'). Once you find that you can find what triggers the error and then you know whats causing it and usually how to fix it :)

So on my servers I just did a grep to find the code, then opened the file to find the exact line with the error code, so on and so on.

user@myserver /var/www/tickets > grep -ri 'Invalid source' *

Of course if you don't have access to the command line you could always download the source code and use windows search to go through and find the error message - though I imagine that would take quite a bit longer.

Thanks for the quick reply. Looks like the entry is in class.ticket.php so I updated the array to include "IM" like below:

array('email', 'phone', 'other', 'IM')

For some reason, it is still telling me Invalid source when I try to submit.

Any ideas?

Hrm... clear your browser cache?

I went ahead and tried that and attempted using another browser just to make sure. Seem to still get the same results ie. Invalid source - IM

I just double checked and thats the only place the code shows up. I'm not sure what else to tell you other than simple things like making sure the changes were actually saved, you are editing the correct file (such as if you had a "source" code that you used for testing and then the actual love code). Otherwise, I'm at a loss, that should make it work.

Ok, just to clarify I have the following:

staff/newticket.inc.php

<select name="source">

<option value="" selected >Select Source</option>

<option value="Phone" <?=($info=='Phone')?'selected':''?>>Phone</option>

<option value="Email" <?=($info=='Email')?'selected':''?>>Email</option>

<option value="IM" <?=($info=='IM')?'selected':''?>>IM</option>

<option value="Other" <?=($info=='Other')?'selected':''?>>Other</option>

</select>

As you can see, IM has been added as an option.

Then I have updated class.ticket.php

if($var && !in_array(strtolower($var),array('email','phone','other','IM')))

$errors='Invalid source - '.Format:($var);

Additionally, I restarted apache on the system just to make sure.

Sounds like there is not anything left to do? If not, I'll just remove this and the users will have to choose "Other" but seems rather silly that this can't be fixed.

Thanks again for you help.

Yep, that all looks correct to me. I assume since you are in class.ticket.php that you are using 1.6 ST. Is that correct? I can setup a similar system here and see how it works for me, but I want to make certain of what version you are using first.

I don't think it should matter anyway since there is a strtolower function in there but just in case...what if you put the value of IM as im instead?

Such as

<option value="im" <?=($info=='IM')?'selected':''?>>IM</option>

Again, I don't think this should matter but I've found that...when logic fails....try doing things illogically

Then I have updated class.ticket.php

if($var && !in_array(strtolower($var),array('email','phone','other','IM')))

$errors='Invalid source - '.Format:($var);

should be:

if($var && !in_array(strtolower($var),array('email','phone','other','im')))

$errors='Invalid source - '.Format:($var);

IM->im.

Thank you scottro and peter. Looks like just changing IM to im has resolved this issue and I am now able to use that as a ticket source. Thank you so much!

Any ideas why the "Source" does not show up when the ticket is opened through the staff interface? Look like there is no value appearing even though the ticket saved using "IM" as the source.

2 months later

Any ideas why the "Source" does not show up when the ticket is opened through the staff interface? Look like there is no value appearing even though the ticket saved using "IM" as the source.

Old thread, but in case anyone else runs into this issue, the reason that it doesn't show your new source is because that value never makes it to the database - that field only allows 4 possible values:

mysql> SHOW COLUMNS IN ost_ticket IN osticket LIKE 'source';

+--------+-----------------------------------------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+--------+-----------------------------------------------+------+-----+---------+-------+

| source | enum('Web','Email','Phone','Other') | YES | | NULL | |

+--------+-----------------------------------------------+------+-----+---------+-------+

1 row in set (0.00 sec)

You need to add your custom source to the enum list:

ALTER TABLE `ost_ticket` MODIFY COLUMN `source` ENUM('Web','Email','Phone','Other','Walk-in');

Now it'll accept it:

mysql> SHOW COLUMNS IN ost_ticket IN osticket LIKE 'source';

+--------+-----------------------------------------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+--------+-----------------------------------------------+------+-----+---------+-------+

| source | enum('Web','Email','Phone','Other','Walk-in') | YES | | NULL | |

+--------+-----------------------------------------------+------+-----+---------+-------+

1 row in set (0.00 sec)

Notes:

* I used "Walk-in" for my setup instead of IM - I assume it'll work if you just put that in instead.

* Any tickets you've already opened using that new source will still have no source. Either go in the db and add it manually, or just don't worry about it and new tickets from now on will show that source...

Write a Reply...