New Client Script

PHOTO EMBED

Tue Jul 01 2025 07:37:07 GMT+0000 (Coordinated Universal Time)

Saved by @Peaky ##pagination ##zoho ##crm ##zohocrm ##zoho_crm ##deluge

var userID = $Crm.user.id;
console.log("userID==>", userID);
var userName = $Crm.user.first_name; // + " " + $Crm.user.last_name;
console.log("userName==>", userName);
var module = $Page.module;
console.log("module==>", module);
var module_recordID = $Page.record_id;
console.log("module_recordID==>", module_recordID);
var recordName = $Page.record._Full_Name;
console.log("recordName==>", recordName);
var owner = ZDK.Page.getField('Owner').getValue();
console.log("owner==>", owner);
var ownerID = ZDK.Apps.CRM.Users.fetchById(owner.id);
console.log("owner==>", owner);
// Construct the map to include both fields you want to update

created_time = ZDK.Page.getField('Created_By').getValue();
console.log("created_time==>", created_time);

var map = {
    "Last_Viewed_User_ID": userID
};

console.log("User ID: " + userID);

// Prepare data for the API call
var datalist = [];
datalist.push(map);

var param = { "data": datalist };

// API call to update the record in Zoho CRM
var response = ZDK.Apps.CRM.Connections.invoke(
    "crmconn", 
    "https://www.zohoapis.com/crm/v5/" + module + "/" + module_recordID, 
    "PUT", 
    2, 
    param, 
    {}
);

console.log("Response: ", response);
content_copyCOPY