- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2023 03:32 PM
Hi, I am currently working on an Inbound Action to allow user re-open incidents by email. So far is working, but I wanted to restrict to only incidents which are not major incidents in 'accepted' or propose state.
gs.include('validators');
if (current.getTableName() == "incident") {
var gr = current;
// Trying to create a condition to restrict the major incident records being open
if (email.subject.toLowerCase().indexOf("reopen") >= 0 && gr.major_incident_state != 'accepted' || gr.major_incident_state != 'proposed')
gr = new ReOpenIncident().reopen(gr, email) || gr;
/* This is working, but its including major incidents records.
if (email.subject.toLowerCase().indexOf("reopen") >= 0)
gr = new ReOpenIncident().reopen(gr, email) || gr;
*/
gr.update();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2023 11:17 AM
Thanks @Ratnakar7 and @BharathChintala , I was able to figure out the issue. I was adding the condition in the wrong place. That code that I posted was in the action section of the inbound action but I need it into one of the script included which are being call in the script.
In the script above is calling another script include - ReOpenIncident, which will call another script include:
if (gr.state == IncidentState.RESOLVED&& gr.major_incident_state != 'accepted' && gr.major_incident_state != 'proposed') {
// If the incident is Resolved
gr.state = IncidentState.IN_PROGRESS;
gr.incident_state = IncidentState.IN_PROGRESS;
//gr.work_notes = gs.getMessage("The caller did not feel that this issue was resolved " + gr.number);
gr.update();
return gr;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2023 12:02 AM
@Edxavier Robert always use && when you give condition as != . Try below
gs.include('validators');
if (current.getTableName() == "incident") {
var gr = current;
// Trying to create a condition to restrict the major incident records being open
if (email.subject.toLowerCase().indexOf("reopen") >= 0 && gr.major_incident_state != 'accepted' && gr.major_incident_state != 'proposed')
gr = new ReOpenIncident().reopen(gr, email) || gr;
/* This is working, but its including major incidents records.
if (email.subject.toLowerCase().indexOf("reopen") >= 0)
gr = new ReOpenIncident().reopen(gr, email) || gr;
*/
gr.update();
}
Thanks,
Bharath
Bharath Chintala
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2023 06:11 AM
Hi @BharathChintala ,
I tired that but didn't work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2023 04:18 AM
Hi @Edxavier Robert ,
Can you please try with below code:
gs.include('validators');
if (current.getTableName() == "incident") {
var gr = current;
// Trying to create a condition to restrict the major incident records being open
if (email.subject.toLowerCase().indexOf("reopen") >= 0 && gr.major_incident_state != 'accepted' && gr.major_incident_state != 'proposed')
gr = new ReOpenIncident().reopen(gr, email) || gr;
/* This is working, but its including major incidents records.
if (email.subject.toLowerCase().indexOf("reopen") >= 0)
gr = new ReOpenIncident().reopen(gr, email) || gr;
*/
gr.update();
}
Thanks,
Ratnakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2023 06:12 AM
Hi, I tried that but didn't work.