根据上下级用户,自动共享数据给到上级用户

根据上下级用户,自动共享数据给到上级用户

sharelist = List();
resp = zoho.crm.getRecordById("CustomModule2",id);
last_id = resp.get("field6").get("id").toString();
//customer_count = zoho.crm.searchRecords("Accounts","(Account_Name:equals:" + last_name + ")",1,200);
customer_count = zoho.crm.getRecordById("Accounts",last_id);
parent_customer = ifnull(customer_count.get("field7").toString(),"");
if(parent_customer != "")
{
response1 = invokeurl
[
type :GET
connection:"dealscontact_roles"
];
for each  sj_name in parent_customer
{
users = response1.get("users");
for each  user_count in users
{
user_name = user_count.get("last_name").toString();
if(sj_name == user_name)
{
info "exists" + user_name;
user_id = user_count.get("id").toString();
mp = Map();
mp.put("user",{"id":"" + user_id + ""});
//full_access- Allow the user full access to the record. This is the default value.
               //read_only - Allow the user to only view the record.
//read_write - Allow the user to view and edit the record.
mp.put("permission","read_only");
sharelist.add(mp);
}
}
}
//info sharelist;
dmp = Map();
dmp.put("share",sharelist);
resp = invokeurl
[
type :POST
parameters:dmp.toString()
connection:"dealscontact_roles"
];
info "exists" + resp;
}