Spam in Customer service - Users delete request? og help with script to delete requests in category

Hi

Hope you can help me with this one 

How is it possible to give the customer service user acces to dele a request, without beeing full administrator? (we get spam in and they need to dele those requests)

Any better ways?

Or else

- I can ask them to assign this spam email/request to a specific category - but then i need a script to delete all request evert 5 minute etc. within that given "spam category"

 

Please let me know

 

Thanks
Jesper 

RE: Spam in Customer service - Users delete request? og help with script to delete requests in category

Hi!

Delete is unfortunally part of full administrator. Wish it could be a separate role as well.

Anne Lene

Av: Anne Lene Solheim Lilleberg 8. jun 2017

RE: Spam in Customer service - Users delete request? og help with script to delete requests in category

Or you could just create a button available on the View Ticket screen which both marks the ticket as deleted and moves it into spam category.

You don't need admin rights if you create a custom button that does exactly what you tell it to do.

Av: Hans Wilhelmsen 8. jun 2017

RE: Spam in Customer service - Users delete request? og help with script to delete requests in category

Hi Hans

Ok, that sounds nice! - Are there any description on how to do that?

/Jesper 

Av: Jesper Vedholm Hansen 8. jun 2017

RE: Spam in Customer service - Users delete request? og help with script to delete requests in category

You basically create a script does the following:

Takes the ID of the ticket you're reading.

Loads the ticket.

Changes the status of the ticket to 4 (deleted) and (optionally) the category of the ticket to the ID of a category you want.

Saves the ticket.

It could look something like this:

#setLanguageLevel 3;

String ticketId = getVariable("entryId");

Ticket t;
t.load(ticketId.toInteger());
t.setValue("status","4");
t.save();

 

Then you head over to to Settings -> System Design -> Extra menus.

Create a new extra menu for "Top menu" -> "View request" called "Spam" for example. Then you make sure this extra menu is set to "Use script" and you point it to the script you made earlier.
Finally you need to make sure "Append ID" is checked.

This should leave you with a button called "Spam" when clicking the "hamburger menu" on a ticket.

Here is a link to the SDK, and more specifically directly into the setValue function for the Ticket class so you can see which other parameters it can take. ("category" might be interesting for example.

If you want something more advanced you could always book one of our consultants.

Av: Hans Wilhelmsen 9. jun 2017

RE: Spam in Customer service - Users delete request? og help with script to delete requests in category

If you want the original delete button to work regardless, you'll have to edit the "Edit ticket 80" screen, take a copy of it first and edit the copy.

  1. Click the "Form page" element (top element)
  2. Click the "Creation script" pane
  3. Remove the if-statement so that the only part remaining is formPage.setFieldValue("addButton...

That should enable the delete button regardless of which role you've got.

Av: Simen Mostuen Iversen 9. jun 2017

RE: Spam in Customer service - Users delete request? og help with script to delete requests in category

The method presented by Simen is another way to do it. 

Av: Hans Wilhelmsen 9. jun 2017

RE: Spam in Customer service - Users delete request? og help with script to delete requests in category

Thanks both! I will try the most simple first.

Simon

- If i edit the copy.. how do i get the original edited or active? (it seems locked)

/Jesper

 

Av: Jesper Vedholm Hansen 12. jun 2017

RE: Spam in Customer service - Users delete request? og help with script to delete requests in category

If you edit a copy you need to make a screenchooser for "edit ticket" that points to the new screen.

If you want to edit the original you need to either go into Packages and unlock the System Screens package or into ?action=debug and unlock it. Keep in mind that editing default screens/keeping these unlocked can cause issues when upgrading. 

Av: Hans Wilhelmsen 12. jun 2017

RE: Spam in Customer service - Users delete request? og help with script to delete requests in category

Hi

When i remove the "if" statement i get the error when using the "edit" request after.

Before

After

Error when i click "edit" on request

Av: Jesper Vedholm Hansen 12. jun 2017

RE: Spam in Customer service - Users delete request? og help with script to delete requests in category

You need to remove the curly braces as well, they belong to the if statement.

if (something)
do whatever is inside the curly braces
{
 add delete button
}

In other words everything except "add delete button" should be deleted.

Av: Hans Wilhelmsen 12. jun 2017

RE: Spam in Customer service - Users delete request? og help with script to delete requests in category

Hi Jesper,

as Hans mentioned, remove the curly brackets as well ( { and } ).

 

We don't advice to edit the original file, instead we advice to take a copy and change the pointers to the copy instead.

This is done by editing the screen choosers (new ticket, reply, edit ticket choosers)

This is also a bit advanced if you haven't done this previously, so I recommend getting help from someone experienced with this.

The code in the screen chooser needs to be something like this:

New Ticket:

setVariable("url", getProgramTicket() + "&action=doScreenDefinition&id=123&actionType=0");

Reply:

String url = getProgramTicket() + "&action=doScreenDefinition&id=123&actionType=1&entryId=" + getVariable("entryId");
if(getCgiVariable("copyToAll") == "true")
  url.append("&copyToAll=true");
setVariable("url", url);



Edit:

setVariable("url", getProgramTicket() + "&action=doScreenDefinition&id=123&actionType=2&entryId=" + getVariable("entryId")");

 

where you change 123 with the id of your copied screen.

Note that my example code isn't necessarily correct, and it is recommended that you test it thoroughly.

Av: Simen Mostuen Iversen 12. jun 2017

RE: Spam in Customer service - Users delete request? og help with script to delete requests in category

Ok, thanks! I look into this

The "Delete" buttom i am able to get visible, but when a user click on it they get an error anyway

 

Av: Jesper Vedholm Hansen 12. jun 2017

RE: Spam in Customer service - Users delete request? og help with script to delete requests in category

Jesper,

open the screen and click the Buttons pane and find the "delete" script.

This is how it looks like:

User u = getActiveUser();
if(u.isAdministrator())
{
...
}
else
 exitWithMessage(getLanguageVariable("lang_global_messages_noAccess"));

You'll need to remove the if statement with the curly brackets, and the else statement and the exit with message so that the only thing remaining is the text inside the if statement i.e: 

Integer entryId = getVariable("entryId").toInteger();

User u = getActiveUser();

Integer actionType = getCgiVariable("actionType").toInteger();
Bool newWindow;
FHBitSet flags;
flags.set(u.getValue("flags").toInteger());

newWindow = flags.getBitNo(11);

if(entryId > 0)
{
  Ticket t;
  t.load(entryId);
  t.setValue("status", "4");
  t.save("Ticket deleted");
  if( newWindow && (action == 1 || actionType == 2))
    setVariable("url", "?action=doScreenDefinition&idString=ej_closeTicket&ticketId=" + entryId.toString());
  else
    setVariable("url", getProgram(1) + "?action=listTicketMessages&ticketId=" + entryId.toString());
}
else
  setVariable("url", getProgram(1) + "?action=mainMenu");
Av: Simen Mostuen Iversen 12. jun 2017

RE: Spam in Customer service - Users delete request? og help with script to delete requests in category

Thanks all!!

Av: Jesper Vedholm Hansen 12. jun 2017