I have a deluge script to share a request with anyone who is in the "emails to notify". but i would like to exclude a specific user, as that user is getting the ticket shared through another script. But i am not sure how to do that.
configuration = global_function_6();
returnObj = Collection();
requestID = requestObj.get("id");
helpdeskID = context.get("instance").get("id");
//get the emailIDs of the users to share the request
mail_ids = requestObj.get("email_ids_to_notify");
if(mail_ids == null || mail_ids.isEmpty()) {
returnObj = {"result":"success","message":"No email ids to notify"};
return returnObj;
}
userEmailIDs = {"emailIDs":mail_ids};
//global_function_2 will return the list of users with the emailIDs passed as argumemts
userJson = global_function_2(helpdeskID,userEmailIDs).toMap();
if(userJson.containKey("users")) {
users = userJson.get("users");
technician_json = Collection();
user_json = Collection();
for each user in users
{
//If the email id belongs to technician, data is appended to technician details
is_tech = user.get("is_technician");
if(is_tech) {
technician_json.insert({"id": user.get("id")});
}
//If the email id belongs to requester, data is appended to user details
else {
user_json.insert({"id": user.get("id")});
}
}
share = Collection();
share.insert("technicians":technician_json);
share.insert("users":user_json);
input_data = {"share":share};
//Please update all the parameters like the ServerName , portnumber and Technician API key based on your Environment.
responseJson = invokeurl
[
url: configuration.get("url")+"/api/v3/requests/"+requestID+"/share"
type: PUT
parameters: {"input_data":input_data}
headers: {"authtoken":configuration.get("technicianKey"),"PORTALID":helpdeskID}
];
response_status = responseJson.get("response_status");
messages = response_status.get("messages");
messageJson = messages.get(0);
if(messageJson.get("status_code").equals("200")) {
returnObj.insert("result":"success");
returnObj.insert("message":"Request updated successfully");
}
else {
returnObj.insert("result":"failure");
returnObj.insert("message":"Failed to update request");
}
} else {
returnObj.insert("result":"failure");
returnObj.insert("message":"Failure in getting user details");
}
return returnObj;