Best practice when changing "Edit Ticket" screen for Online customers?

Hi,

we've been reluctant to customize the "Edit ticket 80" screen for Online customers, because we prefer that they use the standard screens as much as possible. However, in some edge cases we are forced to make some sort of modification to it.

I'm trying to figure out what the best way to configure the ScreenChoosers are, so that everything works as close to normal as possible. Both for new tickets, replying to tickets, editing tickets, creating new tickets from persons and whereever else the Edit Ticket is called.

Here are the three screenchoosers I'm testing out so far:

New request

#setLanguageLevel 3;

String args;
Map cgi = getCgiVariables();
cgi.remove("action");
cgi.remove("_sf");

cgi.insert("actionType", "0"); //0 = New request

for (cgi.first(); !cgi.eof(); cgi.next())
  args += "&" + cgi.getKey() + "=" + cgi.getVal();

setVariable("url", getProgramTicket() + "&action=doScreenDefinition&idString=ej_editTicket_80_kopi" + args);

Edit request

#setLanguageLevel 3;

String args;
Map cgi = getCgiVariables();
cgi.remove("action");
cgi.remove("_sf");

cgi.insert("entryId", cgi.get("ticketId"));
cgi.insert("actionType", "2"); //2 = Edit request

for (cgi.first(); !cgi.eof(); cgi.next())
  args += "&" + cgi.getKey() + "=" + cgi.getVal();

setVariable("url", getProgramTicket() + "&action=doScreenDefinition&idString=ej_editTicket_80_kopi" + args);

Reply to customer

#setLanguageLevel 3;

String args;
Map cgi = getCgiVariables();
cgi.remove("action");
cgi.remove("_sf");

cgi.insert("entryId", cgi.get("ticketId"));
cgi.insert("actionType", "1"); //1 = Add message

for (cgi.first(); !cgi.eof(); cgi.next())
  args += "&" + cgi.getKey() + "=" + cgi.getVal();

setVariable("url", getProgramTicket() + "&action=doScreenDefinition&idString=ej_editTicket_80_kopi" + args);

This seems to "mostly" work, but there is at least one problem. When you start out with the inline-reply to customer, but then click the Edit button it crashes:

 

 

What are the experiences you guys have when modifying the "Edit ticket" screen in Online?

RE: Best practice when changing "Edit Ticket" screen for Online customers?

Anyone? What are your experiences with using screenchoosers for the standard screens in Online?

Af: Frode Lillerud 4. nov 2020

RE: Best practice when changing "Edit Ticket" screen for Online customers?

Hi Frode,

I am experiencing same issues as you describe, looks like we need to investigate why this is happening.

Af: Michel Krohn-Dale 5. nov 2020

RE: Best practice when changing "Edit Ticket" screen for Online customers?

Thank you, Michel.

In addition to figuring out why it crashes in that particular scenario, I'm also interrested in any other generic improvements to the three screenchooser scripts, so that we end up with three common scripts that can be used for all customers where we want to make SuperOffice use a copy of Edit Ticket.

Af: Frode Lillerud 6. nov 2020

RE: Best practice when changing "Edit Ticket" screen for Online customers?

The reason for your screenchooser crashing when clicking the "Edit" button, is that you are taking all the cgi variables and appending them at the end of the URL. 

That screen will contain a cgi variable called "message", and the value of this one is the message itself (the HTML code), and it contains newlines. Adding new lines to a URL isn't that good :)

Fixing this particular issue is simple:

for (cgi.first(); !cgi.eof(); cgi.next())
args += "&" + cgi.getKey() + "=" + cgi.getVal().urlEncode();

I have added "urlEncode()" to the value part as you can see. Now it works.

But you might end up in another problem. Since these are added to an URL, it might becom lengthy, and there is a limit of how long an URL can be on different browsers.

Af: Stian Andre Olsen 11. nov 2020

RE: Best practice when changing "Edit Ticket" screen for Online customers?

Ah, of course, I forgot URL encoding.

Do you see anything else that is missing from these generic screenchooser scripts? By removing _sf and action, and setting appropriate actiontype and entryId, and adding all the other CGI variables, we should be pretty well covered?

Af: Frode Lillerud 11. nov 2020

RE: Best practice when changing "Edit Ticket" screen for Online customers?

My experience is that if you start edit the qucik-reply message in the ViewTicket screen and then decide to go to the Edit Ticket screen passing variables like that will not be enough. At least not if you have pasted picture into the message.

So to go around I usually do a mix of what you came up to already and by using session variables.

--EDIT REQUEST SCREENCHOOSER ---------------------------------------

#setLanguageLevel 3;

String idString = "ej_editTicket_80_customername";
if (getVariable("activeUser") == "2") //admin when testing
idString = "ej_editTicket_80_customername_v2";

String message;
if (idString != "") {
String cgiVariablesToForward = "";
Map m = getCgiVariables();
if (m.size() > 0) {
m.first();
while(m.eof() ==false)
{
String m_getVal = m.getVal(); //.urlEncode() cannot be used on the message
if (m.getKey() == "action" || m.getKey() == "id") {
} else if (m.getKey() == "message") {
message = m_getVal; //works but signature/images will get lost unless changes in Edit Ticket.
//cgiVariablesToForward = cgiVariablesToForward + "&message=" + message;
} else if (m.getKey() == "ticketId") {
cgiVariablesToForward = cgiVariablesToForward + "&entryId=" + m_getVal + "&ticketId=" + m_getVal;
} else {
cgiVariablesToForward = cgiVariablesToForward + "&" + m.getKey() +"=" + m_getVal;
}
m.next();
}
}

if (getCgiVariable("actionType") == "")
cgiVariablesToForward = "&actionType=2" + cgiVariablesToForward;

if (message != "") {
setSessionVariable("loadMessage", message);
cgiVariablesToForward = cgiVariablesToForward + "&message=loadMessage";
//obs: anpassning måste även läggas in i svarsmallen Edit Ticket
}

String url = getProgram(1) + "&action=doScreenDefinition&idString=" + idString + cgiVariablesToForward;
setVariable("url", url);
}

 

 

And then in the Edit ticket screen I need to paste the following code in the end of the load script (before SetFromCgi)

//-------------------------------------------------------------------------------------------------------------------
if (getCgiVariable("message") == "loadMessage") {
getHtmlElement("msgEditor").setValue(getSessionVariable("loadMessage"));
setSessionVariable("loadMessage", "");
}
//-------------------------------------------------------------------------------------------------------------------

Af: Gustaf Cullin 23. nov 2020