Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
        // implement resource here
    
        var queryParams = request.queryParams; 
        var userEmail = queryParams.userEmail;
    
        // Obtain the user system Id corresponding to the user Id
        var userId = gs.getUser().getUserByEmail(userEmail).getName();
    
        var adminUser = gs.getSession().getUserName().toString();

        var impersonateSuccess = gs.getSession().impersonate(userId);

        if (impersonateSuccess){
            // Retrieve all user criteria
            var allCriterias = SNC.UserCriteriaLoader.getAllUserCriteria();
    
            response.setBody(allCriterias);
        }        

        gs.getSession().impersonate(adminUser);

        response.setContentType('application/json');
        response.setStatus(200);

    
})(request, response);





Or

...

the

...

user's

...

sys_id:

Code Block


(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
        // implement resource here
    
        var queryParams = request.queryParams; 
        var userId = queryParams.userId;
        
        var adminUser = gs.getSession().getUserName().toString();

        var impersonateSuccess = gs.getSession().impersonate(userId);

        if (impersonateSuccess){
            // Retrieve all user criteria for the impersonated user
            var allCriterias = SNC.UserCriteriaLoader.getAllUserCriteria();
    
            response.setBody(allCriterias);
        }        

        gs.getSession().impersonate(adminUser);

        response.setContentType('application/json');
        response.setStatus(200);

    
})(request, response);

...