How to ignore "Required" fields when Custom Function Executes?

How to ignore "Required" fields when Custom Function Executes?

Hi All -

I have a Custom Function that "cleans" the Subject if it contains certain characters (i.e. FW:, RE: etc). The problem is I also have required fields on my Incident Template therefore when a ticket is created by email, the Function executes but fails since required fields need to be updated first. 

So, I have the Function getting triggered on "Created" and "Edited" so eventually it does work but it clutters the "Notification" icon since it executes so much.  Is there a way to update the Request with the Custom Function and IGNORE the required fields?

Here's my function:

configuration = global_function_4();
instanceJson = context.get("instance");
helpdeskID = instanceJson.get("id");
workorderid = requestObj.get("id");

input_data = {
"request": {
"subject": replaceall(replaceall(replaceall(replaceall(requestObj.get("subject"),'FW: ',''),'RE: ',''),'fw: ',''),'re: ','')
}
};
info input_data;
info configuration.get("url");
response = invokeurl
[
url: replaceall(configuration.get("url"),'http','https') + "/api/v3/requests/"+workorderid
type: PUT
parameters: {"input_data" : input_data}
headers: {"authtoken":configuration.get("technicianKey"),"PORTALID":helpdeskID}
];
info response;

returnObj = Collection();
if(response.get("response_status").get("status_code") == 2000) {
returnObj.insert("result":"Success","message":"Subject Updated!");
}
else{
returnObj.insert("result":"failure","message":response);
}
return returnObj;

                New to ADManager Plus?

                  New to ADSelfService Plus?