Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
Hi,
I am trying to get the User Object from imUserBean, but I think it cannot be created: JavaScript Error: Internal Error: undefined: Cannot convert null to an object
function main()
{
if(delta.isNewlyPosted() && delta.getNewFieldValue("Severity") == null){
abort(user.getFullName());
}
}
var delta = bsf.lookupBean("imIssueDeltaBean");
var eb = bsf.lookupBean("siEnvironmentBean");
var user = bsf.lookupBean("imUserBean");
main();
So I am trying to create the object with bsf.lookupBean and then abort the action with the full name of the user who caused this action.
Instead I get the error in the line (bold).
Thanks in advance
Alexander
Solved! Go to Solution.
There is a difference between user beans from the Integrity Manager (Workflow & Documents) and the Domain Users.
Unfortunately both use a Bean called .....ScriptUserBean
I'm not sure with one is returned by
bsf.lookupBean("imUserBean")
Nevertheless, every time I tried to solve a task like your's in the past I ended up using the following template:
//get the Server bean
var sb = bsf.lookupBean("imServerBean");
// get the bean representing the current item
var delta = bsf.lookupBean("imIssueDeltaBean");
// fetch the user name from the current item's bean e.g.
var currentUserName = delta.getCurrentUser();
// retrieve the matching user bean from the server
var userbean = sb.getUserBean(currentUserName);
// analyze the user bean
if( userbean.isMember("a Group") == true ){
// do something
}
HI Alex,
i assume your user is null, as
var user = bsf.lookupBean("imUserBean");
ives you an undefined user bean.
I'd choose someting like this:
var user = delta.getCurrentUser();
or
var user = delta.getCreatedUser();
or
var user = delta.getModifiedUser();
given your use case, they should all return the same user.
HTH Matthias
Hi,
thank you for your reply.
Iis not described in my question, but I need furthermore the group of the user, not only his name.
I want to try something like this:
var user = bsf.lookupBean("imUserBean");
if(user.isMember("Some_group")){
abort("foo");
}
I dont understand why this bean is empty or null. Because I use a Domain User who is imported into Workflows&Documents. It must have bean for IM user...
Any other idea how to get the user and its groups or membership of a specific group?
Thank you
There is a difference between user beans from the Integrity Manager (Workflow & Documents) and the Domain Users.
Unfortunately both use a Bean called .....ScriptUserBean
I'm not sure with one is returned by
bsf.lookupBean("imUserBean")
Nevertheless, every time I tried to solve a task like your's in the past I ended up using the following template:
//get the Server bean
var sb = bsf.lookupBean("imServerBean");
// get the bean representing the current item
var delta = bsf.lookupBean("imIssueDeltaBean");
// fetch the user name from the current item's bean e.g.
var currentUserName = delta.getCurrentUser();
// retrieve the matching user bean from the server
var userbean = sb.getUserBean(currentUserName);
// analyze the user bean
if( userbean.isMember("a Group") == true ){
// do something
}
Hello Matthias Rump,
If you look at the JavaDoc followed from the Event Trigger Java Documenation off of most server's home pages, the method getExposedName() of a given class will tell you the name of the bean used for bsf.lookupBean(String foo). In this case, it's mks.ci.server.engine.LocalTriggerManager.ScriptUserBean.
Regards,
Kael
That is exactly what I am looking for.
Thank you very much.