CMDBuild Forum

Re: Workflows using CurrentUser reftype

Hello,

I'm working on a new workflow and I'm attempting to pull the current users email address from their user account record into the workflow.

This is a small workflow to ensure I can use the functionality in larger workflows, but for some reason I error out on the script.

Here's the script:

ContactList = cmdb.queryClass("User").withAttribute("Id", _CurrentUser.getId()).fetch

Contact = ContactList.get(0);

ContactMap = Contact.getAttributes();

contName = ContactMap.get("Description");

contEmail = ContactMap.get("Email");

contUname = ContactMap.get("Username");

 

Yes I realise that some of my classes start with lowercase chars.

Here's the error I get:

2014-08-11 14:10:05,798: BshToolAgent - application ContactList = cmdb.queryClass("User").withAttribute("Id", _CurrentUser.getId()).fetch();

Contact = ContactList.get(0);

ContactMap = Contact.getAttributes();

contName = ContactMap.get("Description");

contEmail = ContactMap.get("Email");

contUname = ContactMap.get("Username"); terminated incorrectly: Sourced file: eval stream : Method Invocation fetch : at Line: 1 : in file: eval stream : .fetch ( )

Target exception: javax.xml.ws.soap.SOAPFaultException: Fault occurred while processing.

2014-08-11 14:10:05,798: cannot execute tool agent - application  terminated incorrectly

Sourced file: eval stream : Method Invocation fetch : at Line: 1 : in file: eval stream : .fetch ( )

 

Has something changed in the API? This code snippet worked for me previously.

Any suggestions would be great, thanks.

Jamie

 

Okay I've created a workaround for this, it appears to be specific when trying to reference objects in the User class / table. I'm assuming this isn't a public class in the application which means I can't reference it other than through keywords.
 
Might I suggest a feature in future for also referencing the current user's e-mail address to ensure they receive e-mails on their part of the process?
 
My work around involved using my own contacts table which matches based on the description as key and pulls the attributes from there.
 
I'm now going to create a trigger for any new users to be created in that contacts table.
 
Thanks,
Jamie
 
Previously Jamie wrote:

Hello,

I'm working on a new workflow and I'm attempting to pull the current users email address from their user account record into the workflow.

This is a small workflow to ensure I can use the functionality in larger workflows, but for some reason I error out on the script.

Here's the script:

ContactList = cmdb.queryClass("User").withAttribute("Id", _CurrentUser.getId()).fetch

Contact = ContactList.get(0);

ContactMap = Contact.getAttributes();

contName = ContactMap.get("Description");

contEmail = ContactMap.get("Email");

contUname = ContactMap.get("Username");

 

Yes I realise that some of my classes start with lowercase chars.

Here's the error I get:

2014-08-11 14:10:05,798: BshToolAgent - application ContactList = cmdb.queryClass("User").withAttribute("Id", _CurrentUser.getId()).fetch();

Contact = ContactList.get(0);

ContactMap = Contact.getAttributes();

contName = ContactMap.get("Description");

contEmail = ContactMap.get("Email");

contUname = ContactMap.get("Username"); terminated incorrectly: Sourced file: eval stream : Method Invocation fetch : at Line: 1 : in file: eval stream : .fetch ( )

Target exception: javax.xml.ws.soap.SOAPFaultException: Fault occurred while processing.

2014-08-11 14:10:05,798: cannot execute tool agent - application  terminated incorrectly

Sourced file: eval stream : Method Invocation fetch : at Line: 1 : in file: eval stream : .fetch ( )

 

Has something changed in the API? This code snippet worked for me previously.

Any suggestions would be great, thanks.

Jamie