Identity Portal forms - Modify user - api.getSubject() usage
search cancel

Identity Portal forms - Modify user - api.getSubject() usage

book

Article ID: 101392

calendar_today

Updated On:

Products

CA Identity Manager CA Identity Governance CA Identity Portal

Issue/Introduction

In a Modify form, in some handlers, I need to get some properties related to the user passed in the context (i.e. %STRING_01%, %ORG_MEMBERSHIP%, ...).

The manual for api.getSubject() says:
"Returns an array of the managed objects in the context of the form. The managed object types are either user or group." 

In my case for modify user, I should find a "User" (com.netegrity.llsdk6.imsapi.managedobject.User ?) in the first position of the array, in fact the user is correctly fetched in the form and I can see the fields. If I try:

var subject = api.getSubject();
var user = subject[0];
console.log("Friendly name: " +  user.getFriendlyName());
 
I get an error: user.getFriendlyName is not a function.

How to code the script to get user attribute values?
 

Environment

Release:
Component: SIGMA

Resolution

First of all, the user attributes available in the user object and returned by "api.getSubject()" are the attributes configured in the Managed Object Attributes screen (in the Admin UI -> Setup).
Make sure that the required attribute is configured in the User Attributes list in the Managed Object Attributes screen.




Sample 1 to display user information in Message prop of an invocation request form 
// This operation is for a single target 
var userObj = api.getSubject()[0];



// Present user data 
prop.message = 'Manager : ' + userObj.userData.Manager + '<br>' 
+ 'Email : ' + userObj.userData.Email + '<br>' 
+ 'Phone : ' + userObj.userData.Phone + '<br>' 
+ 'Title: ' + userObj.userData.Title;




Sample 2 to display target users name for bulk access, also in message prop: 
prop.message = 'Users are: <br>'; 
var subject = api.getSubject();



subject.forEach(function(user){ 
prop.message += user.getDisplayName() + '<br>'; 
});



 



Sample 3 to display a User attribute with such a name as "Role Org Based" including blank characters and mapped to a back-end attribute as "%STRING_nn%",
you can get its value for the specific user who is the subject of the request using this:



var userObj = api.getSubject()[0]; 
var roleOrgBased = userObj.userData['Role Org Based'];



now roleOrgBased will contain the value this user has in the %STRING_nn% attribute. 
Notice that if this is a multi value attribute you might need to parse the value.