簡體   English   中英

如何在Netsuite的suitescript 2.0中獲取登錄用戶的個人資料圖像?

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

我可以通過下面的suitescript 2.0獲取登錄的用戶詳細信息

    runtime.getCurrentUser();

回應是

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

沒有屬性可以從getCurrentUser() 的響應中獲取圖像。 有沒有其他方法可以在 Suitescript 2.0 中獲取登錄用戶的個人資料圖片?

您需要使用記錄或搜索模塊從員工(用戶)記錄中獲取圖像 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');

或者:

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

對於服務器腳本,您可以使用N/file模塊加載圖像文件,傳入imageId 如果需要在客戶端獲取圖片,可以獲取字段的文本而不是值:

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

這將返回文件櫃中圖像的相對路徑。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM