OK, CA Support sent my the fragment "editor.getSession().getUser().getName()", which works fine.
:)
How to get the user's name with JavaScript in Harvest version 7.1?
We are planning to upgrade Harvest 7.1 to CA SCM 12.1SP2.
The handling of forms changed and unfortunately the scripting language, too. Now we would like to get the users name within an change event. With VBScript we had an User-object.
Where is the CA SCM userinfo located? In the editor object?
Is there a documentation for or experiences with the editor object?
Any help welcome
-Hans-Arno
2 Answers
Hi,
Here's some sample code from a form we wrote for a customer. When the form is first created, the creating user's real name and telephone number is placed into the form, along with the creation date and some default target environments for testing.
<initialization language="javascript" client="eclipse">
if (editor.getTextFieldValue("rr_requestor").length() ==0)
{
editor.setTextFieldValue("rr_requestor",editor.getUser().name);
editor.setTextFieldValue("rr_tel",editor.getUser().getPhoneNumber());
editor.setDateFieldValue("rr_date",new Date());
editor.setTextFieldValue("rr_sit_target","TST1");
editor.setTextFieldValue("rr_uat_target","UAT1");
editor.setTextFieldValue("rr_preprod_target","SUP1");
editor.commit();
}
</initialization>
Hope this helps,
Phil.