How to get the user's name with JavaScript in Harvest version 7.1?

HAMielsch's picture
HAMielsch asked on February 16, 2012 - 2:47pm | Replies (2).

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

HAMielsch's picture
HAMielsch replied on February 17, 2012 - 2:45pm.

OK, CA Support sent my the fragment "editor.getSession().getUser().getName()", which works fine.
:)

pgibbs's picture
pgibbs replied on February 17, 2012 - 4:30pm.

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.

CMCrossroads is a TechWell community.

Through conferences, training, consulting, and online resources, TechWell helps you develop and deliver great software every day.