Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
Hi,
i want to get the email address from a user inside a trigger script using the Integrity API. I've used mksapiviewer --iplocal im users --fields=email USERNAME to check if there is an output at all and it returned a response including a work item containing the field "Value" where the address is stored. I've tried
var eb = bsf.lookupBean("siEnvironmentBean");
var apibean = eb.createAPISessionBean();
var command = new Packages.com.mks.api.Command("im", "users");
command.addOption(new Packages.com.mks.api.Option("fields", "email");
command.addSelection(USERNAME);
var response = apibean.executeCmd(command);
var workitems = response.getWorkItems();
while(workitems.hasNext()){
var thisItem = workitems.next();
var val = thisItem.getField("Value");
}
Somewhere has to be a mistake since i get a NoSuchElementException: Value
Does somebody have an idea where the problem is??
Thanks!
Solved! Go to Solution.
Hi,
found the solution myself. I got confused with the fields inside the response, so using
var fld = thisItem.getField("notificationRule");
var val = fld.getValueAsString();
returns the Notification Rule as a string!
But thanks for your input!
Hello Stephan,
Whenever possible, you should attempt to use trigger beans rather than API calls from within a trigger. In this case, instead of your API call, you should call getEmailAddress() on an instance of ScriptUserBean.
You can get a ScriptUserBean for any user on the server by calling the getUserBean(<UserName>) on a ServerBean.
Regards,
Kael
Hi,
this may work for getting the email address, but there will be several other steps like getting the Notification Rule of the user, which I doubt can be done by using trigger beans alone. But thanks anyway!!
Stephan
Hi,
what is your Use Case?
The notification rule of a user can found in the Admin Gui (W&D-Users).
Hi,
found the solution myself. I got confused with the fields inside the response, so using
var fld = thisItem.getField("notificationRule");
var val = fld.getValueAsString();
returns the Notification Rule as a string!
But thanks for your input!
Hi Stephan,
I'm glad you figured it out yourself! You should mark your own answer as correct, then, since it's the one that actually answers your question.
Thanks for coming back and letting everyone know what that answer was!
Regards,
Kael
Hello, I need to call powershell script / vbs script from triggered javascript. I tried to use ActiveXObject but throws error stating 'ActiveXObject not defined'. any other way to call scripts using javascript? Thanks