简体   繁体   English

如何在Netsuite的suitescript 2.0中获取登录用户的个人资料图像?

[英]How to get profile image of logged user in suitescript 2.0 in Netsuite?

I am able to get logged user details through below suitescript 2.0我可以通过下面的suitescript 2.0获取登录的用户详细信息

    runtime.getCurrentUser();

The response is回应是

{
    "id": 12345,
    "name": "ABC",
    "email": "abc@gmail.com",
    "location": 0,
    "department": 0,
    "role": 3,
    "roleId": "administrator",
    "roleCenter": "BASIC",
    "subsidiary": 1,
    "timezone": "Asia/Calcutta"
} 

There is no property to get image from response of getCurrentUser() .没有属性可以从getCurrentUser() 的响应中获取图像。 Any other way to get profile picture of logged user in Suitescript 2.0?有没有其他方法可以在 Suitescript 2.0 中获取登录用户的个人资料图片?

You would need to get the image id from the employee (user) record using the record or search module, passing in the user id:您需要使用记录或搜索模块从员工(用户)记录中获取图像 ID,并传入用户 ID:

var userId = runtime.getCurrentUser().id;
var userRecord = record.load({  //make sure 'N/record' is defined as record
    type: record.Type.EMPLOYEE,
    id: userId
});
var imageId = userRecord.getValue('image');

Or:或者:

var userId = runtime.getCurrentUser().id;
var imageId = search.lookupFields({
    type: search.Type.EMPLOYEE,
    id: userId,
    columns: 'image'
}).image[0].value;

For server scripts, you can then use the N/file module to load the image file, passing in the imageId .对于服务器脚本,您可以使用N/file模块加载图像文件,传入imageId If you need to get the image in the client side, you can get the text of the field instead of the value:如果需要在客户端获取图片,可以获取字段的文本而不是值:

var userId = runtime.getCurrentUser().id;
var imageId = search.lookupFields({
    type: search.Type.EMPLOYEE,
    id: userId,
    columns: 'image'
}).image[0].text;

which will return the relative path to the image in the file cabinet.这将返回文件柜中图像的相对路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM