// ------------ Get loginuser name and id and then get the default Layout for that user's Profile ------------
// (user creating invoice will be the owner of the invoice)
u_resp = zoho.crm.invokeConnector("crm.getusers",{"type":"ActiveUsers"});
u_respMap = u_resp.get("response").toMap();
u_respList = u_respMap.get("users").toJSONList();
//info respList;
for each u_respVar in u_respList
{
email = u_respVar.get("email");
if(zoho.loginuserid == email)
{
user_id = u_respVar.get("id");
user_profile_name = u_respVar.get("profile").getJSON("name");
info "user_profile_name : " + user_profile_name;
}
}
user_name = zoho.loginuser;
layouts_resp = invokeurl
[
type :GET
connection:"InsertYourZohoConnectionHere"
];
layoutslist = layouts_resp.get("layouts").toJSONList();
for each layout_item in layoutslist
{
profileslist = layout_item.get("profiles").toJSONList();
for each profile_item in profileslist
{
if(user_profile_name == profile_item.get("name") && profile_item.get("default") == true)
{
layout_id = layout_item.get("id");
layout_name = layout_item.get("name");
info profile_item.get("name") + ", default = " + profile_item.get("default");
info "Using Layout : " + layout_name + ", ID : " + layout_id;
}
}
}
// ------------------------------------------------------------------
map_layout = Map();
map_layout.put("name",layout_name);
map_layout.put("id",layout_id);
paramap.put("Layout",map_layout);