getVariable("messageId")

Hi,

I created a script using that is initiated by an extra menu item on message level.

But the script does not seem to get the messageId from the menu item.

Was this not implemented to work that way, or am I missing something?

My script does actually just one thing and that is to set the access level of the message to external.

Thanx!

 

#setLanguageLevel 3;

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

Message m;
m.load (messageId);
m.setValue("slevel","2");
m.save();

RE: getVariable("messageId")

Hi Niels,

in your code you write this:

Integer messageId = (getVariable("messageId").toInteger());
 
Message m;
m.load (messageId);
m.setValue("slevel","2");
m.save();

 

Why Integer messageId = (getVariable("messageId").toInteger()); ?

Why not just Integer messageId = getVariable("messageId").toInteger(); ?

Anyways, a good way to find out all available variables is to write this code, although I'm certain you already know of this:

Map mVar = getVariables();
while(!mVar.eof())
{
  log("Var: " + mVar.getKey() + ": " + mVar.getVal());
  mVar.next();
}

It'll show all keys and it's value.

Where to locate the log: http(s)://<service-url>/scripts/rms.fcgi?action=newLog

Av: Simen Mostuen Iversen 24. apr 2017

RE: getVariable("messageId")

Hi Simen,

Thanks for your elaboration.

For the values I used the print function in stead of the log function, since I an in Online. This gives me the following result when started from a message.

 

Var: AIMRevision: 8.1.0000.0Var: AIMVersion: 8.1.0000.0Var: __returnScreen: 5Var: _sf: 0Var: action: doScriptVar: activeAssociateId: 5Var: activeUser: 2Var: activeUsername: NBVar: contactId: Var: debugId: Var: entryId: 497Var: id: 55Var: messageId: Var: personId: Var: serverName: online.superoffice.comVar: ticketId: Var: userLang: nl

So I seems that the messageId is actually not filled, but fortunately the entryId is and contains the value of the messageId.

So I changed my script to the following and this works! I had to add the last part, since returning to the screen did not work either since the TicketID was not put in the variables.

Thank you for the tips!

#setLanguageLevel 3;

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

Message m;
m.load (messageId);
m.setValue("slevel","2");
m.save();
String ticketId=m.getValue("ticketId");
setVariable("url", getProgram(1) + "?action=listTicketMessages&ticketId=" + ticketId);
 
Av: Niels van Broekhoven 24. apr 2017